# \donttest{
es.agri <- 0.2 # the elasticity of substitution
es.manu <- 0.3
es.serv <- 0.1
es.VA.agri <- 0.25
es.VA.manu <- 0.5
es.VA.serv <- 0.8
d.agri <- c(260, 345, 400, 200, 160)
d.manu <- c(320, 390, 365, 250, 400)
d.serv <- c(150, 390, 320, 400, 210)
d.hh <- c(635, 600, 385, 0, 0)
# d.hh <- c(635, 600, 100, 0, 0)
IT <- cbind(d.agri, d.manu, d.serv, d.hh)
OT <- matrix(c(
1365, 0, 0, 0,
0, 1725, 0, 0,
0, 0, 1470, 0,
0, 0, 0, 850,
0, 0, 0, 770
), 5, 4, TRUE)
dimnames(IT) <- dimnames(OT) <-
list(
c("agri", "manu", "serv", "lab", "cap"),
c("agri", "manu", "serv", "hh")
)
addmargins(IT)
addmargins(OT)
dst.agri <- node_new("sector.agri",
type = "SCES", es = es.agri,
alpha = 1,
beta = prop.table(
c(sum(d.agri[1:3]), sum(d.agri[4:5]))
),
"cc1.agri", "cc2.agri"
)
node_set(dst.agri, "cc1.agri",
type = "Leontief",
a = prop.table(d.agri[1:3]),
"agri", "manu", "serv"
)
node_set(dst.agri, "cc2.agri",
type = "SCES", es = es.VA.agri,
alpha = 1,
beta = prop.table(d.agri[4:5]),
"lab", "cap"
)
dst.manu <- node_new("sector.manu",
type = "SCES", es = es.manu,
alpha = 1,
beta = prop.table(
c(sum(d.manu[1:3]), sum(d.manu[4:5]))
),
"cc1.manu", "cc2.manu"
)
node_set(dst.manu, "cc1.manu",
type = "Leontief",
a = prop.table(d.manu[1:3]),
"agri", "manu", "serv"
)
node_set(dst.manu, "cc2.manu",
type = "SCES", es = es.VA.manu,
alpha = 1,
beta = prop.table(d.manu[4:5]),
"lab", "cap"
)
dst.serv <- node_new("sector.serv",
type = "SCES", es = es.serv,
alpha = 1,
beta = prop.table(
c(sum(d.serv[1:3]), sum(d.serv[4:5]))
),
"cc1.serv", "cc2.serv"
)
node_set(dst.serv, "cc1.serv",
type = "Leontief",
a = prop.table(d.serv[1:3]),
"agri", "manu", "serv"
)
node_set(dst.serv, "cc2.serv",
type = "SCES", es = es.VA.serv,
alpha = 1,
beta = prop.table(d.serv[4:5]),
"lab", "cap"
)
##
dst.hh <- node_new("sector.hh",
type = "SCES", es = 0.5,
alpha = 1,
beta = prop.table(d.hh[1:3]),
"agri", "manu", "serv"
)
dstl <- list(dst.agri, dst.manu, dst.serv, dst.hh)
ge <- gemInputOutputTable_5_4(dstl)
#### labor supply increase
geLSI <- gemInputOutputTable_5_4(dstl, supply.labor = 850 * 1.08)
geLSI$p
geLSI$z / ge$z
## capital supply change
ge.CSC <- sdm2(
A = dstl,
B = matrix(c(
1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1,
0, 0, 0, 1
), 5, 4, TRUE),
S0Exg = {
tmp <- matrix(NA, 5, 4)
tmp[4, 4] <- 850
tmp[5, 4] <- 770
tmp
},
names.commodity = c("agri", "manu", "serv", "lab", "cap"),
names.agent = c("agri", "manu", "serv", "hh"),
numeraire = "lab",
ts = TRUE,
numberOfPeriods = 100,
maxIteration = 1,
z0 = c(1365, 1725, 1470, 1620),
p0 = rep(1, 5),
policy = function(time, state) {
if (time >= 5) {
state$S[5, 4] <- 880
}
state
}
)
matplot(ge.CSC$ts.p, type = "l")
matplot(ge.CSC$ts.z, type = "l")
## economic fluctuation: a sticky-price path
de <- sdm2(
A = dstl,
B = matrix(c(
1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1,
0, 0, 0, 1
), 5, 4, TRUE),
S0Exg = {
tmp <- matrix(NA, 5, 4)
tmp[4, 4] <- 850
tmp[5, 4] <- 770
tmp
},
names.commodity = c("agri", "manu", "serv", "lab", "cap"),
names.agent = c("agri", "manu", "serv", "hh"),
numeraire = "lab",
ts = TRUE,
numberOfPeriods = 50,
maxIteration = 1,
z0 = c(1365, 1725, 1470, 1620),
p0 = rep(1, 5),
policy = list(
function(time, state) {
if (time >= 5) {
state$S[5, 4] <- 880
}
state
},
makePolicyStickyPrice(0.5)
),
priceAdjustmentVelocity = 0
)
matplot(de$ts.p, type = "o", pch = 20)
matplot(de$ts.z, type = "o", pch = 20)
# }
Run the code above in your browser using DataLab