#
# SSA Model Cut and Paste code below and Run (Cmd-Enter)
#
# Measurement Matrix
# EN.ATM.CO2E.KT EG.USE.COMM.KT.OE NY.GDP.MKTP.KD SL.TLF.TOTL.IN
#[1,] 0.34762 0.3461 0.3332 0.34982
#[2,] -0.16275 -0.2355 -0.3531 -0.15180
#[3,] 0.07203 -0.0701 -0.2855 0.02768
# SP.POP.TOTL SL.UEM.TOTL.ZS EF1 HDI1 GLOB1
#[1,] 0.34697 0.3007 0.34346 0.35004 0.2732
#[2,] -0.20062 0.4039 0.27151 -0.07706 0.6981
#[3,] -0.08363 0.7249 0.05914 0.11182 -0.5993
#
# Fraction of Variance
#[1] 0.8932 0.9565 0.9941 0.9978 0.9992 0.9997 0.9999 1.0000 1.0000
#
AIC <- function(model) {informationTestsCalculations(model)[3]}
require(dse)
require(matlab)
f <- matrix( c(1.0183603566, -0.02571595, 0.003499238, 0.146584882,
-0.0273328386, 1.02963120, 0.180449889, -0.015040318,
-0.0005446326, -0.01744892, 0.922227651, 0.003969535,
0.00000000, 0.0000000, 0.0000000, 1.0000000000
),byrow=TRUE,nrow=4,ncol=4)
#
# Stabilize (Uncomment following command)
# f[1,1] <- f[2,2] <- 0.9
#
h <- eye(3,4)
k <- (f[,1:3,drop=FALSE])
SSA <- SS(F=f,H=h,K=k,z0=c( 0.146584882, -0.015040318, 0.003969535, 1.0000000000),
output.names=c("SSA1","SSA2","SSA3"))
print(SSA)
is.SS(SSA)
stability(m <- SS(F=f[1:3,1:3,drop=FALSE],H=eye(3),Q=eye(3),R=eye(3)))
shockDecomposition(m)
# tfplot(simulate(SSA,sampleT=100),start=1960)
SSA.data <- simulate(SSA,sampleT=100,noise=matrix(0,100,3),start=1960)
SSA.f <- forecast(l(SSA,SSA.data),horizon=100)
tfplot(SSA.f)
AIC(l(SSA,SSA.data))