# COLUMBIA L20 MODEL
#
# Cut-and-Paste Code Below Into Window Above
#
require(dse)
require(matlab)
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)
#
# Measurement Matrix (Growth) (LU-Q) (KOF-LU-CO2)
#
# EN.ATM.CO2E.KT EG.USE.COMM.KT.OE NY.GDP.MKTP.KD SL.TLF.TOTL.IN
#[1,] 0.334 0.3401 0.3395 0.3423
#[2,] -0.224 0.0126 -0.3089 -0.1177
#[3,] -0.396 0.0640 0.0343 0.0984
# SP.POP.TOTL SL.UEM.TOTL.NE.ZS KOF EF HDI
#[1,] 0.3471 0.297 0.314 0.3413 0.3419
#[2,] -0.0511 0.800 0.335 -0.2903 -0.0291
#[3,] 0.0203 -0.442 0.786 -0.0734 -0.0941
#
# Fraction of Variance
# [1] 0.918 0.957 0.982 0.992 0.998 0.999 1.000 1.000 1.000
#
f <- matrix( c(0.99965839, -0.01426713, 0.03417140, 0.17092153,
-0.01930647, 1.00581165, -0.03915463, -0.03737075,
-0.01633222, 0.22481442, 0.99270033, -0.04213761,
0.00000000, 0.0000000, 0.0000000, 1.0000000000
),byrow=TRUE,nrow=4,ncol=4)
#
# To Stabilize Model with Globalization
# Uncomment Following line
# f[2,2]<- 0.8 ; f[3,3] <- .4;
h <- eye(3,4)
k <- (f[,1:3,drop=FALSE])
COL20 <- SS(F=f,H=h,K=k,z0=c( 0.17092153, -0.03737075, -0.042137610, 1.0000000000),
output.names=c("CO1","CO2","CO3"))
print(COL20)
is.SS(COL20)
stability(m0 <- SS(F=f[1:3,1:3,drop=FALSE],H=eye(3),Q=eye(3), R=eye(3)))
# tfplot(simulate(COL20,sampleT=150))
COL20.data <- simulate(COL20,sampleT=150,noise=matrix(0,150,3))
COL20.f <- forecast(m <- l(COL20,COL20.data),horizon=150)
tfplot(COL20.f)
AIC(m)
shockDecomposition(m0)