#
# UKL201 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),start=1950)
WL20.f <- forecast(l(WL20,WL20.data),horizon=50)
WL20.fx <- merge.forecast(WL20.f)
#
# USL201 World Model Input (requires WL20.fx)
#
#
# Measurement Matrix (Growth-CO2-U), (EG+CO2-L-LU), (LU+EG)
#
# EN.ATM.CO2E.KT EG.USE.COMM.KT.OE NY.GDP.MKTP.KD SL.TLF.TOTL.IN
#[1,] -0.4005 0.210 0.4914 0.418
#[2,] 0.4492 0.750 0.1189 -0.380
#[3,] -0.0952 0.411 0.0308 0.116
# SP.POP.TOTL SL.UEM.TOTL.ZS
#[1,] 0.4874 -0.376
#[2,] 0.0392 -0.276
#[3,] 0.2750 0.856
#
# Fraction of Variance
#[1] 0.669 0.889 0.965 0.995 0.998 1.000
#
f <- matrix( c( 0.8572965, 0.004722643,
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.08234309, -0.1063676, 0.03277194,
0.0000000, 0.000000, 0.0000000
),byrow=TRUE,nrow=2,ncol=3)
UK1 <- SS(F=f,H=h,K=k,G=g,z0=c( -0.2439615, 1.0000000),
output.names=c("UK1"),input.names=c("W1","W2","W3"))
tfplot(simulate(UK1,sampleT=150,noise=matrix(0,150,1),start=1950,input=WL20.fx))
#