Description Usage Arguments Details Value Note Author(s) References See Also Examples
View source: R/SZ.prior.evaluation.R
Estimates posterior and in-sample fit measures for a reduced form vector autoregression model with different specifications of the Sims-Zha hyperparameters values.
1 2 3 4 | SZ.prior.evaluation(Y, p,
lambda0, lambda1, lambda3, lambda4, lambda5,
mu5, mu6, z = NULL, nu = ncol(Y) + 1, qm,
prior = 0, nsteps, y.future)
|
Y |
T x m matrix of endogenous variables for the VAR |
p |
Lag length |
lambda0 |
List of values, e,g, |
lambda1 |
List of values, e,g, |
lambda3 |
List of values, e,g, |
lambda4 |
List of values, e,g, |
lambda5 |
Single value for the standard deviation or tightness around the exogneous variable coefficients [>0] |
mu5 |
Single value for sum of coefficients prior weight [>=0] |
mu6 |
Single value for dummy Initial observations or cointegration prior [>=0] |
z |
Exogenous variables |
nu |
Prior degrees of freedom = m+1 |
qm |
Frequency of the data for lag decay equivalence. Default is 4, and a value of 12 will match the lag decay of monthly to quarterly data. Other values have the same effect as "4" |
prior |
One of three values: 0 = Normal-Wishart prior, 1 = Normal-flat prior, 2 = flat-flat prior (i.e., akin to MLE) |
nsteps |
Number of periods in the forecast horizon |
y.future |
Future values of the series, nsteps x m for computing the root mean squared error and mean absolute error for the fit |
This function fits a series of BVAR models for the combinations of
lambda0
, lambda1
, lambda3
, and lambda4
provided. For each possible value of these parameters specified, a
Sims-Zha prior BVAR model is fit, posterior fit measures are computed, and
forecasts are generated over nsteps
. These nstep
forecasts are then compared to a new set of data in y.future
and root mean sqaured error and mean absolute error measures are
computed.
A matrix of the results with columns corresponding to the values of "lambda0", "lambda1", "lambda3", "lambda4", "lambda5", "mu5", "mu6", "RMSE", "MAE", "MargLLF","MargPosterior".
The matrix of the results can be usefully plotted using the
lattice
package. See the example below.
Patrick T. Brandt
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.
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 | Y <- EuStockMarkets
results <- SZ.prior.evaluation(window(Y, start=c(1998, 1),
end=c(1998,149)),
p=3,
lambda0=c(1,0.9),
lambda1=c(0.1,0.2),
lambda3=c(0,1),
lambda4=c(0.1,0.25),
lambda5=0,
mu5=4,
mu6=4, z=NULL,
nu=ncol(Y)+1, qm=4,
prior=0,
nstep=20,
y.future=window(Y, start=c(1998,150)))
# Now plot the RMSE and marginal posterior of the data for each of the
# 6 period forecasts as a function of the prior parameters. This can
# easily be done using a lattice graphic.
library(lattice)
attach(as.data.frame(results))
dev.new()
xyplot(RMSE ~ lambda0 | lambda1 + lambda3)
dev.new()
xyplot(logMDD ~ lambda0 | lambda1 + lambda3)
dev.new()
xyplot(LLF ~ lambda0 | lambda1 + lambda3)
|
##
## MSBVAR Package v.0.9-2
## Build date: Thu Nov 1 08:57:59 2018
## Copyright (C) 2005-2018, Patrick T. Brandt
## Written by Patrick T. Brandt
##
## Support provided by the U.S. National Science Foundation
## (Grants SES-0351179, SES-0351205, SES-0540816, and SES-0921051)
##
Finished model 1 of 16
dev.new(): using pdf(file="Rplots1.pdf")
dev.new(): using pdf(file="Rplots2.pdf")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.