# NOT RUN {
## These are long running examples that use parallel computing!
# These examples use the data 'eurusd' which comes with the
# package, but in a scaled form (similar to Kalliovirta et al. 2016).
data(eurusd, package="gmvarkit")
data <- cbind(10*eurusd[,1], 100*eurusd[,2])
colnames(data) <- colnames(eurusd)
# GMVAR(1,2) model: 10 estimation rounds with seeds set
# for reproducibility
fit12 <- fitGMVAR(data, p=1, M=2, ncalls=10, seeds=1:10)
fit12
plot(fit12)
summary(fit12)
print_std_errors(fit12)
profile_logliks(fit12)
# Structural GMVAR(1,2) model identified with sign
# constraints. The sign constraints (which fully identify
# the shocks) are in line with the reduced form model,
# so the maximized loglikelihood is the same.
W_122 <- matrix(c(1, NA, -1, 1), nrow=2)
fit12s <- fitGMVAR(data, p=1, M=2, structural_pars=list(W=W_122),
ncalls=10, seeds=1:10)
fit12s
# GMVAR(2,2) model with mean parametrization
fit22 <- fitGMVAR(data, p=2, M=2, parametrization="mean",
ncalls=16, seeds=1:16)
fit22
# Structural GMVAR(2,2) model with the lambda parameters restricted
# to be identical (in the second regime) and the shocks identified
# with diagonal of the B-matrix normalized positive and one zero constraint.
# The resulting model has error term covariance matrices that are
# multiplicatives of each other, while the identification equals to
# identification through Cholesky decomposition.
W_222 <- matrix(c(1, NA, 0, 1), nrow=2)
C_lambda_222 <- matrix(c(1, 1), nrow=2)
fit22s <- fitGMVAR(data, p=2, M=2, structural_pars=list(W=W_222, C_lambda=C_lambda_222),
ncalls=20, seeds=1:20)
fit22s
# GMVAR(2,2) model with autoregressive parameters restricted
# to be the same for both regimes
C_mat <- rbind(diag(2*2^2), diag(2*2^2))
fit22c <- fitGMVAR(data, p=2, M=2, constraints=C_mat)
fit22c
# GMVAR(2,2) model with autoregressive parameters restricted
# to be the same for both regimes and non-diagonl elements
# the coefficient matrices constrained to zero. Estimation
# with only 10 estimation rounds.
tmp <- matrix(c(1, rep(0, 10), 1, rep(0, 8), 1, rep(0, 10), 1),
nrow=2*2^2, byrow=FALSE)
C_mat2 <- rbind(tmp, tmp)
fit22c2 <- fitGMVAR(data, p=2, M=2, constraints=C_mat2)
fit22c2
# }
Run the code above in your browser using DataLab