Skip to contents

Provides posterior summary of the forecasts including their mean, standard deviations, as well as 5 and 95 percentiles.

Usage

# S3 method for class 'ForecastsPANEL'
summary(object, which_c, ...)

Arguments

object

an object of class ForecastsPANEL obtained using the forecast() function containing draws the predictive density.

which_c

a positive integer or a character string specifying the country for which the forecast should be plotted.

...

additional arguments affecting the summary produced.

Value

A list reporting the posterior mean, standard deviations, as well as 5 and 95 percentiles of the forecasts for each of the variables and forecast horizons.

Author

Tomasz Woźniak wozniak.tom@pm.me

Examples

data(ilo_dynamic_panel)                                   # load the data
data(ilo_exogenous_variables)                           # load the exogenous variables
data(ilo_exogenous_forecasts)                           # load the exogenous forecast
set.seed(123)

# specify the model
specification = specify_bvarPANEL$new(ilo_dynamic_panel, exogenous = ilo_exogenous_variables)
burn_in       = estimate(specification, 10)             # run the burn-in
#> **************************************************|
#> bvarPANELs: Forecasting with Bayesian Hierarchical|
#>             Panel Vector Autoregressions          |
#> **************************************************|
#>  Progress of the MCMC simulation for 10 draws
#>     Every draw is saved via MCMC thinning
#>  Press Esc to interrupt the computations
#> **************************************************|
posterior     = estimate(burn_in, 10)                   # estimate the model
#> **************************************************|
#> bvarPANELs: Forecasting with Bayesian Hierarchical|
#>             Panel Vector Autoregressions          |
#> **************************************************|
#>  Progress of the MCMC simulation for 10 draws
#>     Every draw is saved via MCMC thinning
#>  Press Esc to interrupt the computations
#> **************************************************|

# forecast 6 years ahead
predictive    = forecast(posterior, 6, exogenous_forecast = ilo_exogenous_forecasts)
#> **************************************************|
#> bvarPANELs: Forecasting with Bayesian Hierarchical|
#>             Panel Vector Autoregressions          |
#> **************************************************|
#>  Progress of sampling 10 draws from
#>     the predictive density for 189 countries
#>     Press Esc to interrupt the computations
#> **************************************************|
summary(predictive, which_c = "POL")
#>  **************************************************|
#>  bsvars: Bayesian Structural Vector Autoregressions|
#>  **************************************************|
#>    Posterior summary of forecasts                  |
#>  **************************************************|
#> $variable1
#>       mean         sd 5% quantile 95% quantile
#> 1 27.21313 0.02408531    27.17925     27.24678
#> 2 27.26329 0.02871019    27.22304     27.30289
#> 3 27.30318 0.03550437    27.25307     27.34851
#> 4 27.32995 0.04919806    27.24869     27.37955
#> 5 27.36594 0.05946100    27.26911     27.43260
#> 6 27.38929 0.07180236    27.26397     27.45593
#> 
#> $variable2
#>          mean       sd 5% quantile 95% quantile
#> 1  2.40783027 2.782698   -0.455143     6.627415
#> 2  1.24354630 4.155141   -4.184068     6.868560
#> 3  0.32535686 4.876128   -5.561055     7.804874
#> 4 -0.02924289 5.291247   -5.597902     9.022041
#> 5 -0.69981390 6.526451   -7.952230    10.394746
#> 6 -0.97105073 7.039195   -8.337951    11.059085
#> 
#> $variable3
#>       mean       sd 5% quantile 95% quantile
#> 1 57.16358 1.355405    55.11561     58.91817
#> 2 57.91772 2.419252    54.78791     61.28129
#> 3 58.24847 2.906429    54.08480     61.98811
#> 4 58.65542 3.449756    53.53578     63.15353
#> 5 59.20002 4.235689    52.57040     64.33862
#> 6 59.35998 4.387566    52.35463     64.62865
#> 
#> $variable4
#>       mean        sd 5% quantile 95% quantile
#> 1 58.59887 0.5862386    57.89950     59.48834
#> 2 58.76026 0.7260036    57.75559     59.62949
#> 3 58.58566 0.5770285    57.94311     59.47936
#> 4 58.83854 1.2021483    57.17111     60.42909
#> 5 59.04450 1.0844067    57.37556     60.27955
#> 6 59.04841 1.1259090    57.42927     60.35871
#> 

# workflow with the pipe |>
############################################################
set.seed(123)
ilo_dynamic_panel |>
  specify_bvarPANEL$new() |>
  estimate(S = 10) |> 
  estimate(S = 20) |> 
  forecast(horizon = 2) |> 
  summary(which_c = "POL")
