# Cut-and-Paste code into Window Above and Run
#
# EAP1 World Model Input (requires WL20.fx)
#
merge.forecast <- function (fx,n=1) {
x <- splice(fx$pred,fx$forecast[[n]])
colnames(x) <- seriesNames(fx$data$output)
return(x)
}
AIC <- function(model) {informationTestsCalculations(model)[3]}
require(dse)
require(matlab)
#
# WL20 World Model
#
f <- matrix( c(1.000000000, 0.00000000, 0.00000000, 0.00000000,
0.210941578, 1.01169571, -0.02519461, -0.09358484,
-0.003862528, -0.01360718, 0.96330129, -0.05250691,
0.018115378, 0.02303607, -0.03631204, 0.93554760
),byrow=TRUE,nrow=4,ncol=4)
#
# Growth-and-Collapse Model
# To create a high-level steady state, uncomment next line
# f[2,2] <- 0.90
#
h <- matrix(c(0, 1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1
),byrow=TRUE,nrow=3,ncol=4)
k <- (f[,2:4,drop=FALSE])
WL20 <- SS(F=f,H=h,K=k,z0=c(1.0000000, -5.3541066, -0.7239263, 0.7703831),
output.names=c("W1","W2","W3"))
WL20.data <- simulate(WL20,sampleT=150,noise=matrix(0,150,3))
WL20.f <- forecast(l(WL20,WL20.data),horizon=50)
WL20.fx <- merge.forecast(WL20.f)
#
# EAP1 World Model Input (requires WL20.fx)
#
#
# Measurement Matrix (Growth) (EG-LU) (LU+EG - L - N)
#
# EN.ATM.CO2E.KT EG.USE.COMM.KT.OE NY.GDP.MKTP.KD
#[1,] 0.4173 0.387 0.421
#[2,] 0.2833 0.690 0.107
#[3,] -0.0241 0.348 -0.249
# SL.TLF.TOTL.IN SP.POP.TOTL SL.UEM.TOTL.ZS
#[1,] 0.416 0.416 0.391
#[2,] -0.257 -0.266 -0.544
#[3,] -0.403 -0.337 0.735
#
# Fraction of Variance
#[1] 0.929 0.983 0.999 0.999 1.000 1.000
#
f <- matrix( c( 0.9112781, 0.05531086,
0.0000000, 1.0000000
),byrow=TRUE,nrow=2,ncol=2)
h <- eye(1,2)
k <- f[1:2,1,drop=FALSE]
g <- matrix(c(0.07732449, -0.03123965, -0.06708171,
0.0000000, 0.000000, 0.0000000
),byrow=TRUE,nrow=2,ncol=3)
EAP1 <- SS(F=f,H=h,K=k,G=g,z0=c( -0.2348308, 1.0000000),
output.names=c("EAP1"),input.names=c("W1","W2","W3"))
tfplot(simulate(EAP1,sampleT=150,noise=matrix(0,150,1),start=1950,input=WL20.fx))
#