#
# Cut-and-Paste Code below into window above and Run
#
#
# ZA20 (South Africa) BAU Model
#
# Measurement Matrix (Growth), (EF-KOF), (KOF+E-LU-CO2)
#
# EN.ATM.CO2E.KT EG.USE.COMM.KT.OE NY.GDP.MKTP.KD SL.TLF.TOTL.IN
#[1,] 0.360 0.352 0.368 0.36952
#[2,] -0.128 0.194 -0.103 0.07516
#[3,] -0.332 0.370 0.134 0.00362
# SP.POP.TOTL SL.UEM.TOTL.ZS SL.UEM.TOTL.NE.ZS KOF EF HDI
#[1,] 0.3708 0.343 0.334 0.304 -0.126 0
#[2,] 0.0294 0.210 0.360 -0.386 0.778 0
#[3,] 0.0879 -0.485 -0.170 0.576 0.363 0
#
# Fraction of Variance
#
AIC <- function(model) {informationTestsCalculations(model)[3]}
require(dse)
require(matlab)
f <- matrix( c(1.01675133, -0.004626103, -0.01453521, 0.165772597,
-0.03542798, 0.971611702, -0.16541610, 0.007325817,
-0.01614396, 0.072011756, 1.01788049, -0.033273933,
0.00000000, 0.0000000, 0.0000000, 1.0000000000
),byrow=TRUE,nrow=4,ncol=4)
#
# To stabilize model, Uncomment next Line
# f[1,1] <- 0.99651798; f[2,2] <- 0.952276629; f[3,3] <- 0.99762467
#
h <- eye(3,4)
k <- (f[,1:3,drop=FALSE])
ZA20 <- SS(F=f,H=h,K=k,z0=c( 0.165772597, 0.007325817, -0.033273933, 1.0000000000),
output.names=c("ZA1","ZA2","ZA3"))
print(ZA20)
is.SS(ZA20)
stability(ZA20)
# tfplot(simulate(ZA20,sampleT=100))
ZA20.data <- simulate(ZA20,sampleT=100,noise=matrix(0,100,3),start=1950)
ZA20.f <- forecast(l(ZA20,ZA20.data),horizon=100)
tfplot(ZA20.f)
AIC(l(ZA20,ZA20.data))
ZA20x <- SS(F=f,H=h,Q=eye(4,3),R=eye(3,3),z0=c( 0.165772597, 0.007325817, -0.033273933, 1.0000000000),
output.names=c("ZA1","ZA2","ZA3"))
shockDecomposition(ZA20x)
# LCI Parameter UCI P>=T[1] P< T[1] Std. Dev. Bias
#[1,] 1.00531 1.016751 1.031027 0.29 0.71 0.010009 0.00341
# [2,] -0.04364 -0.035428 -0.028557 0.42 0.58 0.006743 1.05413
# [3,] -0.02682 -0.016144 -0.008613 0.59 0.41 0.007626 1.03246
# [4,] -0.03624 -0.004626 0.021394 0.56 0.44 0.021052 1.02001
# [5,] 0.95355 0.971612 0.988376 0.23 0.77 0.012605 0.05474
# [6,] 0.05507 0.072012 0.094564 0.50 0.50 0.014750 0.94304
# [7,] -0.09647 -0.014535 0.060314 0.63 0.37 0.063817 1.01286
# [8,] -0.23248 -0.165416 -0.106910 0.65 0.35 0.054894 1.17959
# [9,] 0.97022 1.017880 1.064831 0.28 0.72 0.040578 0.02518
#[10,] 0.15525 0.165773 0.179095 0.69 0.31 0.011726 0.84493
#[11,] -0.02283 0.007326 0.029121 0.62 0.38 0.022194 1.00763
#[12,] -0.05148 -0.033274 -0.018334 0.51 0.49 0.013260 1.05205
#