# NOT RUN {
## the example on page 352 in Varian (1992)
ge <- sdm(
A = function(state) {
a <- 0.5
alpha <- rep(1, 3)
Beta <- matrix(c(0, a, a,
0.5, 0, 0,
0.5, 1 - a, 1 - a), 3, 3, TRUE)
#the demand coefficient matrix.
CD_A(alpha, Beta, state$p)
},
B = diag(3),
S0Exg = matrix(c(NA, NA, NA,
NA, 1, NA,
NA, NA, 1), 3, 3, TRUE),
GRExg = 0,
tolCond = 1e-10
)
ge$p/ge$p[1]
## the example (see Table 2.1 and 2.2) of the canonical dynamic
## macroeconomic general equilibrium model in Torres (2016).
discount.factor <- 0.97
return.rate <- 1 / discount.factor - 1
depreciation.rate <- 0.06
ge <- sdm(
n = 4, m = 3,
A = function(state) {
a1 <- CD_A(1, rbind(0, 0.65, 0.35, 0), state$p)
a2 <- CD_A(1, rbind(0.4, 1 - 0.4, 0, 0), state$p)
a3 <- c(1, 0, 0, state$p[1] * return.rate / state$p[4])
cbind(a1, a2, a3)
},
B = matrix(c(
1, 0, 1 - depreciation.rate,
0, 1, 0,
0, 0, 1,
0, 1, 0
), 4, 3, TRUE),
S0Exg = {
tmp <- matrix(NA, 4, 3)
tmp[2, 2] <- 1
tmp[4, 2] <- 1
tmp
},
priceAdjustmentVelocity = 0.03,
maxIteration = 1,
numberOfPeriods = 5000,
ts = TRUE
)
ge$A %*% diag(ge$z) # the demand matrix
ge$p / ge$p[1]
plot(ge$ts.z[, 1], type = "l")
# }
Run the code above in your browser using DataLab