#
# UAL20 BAU Model (Cut-and-Paste Code below into window above and Run (Cmd-Enter))
#
#Measurement Matrix (Growth-E-L), (Q+HDI+N-LU-KOF), (HDI+Q+E-N-LU-KOF)
#
# EN.ATM.CO2E.KT EG.USE.COMM.KT.OE NY.GDP.MKTP.KD SL.TLF.TOTL.IN
#[1,] -0.44492 0.320 -0.0949 -0.431
#[2,] -0.00332 0.378 0.5446 0.116
#[3,] 0.09127 -0.256 0.3296 -0.134
# SP.POP.TOTL SL.UEM.TOTL.ZS HDI EF KOF
#[1,] 0.193 0.3270 0.238 0.3941 0.385
#[2,] 0.385 -0.3784 0.412 0.0947 -0.277
#[3,] -0.695 -0.0499 0.512 0.1592 0.161
#
#Fraction of Variance
#[1] 0.555 0.876 0.962 0.991 0.996 0.999 1.000 1.000 1.000
#
AIC <- function(model) {informationTestsCalculations(model)[3]}
require(dse)
require(matlab)
f <- matrix( c(0.98126945, 0.02960859, 0.00616209, 0.12596852,
-0.05621155 , 0.96535464, 0.14721358, 0.03040828,
0.03222901, -0.05755769, 1.05202408, 0.04012898,
0.00000000, 0.0000000, 0.0000000, 1.0000000000
),byrow=TRUE,nrow=4,ncol=4)
#
# To stabilize, uncomment next line
# f[3,3] <- .9
#
h <- eye(3,4)
k <- (f[,1:3,drop=FALSE])
UAL20 <- SS(F=f,H=h,K=k,z0=c(0.12596852, 0.03040828, 0.04012898, 1.0000000000),
output.names=c("UA1","UA2","US3"))
print(UAL20)
is.SS(UAL20)
stability(UAL20)
# tfplot(simulate(UAL20,sampleT=100))
UAL20.data <- simulate(UAL20,sampleT=20,noise=matrix(0,100,3),start=1960)
UAL20.f <- forecast(l(UAL20,UAL20.data),horizon=100)
tfplot(UAL20.f)
AIC(l(UAL20,UAL20.data))
m <- toSSChol(UAL20)
shockDecomposition(m)
#
# UAL20 Random Walk
#
UAL20r <- SS(F=eye(4),H=h,Q=eye(4,3),R=eye(3),z0=c(0.12596852, 0.03040828, 0.04012898, 1.0000000000),
output.names=c("UA1","UA2","US3"))
UAL20r.data <- simulate(UAL20r,sampleT=100,start=1960)
UAL20r.model <- l(UAL20r,UAL20r.data)
tfplot(UAL20r.model)