# Cut-and-Paste Code below into Window above and Run
#
# ESL20 Model (SPAIN)
#
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 (ES_SYS.index) # (GROWTH) (LU-L-EF) (EF+LU-EG-Q)
#
# EN.ATM.CO2E.KT EG.USE.COMM.KT.OE NY.GDP.MKTP.KD SL.TLF.TOTL.IN SP.POP.TOTL
#[1,] 0.3527 0.3500 0.3554 0.3315 0.3541
#[2,] -0.0307 0.0362 -0.0771 -0.3856 0.0135
#[3,] -0.0940 -0.3823 -0.2095 0.0683 0.0817
# SL.UEM.TOTL.ZS EF KOF HDI
#[1,] 0.243 0.300 0.341 0.355
#[2,] 0.778 -0.447 0.153 0.117
#[3,] 0.489 0.684 -0.259 -0.127
#
# Fraction of Variance
#[1] 0.862 0.948 0.983 0.997 0.999 1.000 1.000 1.000 1.000
#
f <- matrix( c(1.012515245, 0.004650047, 0.01709644, 0.16883530,
0.015455666, 0.959520970, -0.15167718, -0.01127248,
0.005752657, 0.036998778, 1.05980297, 0.01080932,
0.00000000, 0.0000000, 0.0000000, 1.0000000000
),byrow=TRUE,nrow=4,ncol=4)
# To Stabiize, Uncomment Next Line
# f[1,1] <- f[3,3] <- f[2,2]
#
h <- eye(3,4)
k <- (f[,1:3,drop=FALSE])
ESL20 <- SS(F=f,H=h,K=k,z0=c(0.16883530, -0.01127248, 0.01080932, 1.0000000000),
output.names=c("ES1","ES2","ES3"))
print(ESL20)
is.SS(ESL20)
stability(ESL20)
# tfplot(simulate(ESL20,sampleT=100,start=1950))
ESL20.data <- simulate(ESL20,sampleT=100,noise=matrix(0,100,3),start=1950)
ESL20.f <- forecast(m <- l(ESL20,ESL20.data),horizon=100)
tfplot(ESL20.f)
AIC(m)
shockDecomposition(toSSChol(ESL20))