Skip to content

Commit f26099d

Browse files
committed
shorten examples ven more #41
1 parent 2643cce commit f26099d

File tree

52 files changed

+168
-318
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+168
-318
lines changed

R/bpvars-package.R

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -204,32 +204,16 @@
204204
#' @examples
205205
#' # Basic estimation and forecasting example
206206
#' ############################################################
207-
#' specification = specify_bvarPANEL$new(ilo_dynamic_panel) # specify the model
207+
#' specification = specify_bvarPANEL$new(ilo_dynamic_panel[1:5]) # specify the model
208208
#' burn_in = estimate(specification, S = 5) # run the burn-in; use say S = 10000
209209
#' posterior = estimate(burn_in, S = 5) # estimate the model; use say S = 10000
210210
#' predictive = forecast(posterior, 2) # forecast the future
211211
#'
212212
#' # workflow with the pipe |>
213-
#' ilo_dynamic_panel |>
213+
#' ilo_dynamic_panel[1:5] |>
214214
#' specify_bvarPANEL$new() |>
215215
#' estimate(S = 5) |>
216216
#' estimate(S = 5) |>
217217
#' forecast(horizon = 2) -> predictive
218218
#'
219-
#' # Full estimation and forecasting example with
220-
#' # exogenous variables and truncation for rates
221-
#' ############################################################
222-
#' specification = specify_bvarPANEL$new(
223-
#' ilo_dynamic_panel,
224-
#' exogenous = ilo_exogenous_variables,
225-
#' type = c("real", rep("rate", 3))
226-
#' )
227-
#' burn_in = estimate(specification, S = 5) # run the burn-in; use say S = 10000
228-
#' posterior = estimate(burn_in, S = 5) # estimate the model; use say S = 10000
229-
#' predictive = forecast(
230-
#' posterior,
231-
#' horizon = 5,
232-
#' exogenous_forecast = ilo_exogenous_forecasts
233-
#' )
234-
#'
235219
"_PACKAGE"

R/compute_forecast_performance.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#' @author Tomasz Woźniak \email{wozniak.tom@pm.me}
2525
#'
2626
#' @examples
27-
#' spec = specify_bvarPANEL$new(ilo_dynamic_panel) # specify the model
27+
#' spec = specify_bvarPANEL$new(ilo_dynamic_panel[1:5]) # specify the model
2828
#' poos = specify_poosf_exercise$new(spec, 2, 5, 1, 30) # specify the forecasting exercise
2929
#' fore = forecast_poos_recursively(spec, poos) # perform the forecasting exercise
3030
#' fp = compute_forecast_performance(fore, "pls") # compute forecasting performance measures

