# Cut-and-Paste Code below into Window above and Run
#
# MEA_L20 (Late 20th) Model (Middle-East Africa)
#
# Measurement Matrix (Growth) (N-CO2-EG-Q) (Q-EG)
# EN.ATM.CO2E.KT EG.USE.COMM.KT.OE NY.GDP.MKTP.KD SL.TLF.TOTL.IN SP.POP.TOTL SL.UEM.TOTL.ZS
#[1,] 0.4140 0.409 0.413 0.4163 0.4163 0.3800
#[2,] -0.2320 -0.361 -0.216 -0.0443 0.0458 0.8746
#[3,] 0.0599 -0.604 0.708 0.1760 -0.3125 -0.0336
#
# Fraction of Variance
#[1] 0.959 0.996 0.999 0.999 1.000 1.000
#
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)
f <- matrix( c(1.013898777, 0.013960359, 0.014314423, 0.160971128,
-0.035391585, 1.097936826, -0.004866923, -0.023976869,
-0.003813121, -0.009715855, 0.919184163 , 0.005569086,
0.000000000, 0.000000000, 0.000000000, 1.000000000
),byrow=TRUE,nrow=4,ncol=4)
#
# To stabilize the model, uncomment the next three lines:
# f[1,1] <- 0.926214020
# f[2,2] <- 0.90 # f[2,2] <- 1.002984227 Stability isn't enough
# f[3,3] <- 0.839690586
#
h <- eye(3,4)
k <- (f[,1:3,drop=FALSE])
MEA <- SS(F=f,H=h,K=k,z0=c(0.32392455, -0.05602608, 0.01030725, 1.0000000000),
output.names=c("MEA1","MEA2","MEA3"))
print(MEA)
is.SS(MEA)
stability(MEA)
MEA.data <- (simulate(MEA,sampleT=100,start=1950))
MEA.data <- simulate(MEA,sampleT=20,noise=matrix(0,20,3),start=1950)
MEA.f <- forecast(m <- l(MEA,MEA.data),horizon=150)
tfplot(MEA.f)
AIC(m)
shockDecomposition(m)