Estimate a FAVAR model by Bernanke et al. (2005).
FAVAR(
Y,
X,
fctmethod = "BBE",
slowcode,
K = 2,
plag = 2,
factorprior = list(b0 = 0, vb0 = NULL, c0 = 0.01, d0 = 0.01),
varprior = list(b0 = 0, vb0 = 0, nu0 = 0, s0 = 0, mn = list(kappa0 = NULL, kappa1 =
NULL)),
nburn = 5000,
nrep = 15000,
standardize = TRUE,
ncores = 1
)
a matrix. Observable economic variables assumed to drive the dynamics of the economy.
a matrix. A large macro data set. The meanings of X
and Y
is same as ones of Bernanke et al. (2005).
'BBE'
or 'BGM'
. 'BBE'
(default) means the factors extracted method by Bernanke et al. (2005),
and 'BGM'
means the factors extracted method by Boivin et al. (2009).
a logical vector that identifies which columns of X are slow
moving. Only when fctmethod
is set as 'BBE'
, slowcode
is valid.
the number of factors extracted from X
.
the lag order in the VAR equation.
A list whose elements is named sets the prior for the factor equation.
b0
is the prior of mean of regression coefficients \(\beta\),and vb0
is the prior of the variance
of \(\beta\), and c0/2
and d0/2
are prior parameters of the variance of the error
\(\sigma^{-2}\), and they are
the shape and scale parameters of Gamma distribution, respectively.
A list whose elements is named sets the prior of VAR equations.
b0
is the prior of mean of VAR coefficients \(\beta\), and vb0
is the prior
of the variance of \(\beta\), it's a scalar that means priors of variance is same, or a
vector whose length equals the length of \(\beta\). nu0
is the degree of freedom
of Wishart distribution for \(\Sigma^{-1}\), i.e., a shape parameter, and s0
is a inverse
scale parameter for the Wishart distribution, and it's a matrix with
ncol(s0)=nrow(s0)=
the number of endogenous variables in VAR. If it's a scalar, it means
the entry of the matrix is same. mn
sets the Minnesota prior. If
varprior$mn$kappa0
is not NULL
, b0,vb0
is neglected.
mn
's element kappa0
controls the
tightness of the prior variance for self-variables lag coefficients, the prior variance
is \(\kappa_0/lag^2\), another element kappa1
controls the cross-variables lag
coefficients spread, the prior variance is
\(\frac{\kappa_0\kappa_1}{lag^2}\frac{\sigma_m^2}{\sigma_n^2}, m\ne n\). See details.
the number of the first random draws discarded in MCMC.
the number of the saved draws in MCMC.
Whether standardize? We suggest it does, because in the function VAR equation and factor equation both don't include intercept.
the number of CPU cores in parallel computations.
An object of class "favar" containing the following components:
A list. The estimation results of VAR including estimated coefficients
A
, their variance-covariance matrix sigma
, and other statistical summary for A
.
A array with 3 dimension. and Lamb[i,,]
is factor loading matrix
for factor equations in the \(i\)th sample of MCMC.
Extracted factors from X
Model information containing nburn,nrep,X,Y
and p
, the number of endogenous variables
in the VAR.
Here we simply state the prior distribution setting of VAR. VAR could be written by (Koop and Korobilis, 2010), $$y_t= Z_t\beta + \varepsilon_t, \varepsilon_t\sim N(0,\Sigma)$$ You can write down it according to data matrix, $$Y= Z\beta + \varepsilon, \varepsilon\sim N(0,I\otimes \Sigma)$$ where \(Y = (y_1,y_2,\cdots, y_T)',Z=(Z_,Z_2,\cdots,Z_T)',\varepsilon=(\varepsilon_1,\varepsilon_2,\cdots,\varepsilon_T)\). We assume that prior distribution of \(\beta\) and \(\Sigma^{-1}\) is, $$\beta\sim N(b0,V_{b0}), \Sigma^{-1}\sim W(S_0^{-1},\nu_0)$$ Or you can set the Minnesota prior for variance of \(\beta\), for example, for the \(m\)th equation in \(y_t= Z_t\beta + \varepsilon_t\),
\(\frac{\kappa_0}{l^2},l\) is lag order, for won lags of endogenous variables
\(\frac{\kappa_0\kappa_1}{l^2}\frac{\sigma_m^2}{\sigma_n^2}, m\ne n\),for lags of other endogenous variables in the mth equation, where \(\sigma_m\) is the standard error for residuals of the mth equation.
Based on the priors, you could get corresponding post distribution for the parameters by Markov Chain Monte Carlo (MCMC) algorithm. More details, see Koop and Korobilis (2010).
Bernanke, B.S., J. Boivin and P. Eliasz, Measuring the Effects of Monetary Policy: A Factor-Augmented Vector Autoregressive (FAVAR) Approach. Quarterly Journal of Economics, 2005. 120(1): p. 387-422.
Boivin, J., M.P. Giannoni and I. Mihov, Sticky Prices and Monetary Policy: Evidence from Disaggregated US Data. American Economic Review, 2009. 99(1): p. 350-384.
Koop, G. and D. Korobilis, Bayesian Multivariate Time Series Methods for Empirical Macroeconomics. 2010: Now Publishers.
summary.favar
, coef.favar
and irf
. All of them are
S3 methods of the "favar" object, and
summary.favar
that prints the estimation results of a FAVAR model, and
coef.favar
that extracts the coefficients in a FAVAR model, and
irf
that computes the impulse response in a FAVAR model.
# NOT RUN {
# data('regdata')
# fit <- FAVAR(Y = regdata[,c("Inflation","Unemployment","Fed_funds")],
# X = regdata[,1:115], slowcode = slowcode,fctmethod = 'BBE',
# factorprior = list(b0 = 0, vb0 = NULL, c0 = 0.01, d0 = 0.01),
# varprior = list(b0 = 0,vb0 = 10, nu0 = 0, s0 = 0),
# nrep = 15000, nburn = 5000, K = 2, plag = 2)
##---- print FAVAR estimation results------
# summary(fit,xvar = c(3,5))
##---- or extract coefficients------
# coef(fit)
##---- plot impulse response figure------
# library(patchwork)
# dt_irf <- irf(fit,resvar = c(2,9,10))
# }
Run the code above in your browser using DataLab