R/compute_variance_decompositions.R

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#'
2929
#' @examples
3030
#' # specify the model and set seed
31-
#' specification = specify_bvarPANEL$new(ilo_dynamic_panel, p = 1)
31+
#' specification = specify_bvarPANEL$new(ilo_dynamic_panel[1:5], p = 1)
3232
#'
3333
#' # run the burn-in
3434
#' burn_in = estimate(specification, 5)
@@ -39,14 +39,6 @@
3939
#' # compute forecast error variance decomposition 4 years ahead
4040
#' fevd = compute_variance_decompositions(posterior, horizon = 4)
4141
#'
42-
#' # workflow with the pipe |>
43-
#' ############################################################
44-
#' ilo_dynamic_panel |>
45-
#' specify_bvarPANEL$new(p = 1) |>
46-
#' estimate(S = 5) |>
47-
#' estimate(S = 5) |>
48-
#' compute_variance_decompositions(horizon = 4) -> fevd
49-
#'
5042
#' @export
5143
compute_variance_decompositions.PosteriorBVARPANEL <- function(posterior, horizon) {
5244

@@ -119,8 +111,8 @@ compute_variance_decompositions.PosteriorBVARPANEL <- function(posterior, horizo
119111
#' @examples
120112
#' # specify the model and set seed
121113
#' specification = specify_bvarGroupPANEL$new( # specify the model
122-
#' ilo_dynamic_panel,
123-
#' group_allocation = country_grouping_region
114+
#' ilo_dynamic_panel[1:5],
115+
#' group_allocation = country_grouping_region[1:5]
124116
#' )
125117
#'
126118
#' # run the burn-in
@@ -132,14 +124,6 @@ compute_variance_decompositions.PosteriorBVARPANEL <- function(posterior, horizo
132124
#' # compute forecast error variance decomposition 4 years ahead
133125
#' fevd = compute_variance_decompositions(posterior, horizon = 4)
134126
#'
135-
#' # workflow with the pipe |>
136-
#' ############################################################
137-
#' ilo_dynamic_panel |>
138-
#' specify_bvarGroupPANEL$new(group_allocation = country_grouping_region) |>
139-
#' estimate(S = 5) |>
140-
#' estimate(S = 5) |>
141-
#' compute_variance_decompositions(horizon = 4) -> fevd
142-
#'
143127
#' @export
144128
compute_variance_decompositions.PosteriorBVARGROUPPANEL <- function(posterior, horizon) {
145129

@@ -210,7 +194,7 @@ compute_variance_decompositions.PosteriorBVARGROUPPANEL <- function(posterior, h
210194
#'
211195
#' @examples
212196
#' # specify the model and set seed
213-
#' specification = specify_bvars$new(ilo_dynamic_panel) # specify the model
197+
#' specification = specify_bvars$new(ilo_dynamic_panel[1:5]) # specify the model
214198
#'
215199
#' # run the burn-in
216200
#' burn_in = estimate(specification, 5)
@@ -221,14 +205,6 @@ compute_variance_decompositions.PosteriorBVARGROUPPANEL <- function(posterior, h
221205
#' # compute forecast error variance decomposition 4 years ahead
222206
#' fevd = compute_variance_decompositions(posterior, horizon = 4)
223207
#'
224-
#' # workflow with the pipe |>
225-
#' ############################################################
226-
#' ilo_dynamic_panel |>
227-
#' specify_bvars$new() |>
228-
#' estimate(S = 5) |>
229-
#' estimate(S = 5) |>
230-
#' compute_variance_decompositions(horizon = 4) -> fevd
231-
#'
232208
#' @export
233209
compute_variance_decompositions.PosteriorBVARs <- function(posterior, horizon) {
234210

R/estimate.BVARGROUPPANEL.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@
9393
#' @examples
9494
#' # specify the model
9595
#' specification = specify_bvarGroupPANEL$new(
96-
#' data = ilo_dynamic_panel,
97-
#' exogenous = ilo_exogenous_variables,
98-
#' group_allocation = country_grouping_region
96+
#' data = ilo_dynamic_panel[1:5],
97+
#' exogenous = ilo_exogenous_variables[1:5],
98+
#' group_allocation = country_grouping_region[1:5]
9999
#' )
100100
#' burn_in = estimate(specification, 10) # run the burn-in; use say S = 10000
101101
#' posterior = estimate(burn_in, 10) # estimate the model; use say S = 10000

R/estimate.BVARGROUPPRIORPANEL.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@
9393
#' @examples
9494
#' # specify the model
9595
#' specification = specify_bvarGroupPriorPANEL$new(
96-
#' data = ilo_dynamic_panel,
97-
#' exogenous = ilo_exogenous_variables,
98-
#' group_allocation = country_grouping_region
96+
#' data = ilo_dynamic_panel[1:5],
97+
#' exogenous = ilo_exogenous_variables[1:5],
98+
#' group_allocation = country_grouping_region[1:5]
9999
#' )
100100
#' burn_in = estimate(specification, 10) # run the burn-in; use say S = 10000
101101
#' posterior = estimate(burn_in, 10) # estimate the model; use say S = 10000

R/estimate.bvarPANEL.R

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,10 @@
8989
#'
9090
#' @examples
9191
#' # specify the model
92-
#' specification = specify_bvarPANEL$new(ilo_dynamic_panel, exogenous = ilo_exogenous_variables)
92+
#' specification = specify_bvarPANEL$new(
93+
#' ilo_dynamic_panel[1:5],
94+
#' exogenous = ilo_exogenous_variables[1:5]
95+
#' )
9396
#' burn_in = estimate(specification, 10) # run the burn-in; use say S = 10000
9497
#' posterior = estimate(burn_in, 10) # estimate the model; use say S = 10000
9598
#'

R/estimate.bvars.R

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,10 @@
8585
#'
8686
#' @examples
8787
#' # specify the model
88-
#' specification = specify_bvars$new(ilo_dynamic_panel, exogenous = ilo_exogenous_variables)
88+
#' specification = specify_bvars$new(
89+
#' ilo_dynamic_panel[1:5],
90+
#' exogenous = ilo_exogenous_variables[1:5]
91+
#' )
8992
#' burn_in = estimate(specification, 10) # run the burn-in; use say S = 10000
9093
#' posterior = estimate(burn_in, 10) # estimate the model; use say S = 10000
9194
#'

R/forecast.R

Lines changed: 16 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -104,20 +104,15 @@ generics::forecast
104104
#'
105105
#' @examples
106106
#' # specify the model
107-
#' specification = specify_bvarPANEL$new(ilo_dynamic_panel, exogenous = ilo_exogenous_variables)
107+
#' specification = specify_bvarPANEL$new(
108+
#' ilo_dynamic_panel[1:5],
109+
#' exogenous = ilo_exogenous_variables[1:5]
110+
#' )
108111
#' burn_in = estimate(specification, 5) # run the burn-in; use say S = 10000
109112
#' posterior = estimate(burn_in, 5) # estimate the model; use say S = 10000
110113
#'
111114
#' # forecast 5 years ahead
112-
#' predictive = forecast(posterior, 5, exogenous_forecast = ilo_exogenous_forecasts)
113-
#'
114-
#' # workflow with the pipe |>
115-
#' ############################################################
116-
#' ilo_dynamic_panel |>
117-
#' specify_bvarPANEL$new() |>
118-
#' estimate(S = 5) |>
119-
#' estimate(S = 5) |>
120-
#' forecast(horizon = 2) -> predictive
115+
#' predictive = forecast(posterior, 5, exogenous_forecast = ilo_exogenous_forecasts[1:5])
121116
#'
122117
#' @export
123118
forecast.PosteriorBVARPANEL = function(
@@ -251,9 +246,9 @@ forecast.PosteriorBVARPANEL = function(
251246
#' @examples
252247
#' # specify the model
253248
#' specification = specify_bvarGroupPANEL$new(
254-
#' ilo_dynamic_panel,
255-
#' exogenous = ilo_exogenous_variables,
256-
#' group_allocation = country_grouping_incomegroup
249+
#' ilo_dynamic_panel[1:5],
250+
#' exogenous = ilo_exogenous_variables[1:5],
251+
#' group_allocation = country_grouping_incomegroup[1:5]
257252
#' )
258253
#' burn_in = estimate(specification, 5) # run the burn-in; use say S = 10000
259254
#' posterior = estimate(burn_in, 5) # estimate the model; use say S = 10000
@@ -262,17 +257,9 @@ forecast.PosteriorBVARPANEL = function(
262257
#' predictive = forecast(
263258
#' posterior,
264259
#' horizon = 5,
265-
#' exogenous_forecast = ilo_exogenous_forecasts
260+
#' exogenous_forecast = ilo_exogenous_forecasts[1:5]
266261
#' )
267262
#'
268-
#' # workflow with the pipe |>
269-
#' ############################################################
270-
#' ilo_dynamic_panel |>
271-
#' specify_bvarGroupPANEL$new(group_allocation = country_grouping_incomegroup) |>
272-
#' estimate(S = 5) |>
273-
#' estimate(S = 5) |>
274-
#' forecast(horizon = 2) -> predictive
275-
#'
276263
#' @export
277264
forecast.PosteriorBVARGROUPPANEL = function(
278265
object,
@@ -497,20 +484,15 @@ forecast.PosteriorBVARGROUPPANEL = function(
497484
#'
498485
#' @examples
499486
#' # specify the model
500-
#' specification = specify_bvars$new(ilo_dynamic_panel, exogenous = ilo_exogenous_variables)
487+
#' specification = specify_bvars$new(
488+
#' ilo_dynamic_panel[1:5],
489+
#' exogenous = ilo_exogenous_variables[1:5]
490+
#' )
501491
#' burn_in = estimate(specification, 5) # run the burn-in; use say S = 10000
502492
#' posterior = estimate(burn_in, 5) # estimate the model; use say S = 10000
503493
#'
504494
#' # forecast 5 years ahead
505-
#' predictive = forecast(posterior, 5, exogenous_forecast = ilo_exogenous_forecasts)
506-
#'
507-
#' # workflow with the pipe |>
508-
#' ############################################################
509-
#' ilo_dynamic_panel |>
510-
#' specify_bvars$new() |>
511-
#' estimate(S = 5) |>
512-
#' estimate(S = 5) |>
513-
#' forecast(horizon = 2) -> predictive
495+
#' predictive = forecast(posterior, 5, exogenous_forecast = ilo_exogenous_forecasts[1:5])
514496
#'
515497
#' @export
516498
forecast.PosteriorBVARs = function(
@@ -645,23 +627,15 @@ forecast.PosteriorBVARs = function(
645627
#' @examples
646628
#' # specify the model
647629
#' specification = specify_bvarGroupPriorPANEL$new(
648-
#' ilo_dynamic_panel,
649-
#' group_allocation = country_grouping_incomegroup
630+
#' ilo_dynamic_panel[1:5],
631+
#' group_allocation = country_grouping_incomegroup[1:5]
650632
#' )
651633
#' burn_in = estimate(specification, 5) # run the burn-in; use say S = 10000
652634
#' posterior = estimate(burn_in, 5) # estimate the model; use say S = 10000
653635
#'
654636
#' # forecast 5 years ahead
655637
#' predictive = forecast(posterior, horizon = 5)
656638
#'
657-
#' # workflow with the pipe |>
658-
#' ############################################################
659-
#' ilo_dynamic_panel |>
660-
#' specify_bvarGroupPriorPANEL$new(group_allocation = country_grouping_incomegroup) |>
661-
#' estimate(S = 5) |>
662-
#' estimate(S = 5) |>
663-
#' forecast(horizon = 2) -> predictive
664-
#'
665639
#' @export
666640
forecast.PosteriorBVARGROUPPRIORPANEL = function(
667641
object,

R/forecast_performance.R

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#' @author Tomasz Woźniak \email{wozniak.tom@pm.me}
2626
#'
2727
#' @examples
28-
#' spec = specify_bvarPANEL$new(ilo_dynamic_panel) # specify the model
28+
#' spec = specify_bvarPANEL$new(ilo_dynamic_panel[1:5]) # specify the model
2929
#' poos = specify_poosf_exercise$new( # specify the forecasting exercise
3030
#' spec,
3131
#' S = 5, # use at least S = 5000
@@ -170,8 +170,8 @@ forecast_poos_recursively.BVARPANEL <- function(
170170
#'
171171
#' @examples
172172
#' spec = specify_bvarGroupPANEL$new( # specify the model
173-
#' ilo_dynamic_panel,
174-
#' group_allocation = country_grouping_region
173+
#' ilo_dynamic_panel[1:5],
174+
#' group_allocation = country_grouping_region[1:5]
175175
#' )
176176
#' poos = specify_poosf_exercise$new( # specify the forecasting exercise
177177
#' spec,
@@ -298,7 +298,7 @@ forecast_poos_recursively.BVARGROUPPANEL <- function(
298298
#' @author Tomasz Woźniak \email{wozniak.tom@pm.me}
299299
#'
300300
#' @examples
301-
#' spec = specify_bvars$new(ilo_dynamic_panel) # specify the model
301+
#' spec = specify_bvars$new(ilo_dynamic_panel[1:5]) # specify the model
302302
#' poos = specify_poosf_exercise$new( # specify the forecasting exercise
303303
#' spec,
304304
#' S = 5, # use at least S = 5000
@@ -425,8 +425,8 @@ forecast_poos_recursively.BVARs <- function(
425425
#'
426426
#' @examples
427427
#' spec = specify_bvarGroupPriorPANEL$new( # specify the model
428-
#' ilo_dynamic_panel,
429-
#' group_allocation = country_grouping_region
428+
#' ilo_dynamic_panel[1:5],
429+
#' group_allocation = country_grouping_region[1:5]
430430
#' )
431431
#' poos = specify_poosf_exercise$new( # specify the forecasting exercise
432432
#' spec,

R/plot.R

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,13 @@
2828
#' @author Tomasz Woźniak \email{wozniak.tom@pm.me}
2929
#'
3030
#' @examples
31-
#' specification = specify_bvarPANEL$new(ilo_dynamic_panel) # specify the model
31+
#' specification = specify_bvarPANEL$new(ilo_dynamic_panel[1:5]) # specify the model
3232
#' burn_in = estimate(specification, 10) # run the burn-in
3333
#' posterior = estimate(burn_in, 10) # estimate the model
3434
#'
3535
#' # forecast 5 years ahead
3636
#' predictive = forecast(posterior, 6)
37-
#' plot(predictive, which_c = "POL") # plot forecasts
38-
#'
39-
#' # workflow with the pipe |>
40-
#' ############################################################
41-
#' ilo_dynamic_panel |>
42-
#' specify_bvarPANEL$new() |>
43-
#' estimate(S = 10) |>
44-
#' estimate(S = 10) |>
45-
#' forecast(horizon = 5) |>
46-
#' plot(which_c = 135)
37+
#' plot(predictive, which_c = "ARG") # plot forecasts
4738
#'
4839
#' @export
4940
plot.ForecastsPANEL = function(
@@ -121,7 +112,7 @@ plot.ForecastsPANEL = function(
121112
#' @author Tomasz Woźniak \email{wozniak.tom@pm.me}
122113
#'
123114
#' set.seed(123)
124-
#' specification = specify_bvarPANEL$new(ilo_dynamic_panel)
115+
#' specification = specify_bvarPANEL$new(ilo_dynamic_panel[1:5])
125116
#'
126117
#' # run the burn-in
127118
#' burn_in = estimate(specification, 10)
@@ -131,16 +122,7 @@ plot.ForecastsPANEL = function(
131122
#'
132123
#' # compute forecast error variance decomposition 4 years ahead
133124
#' fevd = compute_variance_decompositions(posterior, horizon = 4)
134-
#' plot(fevd, which_c = "POL")
135-
#'
136-
#' # workflow with the pipe |>
137-
#' ############################################################
138-
#' ilo_dynamic_panel |>
139-
#' specify_bvarPANEL$new() |>
140-
#' estimate(S = 10) |>
141-
#' estimate(S = 20) |>
142-
#' compute_variance_decompositions(horizon = 4) |>
143-
#' plot(which_c = "POL")
125+
#' plot(fevd, which_c = "ARG")
144126
#'
145127
#' @export
146128
plot.PosteriorFEVDPANEL = function(

0 commit comments

Comments
 (0)