#
# Cut-and-paste code below into window above an Run
#
# NACL2 Model. (NORTH AMERICA)
#
AIC <- function(model) {informationTestsCalculations(model)[3]}
require(dse)
require(matlab)
#
# Measurement Matrix (Growth-LU) (LU) (CO2+EG-Q-L-N)
# EN.ATM.CO2E.KT EG.USE.COMM.KT.OE NY.GDP.MKTP.KD SL.TLF.TOTL.IN
#[1,] 0.43643 0.43882 0.44188 0.4443
#[2,] 0.07086 0.04899 0.02476 0.1189
#[3,] 0.57112 0.51224 -0.49087 -0.2381
# SP.POP.TOTL SL.UEM.TOTL.ZS
#[1,] 0.4442 -0.164207
#[2,] 0.1020 0.983576
#[3,] -0.3372 0.009451
#
#Fraction of Variance
#[1] 0.8237 0.9730 0.9943 0.9988 0.9999 1.0000
#
f <- matrix( c(0.98459345, 0.03242716, -0.07593088, 0.143592850,
0.01351879, 0.69160748, 0.12954780, 0.020758284,
-0.01852557, -0.01318351, 0.92498947, 0.004671989,
0.00000000, 0.0000000, 0.0000000, 1.0000000000
),byrow=TRUE,nrow=4,ncol=4)
#
# To stabilize the model, Uncomment the next line
# f[1,1] <- 0.97474751; f[2,2] <- 0.68469140; f[3,3] <- 0.91573958;
#
h <- eye(3,4)
k <- (f[,1:3,drop=FALSE])
NACL20 <- SS(F=f,H=h,K=k,z0=c(0.143592850, 0.020758284, 0.004671989, 1.0000000000),
output.names=c("NAC1","NAC2","NAC3"))
print(NACL20)
is.SS(NACL20)
stability(SS(F=f[1:3,1:3,drop=FALSE],Q=eye(3,3),R=eye(3,3),H=eye(3,3)))
# tfplot(simulate(NACL20,sampleT=100))
NACL20.data <- simulate(NACL20,sampleT=50,noise=matrix(0,50,3))
NACL20.f <- forecast(l(NACL20,NACL20.data),horizon=50)
tfplot(NACL20.f)
AIC(l(NACL20,NACL20.data))
shockDecomposition(toSSChol(NACL20))