bvec( y, alpha =NULL, beta =NULL, beta_x =NULL, beta_d =NULL, r =NULL, Pi =NULL, Pi_x =NULL, Pi_d =NULL, w =NULL, w_x =NULL, w_d =NULL, Gamma =NULL, Upsilon =NULL, C =NULL, x =NULL, x_x =NULL, x_d =NULL, A0 =NULL, Sigma =NULL, data =NULL, exogen =NULL)## S3 method for class 'bvec'plot(x, ci =0.95, type ="hist",...)
Arguments
y: a time-series object of differenced endogenous variables, usually, a result of a call to gen_vec.
alpha: a Kr×S matrix of MCMC coefficient draws of the loading matrix α.
beta: a Kr×S matrix of MCMC coefficient draws of cointegration matrix β
corresponding to the endogenous variables of the model.
beta_x: a Mr×S matrix of MCMC coefficient draws of cointegration matrix β
corresponding to unmodelled, non-deterministic variables.
beta_d: a NRr×S matrix of MCMC coefficient draws of cointegration matrix β
corresponding to restricted deterministic terms.
r: an integer of the rank of the cointegration matrix.
Pi: a K2×S matrix of MCMC coefficient draws of endogenous varaibles in the cointegration matrix.
Pi_x: a KM×S matrix of MCMC coefficient draws of unmodelled, non-deterministic variables in the cointegration matrix.
Pi_d: a KNR×S matrix of MCMC coefficient draws of restricted deterministic terms.
w: a time-series object of lagged endogenous variables in levels, which enter the cointegration term, usually, a result of a call to gen_vec.
w_x: a time-series object of lagged unmodelled, non-deterministic variables in levels, which enter the cointegration term, usually, a result of a call to gen_vec.
w_d: a time-series object of deterministic terms, which enter the cointegration term, usually, a result of a call to gen_vec.
Gamma: a (p−1)K2×S matrix of MCMC coefficient draws of differenced lagged endogenous variables or a named list, where element coeffs contains a (p−1)K2×S matrix of MCMC coefficient draws of lagged differenced endogenous variables and element lambda contains the corresponding draws of inclusion parameters in case variable selection algorithms were employed.
Upsilon: an sMK×S matrix of MCMC coefficient draws of differenced unmodelled, non-deterministic variables or a named list, where element coeffs contains a sMK×S matrix of MCMC coefficient draws of unmodelled, non-deterministic variables and element lambda contains the corresponding draws of inclusion parameters in case variable selection algorithms were employed.
C: an KNUR×S matrix of MCMC coefficient draws of unrestricted deterministic terms or a named list, where element coeffs contains a KNUR×S matrix of MCMC coefficient draws of deterministic terms and element lambda contains the corresponding draws of inclusion parameters in case variable selection algorithms were employed.
x: an object of class "bvec", usually, a result of a call to draw_posterior.
x_x: a time-series object of Ms differenced unmodelled regressors.
x_d: a time-series object of NUR deterministic terms that do not enter the cointegration term.
A0: either a K2×S matrix of MCMC coefficient draws of structural parameters or a named list, where element coeffs contains a K2×S matrix of MCMC coefficient draws of structural parameters and element lambda contains the corresponding draws of inclusion parameters in case variable selection algorithms were employed.
Sigma: a K2×S matrix of MCMC draws for the error variance-covariance matrix or a named list, where element coeffs contains a K2×S matrix of MCMC draws for the error variance-covariance matrix and element lambda contains the corresponding draws of inclusion parameters in case variable selection algorithms were employed to the covariances.
data: the original time-series object of endogenous variables.
exogen: the original time-series object of unmodelled variables.
ci: interval used to calculate credible bands for time-varying parameters.
type: either "hist" (default) for histograms, "trace" for a trace plot or "boxplot" for a boxplot. Only used for parameter draws of constant coefficients.
...: further graphical parameters.
Returns
An object of class "gvec" containing the following components, if specified: - data: the original time-series object of endogenous variables.
exogen: the original time-series object of unmodelled variables.
y: a time-series object of differenced endogenous variables.
w: a time-series object of lagged endogenous variables in levels, which enter the cointegration term.
w_x: a time-series object of lagged unmodelled, non-deterministic variables in levels, which enter the cointegration term.
w_d: a time-series object of deterministic terms, which enter the cointegration term.
x: a time-series object of K(p−1) differenced endogenous variables
x_x: a time-series object of Ms differenced unmodelled regressors.
x_d: a time-series object of NUR deterministic terms that do not enter the cointegration term.
A0: an S×K2 "mcmc" object of coefficient draws of structural parameters. In case of time varying parameters a list of such objects.
A0_lambda: an S×K2 "mcmc" object of inclusion parameters for coefficients corresponding to structural parameters.
A0_sigma: an S×K2 "mcmc" object of the error covariance matrices of the structural parameters in a model with time varying parameters.
alpha: an S×Kr "mcmc" object of coefficient draws of loading parameters. In case of time varying parameters a list of such objects.
beta: an S×((K+M+NR)r) "mcmc" object of coefficient draws of cointegration parameters corresponding to the endogenous variables of the model. In case of time varying parameters a list of such objects.
beta_x: an S×KM "mcmc" object of coefficient draws of cointegration parameters corresponding to unmodelled, non-deterministic variables. In case of time varying parameters a list of such objects.
beta_d: an S×KNR "mcmc" object of coefficient draws of cointegration parameters corresponding to restricted deterministic variables. In case of time varying parameters a list of such objects.
Pi: an S×K2 "mcmc" object of coefficient draws of endogenous variables in the cointegration matrix. In case of time varying parameters a list of such objects.
Pi_x: an S×KM "mcmc" object of coefficient draws of unmodelled, non-deterministic variables in the cointegration matrix. In case of time varying parameters a list of such objects.
Pi_d: an S×KNR "mcmc" object of coefficient draws of restricted deterministic variables in the cointegration matrix. In case of time varying parameters a list of such objects.
Gamma: an S×(p−1)K2 "mcmc" object of coefficient draws of differenced lagged endogenous variables. In case of time varying parameters a list of such objects.
Gamma_lamba: an S×(p−1)K2 "mcmc" object of inclusion parameters for coefficients corresponding to differenced lagged endogenous variables.
Gamma_sigma: an S×(p−1)K2 "mcmc" object of the error covariance matrices of the coefficients of lagged endogenous variables in a model with time varying parameters.
Upsilon: an S×sMK "mcmc" object of coefficient draws of differenced unmodelled, non-deterministic variables. In case of time varying parameters a list of such objects.
Upsilon_lambda: an S×sMK "mcmc" object of inclusion parameters for coefficients corresponding to differenced unmodelled, non-deterministic variables.
Upsilon_sigma: an S×sMK "mcmc" object of the error covariance matrices of the coefficients of unmodelled, non-deterministic variables in a model with time varying parameters.
C: an S×KNUR "mcmc" object of coefficient draws of deterministic terms that do not enter the cointegration term. In case of time varying parameters a list of such objects.
C_lambda: an S×KNUR "mcmc" object of inclusion parameters for coefficients corresponding to deterministic terms, that do not enter the conintegration term.
C_sigma: an S×KNUR "mcmc" object of the error covariance matrices of the coefficients of deterministic terms, which do not enter the cointegration term, in a model with time varying parameters.
Sigma: an S×K2 "mcmc" object of variance-covariance draws. In case of time varying parameters a list of such objects.
Sigma_lambda: an S×K2 "mcmc" object inclusion parameters for the variance-covariance matrix.
Sigma_sigma: an S×K2 "mcmc" object of the error covariance matrices of the coefficients of the error covariance matrix of the measurement equation of a model with time varying parameters.
specifications: a list containing information on the model specification.
Details
For the vector error correction model with unmodelled exogenous variables (VECX)
the function collects the S draws of a Gibbs sampler in a standardised object, where Δyt is a K-dimensional vector of differenced endogenous variables and A0 is a K×K matrix of structural coefficients. Π+=[Π,Πx,Πd] is the coefficient matrix of the error correction term, where yt−1, xt−1 and dt−1R are the first lags of endogenous, exogenous variables in levels and restricted deterministic terms, respectively. Π, Πx, and Πd are the corresponding coefficient matrices, respectively. Γi is a coefficient matrix of lagged differenced endogenous variabels. Δxt is an M-dimensional vector of unmodelled, non-deterministic variables and Υi its corresponding coefficient matrix. dt is an NUR-dimensional vector of unrestricted deterministics and CUR
the corresponding coefficient matrix. ut is an error term with ut∼N(0,Σu).
For time varying parameter and stochastic volatility models the respective coefficients and error covariance matrix of the above model are assumed to be time varying, respectively.
The draws of the different coefficient matrices provided in alpha, beta, Pi, Pi_x, Pi_d, A0, Gamma, Ypsilon, C and Sigma have to correspond to the same MCMC iteration.
Examples
# Load datadata("e6")# Generate modeldata <- gen_vec(e6, p =4, r =1, const ="unrestricted", season ="unrestricted")# Obtain data matricesy <- t(data$data$Y)w <- t(data$data$W)x <- t(data$data$X)# Reset random number generator for reproducibilityset.seed(1234567)iterations <-400# Number of iterations of the Gibbs sampler# Chosen number of iterations should be much higher, e.g. 30000.burnin <-100# Number of burn-in drawsdraws <- iterations + burnin
r <-1# Set ranktt <- ncol(y)# Number of observationsk <- nrow(y)# Number of endogenous variablesk_w <- nrow(w)# Number of regressors in error correction termk_x <- nrow(x)# Number of differenced regressors and unrestrictec deterministic termsk_alpha <- k * r # Number of elements in alphak_beta <- k_w * r # Number of elements in betak_gamma <- k * k_x
# Set uninformative priorsa_mu_prior <- matrix(0, k_x * k)# Vector of prior parameter meansa_v_i_prior <- diag(0, k_x * k)# Inverse of the prior covariance matrixv_i <-0p_tau_i <- diag(1, k_w)u_sigma_df_prior <- r # Prior degrees of freedomu_sigma_scale_prior <- diag(0, k)# Prior covariance matrixu_sigma_df_post <- tt + u_sigma_df_prior # Posterior degrees of freedom# Initial valuesbeta <- matrix(c(1,-4), k_w, r)u_sigma_i <- diag(1/.0001, k)g_i <- u_sigma_i
# Data containersdraws_alpha <- matrix(NA, k_alpha, iterations)draws_beta <- matrix(NA, k_beta, iterations)draws_pi <- matrix(NA, k * k_w, iterations)draws_gamma <- matrix(NA, k_gamma, iterations)draws_sigma <- matrix(NA, k^2, iterations)# Start Gibbs samplerfor(draw in1:draws){# Draw conditional mean parameters temp <- post_coint_kls(y = y, beta = beta, w = w, x = x, sigma_i = u_sigma_i, v_i = v_i, p_tau_i = p_tau_i, g_i = g_i, gamma_mu_prior = a_mu_prior, gamma_v_i_prior = a_v_i_prior) alpha <- temp$alpha
beta <- temp$beta
Pi <- temp$Pi
gamma <- temp$Gamma
# Draw variance-covariance matrix u <- y - Pi %*% w - matrix(gamma, k)%*% x
u_sigma_scale_post <- solve(tcrossprod(u)+ v_i * alpha %*% tcrossprod(crossprod(beta, p_tau_i)%*% beta, alpha)) u_sigma_i <- matrix(rWishart(1, u_sigma_df_post, u_sigma_scale_post)[,,1], k) u_sigma <- solve(u_sigma_i)# Update g_i g_i <- u_sigma_i
# Store drawsif(draw > burnin){ draws_alpha[, draw - burnin]<- alpha
draws_beta[, draw - burnin]<- beta
draws_pi[, draw - burnin]<- Pi
draws_gamma[, draw - burnin]<- gamma
draws_sigma[, draw - burnin]<- u_sigma
}}# Number of non-deterministic coefficientsk_nondet <-(k_x -4)* k
# Generate bvec objectbvec_est <- bvec(y = data$data$Y, w = data$data$W, x = data$data$X[,1:6], x_d = data$data$X[,7:10], Pi = draws_pi, Gamma = draws_gamma[1:k_nondet,], C = draws_gamma[(k_nondet +1):nrow(draws_gamma),], Sigma = draws_sigma)# Load data data("e6")# Generate modelmodel <- gen_vec(data = e6, p =2, r =1, const ="unrestricted", iterations =20, burnin =10)# Chosen number of iterations and burn-in should be much higher.# Add priorsmodel <- add_priors(model)# Obtain posterior drawsobject <- draw_posterior(model)# Plot drawsplot(object)