#
# LAC1 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)
#
# LAC1 World Model Input (requires WL20.fx)
#
#
# Measurement Matrix # Growth, (LU-Q-E), (N+L-CO2-Q
#
# EN.ATM.CO2E.KT EG.USE.COMM.KT.OE NY.GDP.MKTP.KD SL.TLF.TOTL.IN
#[1,] 0.412 0.412 0.411 0.413
#[2,] -0.190 -0.239 -0.272 -0.144
#[3,] -0.532 -0.169 -0.252 0.497
# SP.POP.TOTL SL.UEM.TOTL.ZS
#[1,] 0.41317 0.388
#[2,] -0.00377 0.901
#[3,] 0.59551 -0.152
#
# Fraction of Variance
#[1] 0.972 0.997 0.999 1.000 1.000 1.000
#
f <- matrix( c( 0.7537367, -0.1158698,
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.1966073, 0.02923806, -0.06832,
0.0000000, 0.000000, 0.0000000
),byrow=TRUE,nrow=2,ncol=3)
LAC1 <- SS(F=f,H=h,K=k,G=g,z0=c( -0.2439615, 1.0000000),
output.names=c("LAC1"),input.names=c("W1","W2","W3"))
tfplot(simulate(LAC1,sampleT=150,noise=matrix(0,150,1),start=1950,input=WL20.fx))
#