require("spdep")
# 1st example (spatial GARCH)
##############
# parameters
rho <- 0.5
lambda <- 0.3
alpha <- 1
d <- 5
nblist <- cell2nb(d, d, type = "rook") # lattice process with Rook's contiguity matrix
W_1 <- nb2mat(nblist)
W_2 <- W_1
# simulation
Y <- sim.spGARCH(rho = rho, lambda = lambda, alpha = alpha,
W1 = W_1, W2 = W_2, type = "spGARCH")
# visualization
image(1:d, 1:d, array(Y, dim = c(d,d)), xlab = expression(s[1]), ylab = expression(s[2]))
# 2nd example (exponential spatial GARCH)
##############
# parameters
rho <- 0.5
lambda <- 0.3
alpha <- 1
zeta <- 0.5
theta <- 0.5
d <- 5
nblist <- cell2nb(d, d, type = "rook") # lattice process with Rook's contiguity matrix
W_1 <- nb2mat(nblist)
W_2 <- W_1
# simulation
Y <- sim.spGARCH(rho = rho, lambda = lambda, alpha = alpha,
W1 = W_1, W2 = W_2, zeta = zeta, theta = 0.5, type = "e-spGARCH")
# visualization
image(1:d, 1:d, array(Y, dim = c(d,d)), xlab = expression(s[1]), ylab = expression(s[2]))
Run the code above in your browser using DataLab