#> **************************************************|
#> bvarPANELs: Forecasting with Bayesian Hierarchical|
#>             Panel Vector Autoregressions          |
#> **************************************************|
#>  Progress of the MCMC simulation for 10 draws
#>     Every draw is saved via MCMC thinning
#>  Press Esc to interrupt the computations
#> **************************************************|
#> **************************************************|
#> bvarPANELs: Forecasting with Bayesian Hierarchical|
#>             Panel Vector Autoregressions          |
#> **************************************************|
#>  Progress of the MCMC simulation for 20 draws
#>     Every draw is saved via MCMC thinning
#>  Press Esc to interrupt the computations
#> **************************************************|
#> **************************************************|
#> bvarPANELs: Forecasting with Bayesian Hierarchical|
#>             Panel Vector Autoregressions          |
#> **************************************************|
#>  Progress of sampling 20 draws from
#>     the predictive density for 189 countries
#>     Press Esc to interrupt the computations
#> **************************************************|
#>  **************************************************|
#>  bsvars: Bayesian Structural Vector Autoregressions|
#>  **************************************************|
#>    Posterior summary of forecasts                  |
#>  **************************************************|
#> $variable1
#>       mean         sd 5% quantile 95% quantile
#> 1 27.20833 0.02292586    27.17483     27.24610
#> 2 27.24256 0.04282843    27.19347     27.31346
#> 
#> $variable2
#>       mean       sd 5% quantile 95% quantile
#> 1 2.997496 2.163707  -0.2116465     6.849011
#> 2 2.916851 2.763951  -1.2962584     6.878897
#> 
#> $variable3
#>       mean       sd 5% quantile 95% quantile
#> 1 57.07870 1.023951    55.62295     58.51290
#> 2 57.32834 1.476331    55.56382     59.33173
#> 
#> $variable4
#>       mean        sd 5% quantile 95% quantile
#> 1 58.90945 0.4657256    58.26021     59.50532
#> 2 59.14215 0.6199194    58.12680     59.89916
#> 

# conditional forecasting 6 years ahead conditioning on 
#  provided future values for the Gross Domestic Product 
#  growth rate
############################################################
data(ilo_conditional_forecasts)                        # load the conditional forecasts of dgdp
specification = specify_bvarPANEL$new(ilo_dynamic_panel)    # specify the model
burn_in       = estimate(specification, 10)               # run the burn-in
#> **************************************************|
#> bvarPANELs: Forecasting with Bayesian Hierarchical|
#>             Panel Vector Autoregressions          |
#> **************************************************|
#>  Progress of the MCMC simulation for 10 draws
#>     Every draw is saved via MCMC thinning
#>  Press Esc to interrupt the computations
#> **************************************************|
posterior     = estimate(burn_in, 10)                     # estimate the model
#> **************************************************|
#> bvarPANELs: Forecasting with Bayesian Hierarchical|
#>             Panel Vector Autoregressions          |
#> **************************************************|
#>  Progress of the MCMC simulation for 10 draws
#>     Every draw is saved via MCMC thinning
#>  Press Esc to interrupt the computations
#> **************************************************|
# forecast 6 years ahead
predictive    = forecast(posterior, 6, conditional_forecast = ilo_conditional_forecasts)
#> **************************************************|
#> bvarPANELs: Forecasting with Bayesian Hierarchical|
#>             Panel Vector Autoregressions          |
#> **************************************************|
#>  Progress of sampling 10 draws from
#>     the predictive density for 189 countries
#>     Press Esc to interrupt the computations
#> **************************************************|
summary(predictive, which_c = "POL")
#>  **************************************************|
#>  bsvars: Bayesian Structural Vector Autoregressions|
#>  **************************************************|
#>    Posterior summary of forecasts                  |
#>  **************************************************|
#> $variable1
#>       mean sd 5% quantile 95% quantile
#> 1 27.20126  0    27.20126     27.20126
#> 2 27.23543  0    27.23543     27.23543
#> 3 27.26786  0    27.26786     27.26786
#> 4 27.29738  0    27.29738     27.29738
#> 5 27.32664  0    27.32664     27.32664
#> 6 27.35630  0    27.35630     27.35630
#> 
#> $variable2
#>       mean       sd 5% quantile 95% quantile
#> 1 2.973705 1.227861   1.1769236     4.507933
#> 2 2.635335 2.036479   0.6156404     5.906735
#> 3 1.999701 2.867749  -1.6137005     6.304514
#> 4 2.163981 3.533968  -3.0439007     6.899090
#> 5 2.129214 4.322081  -3.2777189     8.573412
#> 6 1.545401 4.708804  -4.6379531     8.521792
#> 
#> $variable3
#>       mean        sd 5% quantile 95% quantile
#> 1 56.81392 0.8890254    55.73613     58.14816
#> 2 57.13281 1.0676520    55.86340     58.84989
#> 3 57.72602 1.3030436    55.97099     59.32381
#> 4 57.92416 1.5463865    55.63428     59.65459
#> 5 58.13497 1.8713576    55.16764     60.16334
#> 6 58.62843 2.2359815    55.00153     61.28963
#> 
#> $variable4
#>       mean        sd 5% quantile 95% quantile
#> 1 58.59000 0.6263350    57.68068     59.22851
#> 2 58.75516 0.8354557    57.47867     59.67254
#> 3 59.04370 1.0282282    57.74988     60.50456
#> 4 59.36669 1.0053499    58.06295     60.77492
#> 5 59.58982 1.3874843    57.71137     61.37416
#> 6 59.74854 1.2670284    57.72361     61.17385
#> 

