#
# LA Model (Cut-and-paste code below in window above and Run(Cmd-Enter)
#
AIC <- function(model) {informationTestsCalculations(model)[3]}
require(dse)
require(matlab)
#
# Measurement Matrix
# EN.ATM.CO2E.KT EG.USE.COMM.KT.OE NY.GDP.MKTP.KD
#[1,] 0.412 0.412 0.411
#[2,] -0.190 -0.239 -0.272
#[3,] -0.532 -0.169 -0.252
# SL.TLF.TOTL.IN SP.POP.TOTL SL.UEM.TOTL.ZS
#[1,] 0.413 0.41317 0.388
#[2,] -0.144 -0.00377 0.901
#[3,] 0.497 0.59551 -0.152
#
# Fraction of Variance
#[1] 0.972 0.997 0.999 1.000 1.000 1.000
#
f <- matrix( c( 1.00381064, -0.02146271, 0.08201721, 0.163480774,
-0.01920519, 1.00425865, -0.12263224, -0.009655540,
-0.00456711, 0.04692786, 0.98229614, -0.005545233,
0.00000000, 0.0000000, 0.0000000, 1.0000000000
),byrow=TRUE,nrow=4,ncol=4)
#
# To stabilize the System, uncomment the following line
# f[1,1] <- f[2,2] <- f[3,3] <- 0.97
#
h <- eye(3,4)
k <- (f[,1:3,drop=FALSE])
LA20 <- SS(F=f,H=h,K=k,z0=c( 0.163480774, -0.009655540, -0.005545233, 1.0000000000),
output.names=c("LA1","LA2","LA3"))
print(LA20)
is.SS(LA20)
stability(LA20)
# tfplot(simulate(LA20,sampleT=100))
LA20.data <- simulate(LA20,sampleT=100,noise=matrix(0,100,3))
LA20.f <- forecast(l(LA20,LA20.data),horizon=100)
tfplot(LA20.f)
AIC(l(LA20,LA20.data))
q <- matrix(c( 0.5789478229, -0.002422786, 0.003471643,
0.0519380944, 0.095565398, -0.005190806,
-0.0009844417, -0.000268017, 0.041578858,
0.0000000000, 0.000000000, 0.000000000
),byrow=TRUE,nrow=4,ncol=3)
r <- matrix(c( 0.578195486, 0.000000000, 0.00000000,
0.062615718, 0.094575099, 0.00000000,
-0.001305289, -0.004791044, 0.04232823
),byrow=TRUE,nrow=3,ncol=3)
LA20x <- SS(F=f,H=h,R=r,Q=q,z0=c( 0.163480774, -0.009655540, -0.005545233, 1.0000000000),
output.names=c("LA1","LA2","LA3"))
print(LA20x)
shockDecomposition(LA20x)