# \donttest{
## These are long running examples that take approximately 1 minute to run.
## Estimate first a reduced form Gaussian STVAR p=3, M=2 model with the weighted relative
# stationary densities of the regimes as the transition weight function, and the means and
# AR matrices constrained to be identical across the regimes:
fit32cm <- fitSTVAR(gdpdef, p=3, M=2, AR_constraints=rbind(diag(3*2^2), diag(3*2^2)),
weight_function="relative_dens", mean_constraints=list(1:2), parametrization="mean",
nrounds=1, seeds=1, ncores=1)
# Then, we estimate/create various structural models based on the reduced form model.
# Create a structural model with the shocks identified recursively:
fit32cms_rec <- fitSSTVAR(fit32cm, identification="recursive")
# Create a structural model with the shocks identified by conditional heteroskedasticity:
fit32cms_hetsked <- fitSSTVAR(fit32cm, identification="heteroskedasticity")
fit32cms_hetsked # Print the estimates
# Estimate a structural model with the shocks identified by conditional heteroskedasticity
# and overidentifying constraints imposed on the impact matrix: positive diagonal element
# and zero upper right element:
fit32cms_hs2 <- fitSSTVAR(fit32cm, identification="heteroskedasticity",
B_constraints=matrix(c(1, NA, 0, 1), nrow=2))
# Estimate a structural model with the shocks identified by conditional heteroskedasticity
# and overidentifying constraints imposed on the impact matrix: positive diagonal element
# and zero off-diagonal elements:
fit32cms_hs3 <- fitSSTVAR(fit32cms_hs2, identification="heteroskedasticity",
B_constraints=matrix(c(1, 0, 0, 1), nrow=2))
# Estimate first a reduced form two-regime Threshold VAR p=1 model with
# with independent skewed t shocks, and the first lag of the second variable
# as the switching variable, and AR matrices constrained to be identical
# across the regimes:
fit12c <- fitSTVAR(gdpdef, p=1, M=2, cond_dist="ind_skewed_t",
AR_constraints=rbind(diag(1*2^2), diag(1*2^2)), weight_function="threshold",
weightfun_pars=c(2, 1), nrounds=1, seeds=1, ncores=1)
# Due to the independent non-Gaussian shocks, the structural shocks are readily
# identified. The following returns the same model but marked as structural
# with the shocks identified by non-Gaussianity:
fit12c <- fitSSTVAR(fit12c)
# Estimate a model based on a reversed ordering of the columns of the impact matrix B_2:
fit12c2 <- fitSSTVAR(fit12c, B_pm_reg=2, B_perm=c(2, 1))
# Estimate a model based on reversed signs of the second column of B_2 and reversed
# ordering of the columns of B_2:
fit12c3 <- fitSSTVAR(fit12c, B_pm_reg=2, B_perm=c(2, 1), B_signs=2)
# }
Run the code above in your browser using DataLab