# workflow with the pipe |>
############################################################
set.seed(123)
ilo_dynamic_panel |>
  specify_bvarPANEL$new() |>
  estimate(S = 10) |> 
  estimate(S = 20) |> 
  forecast(
    horizon = 6, 
    conditional_forecast = ilo_conditional_forecasts
  ) |> 
  summary(which_c = "POL")
#> **************************************************|
#> bvarPANELs: Forecasting with Bayesian Hierarchical|
#>             Panel Vector Autoregressions          |
#> **************************************************|
#>  Progress of the MCMC simulation for 10 draws
#>     Every draw is saved via MCMC thinning
#>  Press Esc to interrupt the computations
#> **************************************************|
#> **************************************************|
#> bvarPANELs: Forecasting with Bayesian Hierarchical|
#>             Panel Vector Autoregressions          |
#> **************************************************|
#>  Progress of the MCMC simulation for 20 draws
#>     Every draw is saved via MCMC thinning
#>  Press Esc to interrupt the computations
#> **************************************************|
#> **************************************************|
#> bvarPANELs: Forecasting with Bayesian Hierarchical|
#>             Panel Vector Autoregressions          |
#> **************************************************|
#>  Progress of sampling 20 draws from
#>     the predictive density for 189 countries
#>     Press Esc to interrupt the computations
#> **************************************************|
#>  **************************************************|
#>  bsvars: Bayesian Structural Vector Autoregressions|
#>  **************************************************|
#>    Posterior summary of forecasts                  |
#>  **************************************************|
#> $variable1
#>       mean sd 5% quantile 95% quantile
#> 1 27.20126  0    27.20126     27.20126
#> 2 27.23543  0    27.23543     27.23543
#> 3 27.26786  0    27.26786     27.26786
#> 4 27.29738  0    27.29738     27.29738
#> 5 27.32664  0    27.32664     27.32664
#> 6 27.35630  0    27.35630     27.35630
#> 
#> $variable2
#>       mean       sd 5% quantile 95% quantile
#> 1 3.007303 1.188344   1.5491294     4.551334
#> 2 2.941612 1.411844   0.5280873     4.906943
#> 3 3.262896 1.177707   1.3276339     4.721227
#> 4 3.607827 1.851831   0.6632864     5.906053
#> 5 3.782638 2.074991   0.8245657     7.411908
#> 6 4.650123 2.701818   1.0467395     8.425201
#> 
#> $variable3
#>       mean        sd 5% quantile 95% quantile
#> 1 56.87364 0.7397435    55.72259     58.08835
#> 2 57.11127 0.8710991    55.93056     58.67596
#> 3 57.25469 0.6118194    56.38072     58.11050
#> 4 57.26761 0.7616915    55.96153     58.59708
#> 5 57.23641 0.9094898    55.89276     58.62558
#> 6 56.84611 1.7019920    54.56678     59.33118
#> 
#> $variable4
#>       mean        sd 5% quantile 95% quantile
#> 1 58.68079 0.6008518    57.77759     59.60783
#> 2 58.94663 0.9405458    57.85657     60.67330
#> 3 59.31390 0.7257944    58.33238     60.67594
#> 4 59.53580 0.9285039    58.16205     60.93998
#> 5 59.60022 0.8712144    58.28623     61.00937
#> 6 59.71798 1.0182805    58.28243     61.45111
#>