uc.forecast: Forecast density estimation unconditional forecasts for...

Description Usage Arguments Details Value Author(s) References See Also Examples

Description

Implements unconditional forecast density estimator for VAR/BVAR/BSVAR models described in Waggoner and Zha (1999). The unconditional forecasts place no restriction on the paths of the forecasts (cf. hc.forecast). The forecast densities are estimated as the posterior sample for the VAR/BVAR/BSVAR model using Markov Chain Monte Carlo with data augmentation to account for the uncertainty of the forecasts and the parameters. This function DOES account for parameter uncertainty in the MCMC algorithm.

Usage

1
uc.forecast(varobj, nsteps, burnin, gibbs, exog = NULL)

Arguments

varobj

VAR or BVAR object produced for a VAR or BVAR using szbvar or reduced.form.var

nsteps

Number of periods in the forecast horizon

burnin

Burnin cycles for the MCMC algorithm

gibbs

Number of cycles of the Gibbs sampler after the burnin that are returned in the output

exog

num.exog x nsteps matrix of the exogenous variable values for the forecast horizon. If left at the NULL default, they are set to zero.

Details

Produces a posterior sample of unconstrained VAR/BVAR/BSVAR forecasts via MCMC. This function accounts for the uncertainty of the VAR/BVAR/BSVAR parameters by sampling from them in the computation of the VAR/BVAR/BSVAR forecasts and then regenerating the forecasts. Data augmentation is used to account for the impact of the forecast uncertainty on the parameters.

Value

A list with three components:

yforc

Forecast sample

orig.y

Original endogenous variables time series

hyperp

values of the hyperparameters used in the BVAR estimation / MCMC

Author(s)

Patrick T. Brandt

References

Brandt, Patrick T. and John R. Freeman. 2006. "Advances in Bayesian Time Series Modeling and the Study of Politics: Theory Testing, Forecasting, and Policy Analysis" Political Analysis 14(1):1-36.

Waggoner, Daniel F. and Tao Zha. 1999. "Conditional Forecasts in Dynamic Multivariate Models" Review of Economics and Statistics, 81(4):639-651.

See Also

hc.forecast

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
## Not run: 
## Uses the example from Brandt and Freeman 2006.  Will not run unless
## you have their data from the Politcal
## Analysis website!
library(MSBVAR)   # Brandt's package for Bayesian VAR models

# Read the data and set up as a time series
data <- read.dta("levant.weekly.79-03.dta") 
attach(data)

# Set up KEDS data
KEDS.data <- ts(cbind(a2i,a2p,i2a,p2a,i2p,p2i),
                start=c(1979,15),
                freq=52,
                names=c("A2I","A2P","I2A","P2A","I2P","P2I"))

# Select the sample we want to use.
KEDS <- window(KEDS.data, end=c(1988,50))


################################################################################
# Estimate the BVAR models 
################################################################################

# Fit a flat prior model
KEDS.BVAR.flat <- szbvar(KEDS, p=6, z=NULL, lambda0=1,
                         lambda1=1, lambda3=1, lambda4=1, lambda5=0,
                         mu5=0, mu6=0, nu=0, qm=4, prior=2,
                         posterior.fit=F)

# Reference prior model -- Normal-IW prior pdf
KEDS.BVAR.informed <- szbvar(KEDS, p=6, z=NULL, lambda0=0.6,
                             lambda1=0.1, lambda3=2, lambda4=0.5, lambda5=0,
                             mu5=0, mu6=0, nu=ncol(KEDS)+1, qm=4, prior=0,
                             posterior.fit=F)

# Set up conditional forecast matrix conditions
nsteps <- 12
a2i.condition <- rep(mean(KEDS[,1]) + sqrt(var(KEDS[,1])) , nsteps)

yhat<-matrix(c(a2i.condition,rep(0, nsteps*5)), ncol=6)

# Set the random number seed so we can replicate the results.
set.seed(11023)

# Conditional forecasts
conditional.forcs.ref <- hc.forecast(KEDS.BVAR.informed, yhat, nsteps,
                            burnin=3000, gibbs=5000, exog=NULL)

conditional.forcs.flat <- hc.forecast(KEDS.BVAR.flat, yhat, nsteps,
                             burnin=3000, gibbs=5000, exog=NULL)

# Unconditional forecasts
unconditional.forcs.ref <-uc.forecast(KEDS.BVAR.informed, nsteps,
                                          burnin=3000, gibbs=5000)

unconditional.forcs.flat <- uc.forecast(KEDS.BVAR.flat, nsteps,
                                            burnin=3000, gibbs=5000)

# Set-up and plot the unconditional and conditional forecasts.  This
# code pulls for the forecasts for I2P and P2I and puts them into the
# appropriate array for the figures we want to generate.
uc.flat <- NULL
hc.flat <- NULL
uc.ref <- NULL
hc.ref <- NULL

uc.flat$forecast <- unconditional.forcs.flat$forecast[,,5:6]
hc.flat$forecast <- conditional.forcs.flat$forecast[,,5:6]
uc.ref$forecast <- unconditional.forcs.ref$forecast[,,5:6]
hc.ref$forecast <- conditional.forcs.ref$forecast[,,5:6]

par(mfrow=c(2,2), omi=c(0.25,0.5,0.25,0.25)) 
plot(uc.flat,hc.flat, probs=c(0.16, 0.84), varnames=c("I2P", "P2I"),
     compare.level=KEDS[nrow(KEDS),5:6], lwd=2)
plot(hc.ref,hc.flat, probs=c(0.16, 0.84), varnames=c("I2P", "P2I"),
     compare.level=KEDS[nrow(KEDS),5:6], lwd=2)


## End(Not run)

MSBVAR documentation built on May 30, 2017, 1:23 a.m.

Related to uc.forecast in MSBVAR...