#
# SYL20 BAU Model (cut and paste the following code into the window above and hit "Run (CMD-Enter)"
#
# Measurement Matrix (Growth) (EF-EG) (LU-KOF)
#
# EN.ATM.CO2E.KT EG.USE.COMM.KT.OE NY.GDP.MKTP.KD SL.TLF.TOTL.IN
#[1,] 0.342 0.3239 0.341 0.3477
#[2,] -0.112 -0.4920 -0.301 -0.0397
#[3,] -0.142 0.0312 -0.192 0.0779
# SP.POP.TOTL SL.UEM.TOTL.ZS KOF EF HDI
#[1,] 0.346 0.3169 0.338 0.3053 0.3372
#[2,] -0.176 0.0164 0.107 0.6926 0.3615
#[3,] -0.130 0.8838 -0.363 -0.0417 -0.0684
#
# Fraction of Variance
#
AIC <- function(model) {informationTestsCalculations(model)[3]}
require(dse)
require(matlab)
f <- matrix( c(1.00000000, 0.000000000, 0.000000000, 0.0000000,
0.17863313 , 1.012095084, 0.009518299, -0.1063310,
-0.01364385, -0.030579490, 0.964634125, 0.1349448,
-0.01404508, -0.001345318, 0.046377182, 0.5953866
),byrow=TRUE,nrow=4,ncol=4)
#
# To Stabilize, uncomment next line
# f[2,2] <- 0.9
#
h <- matrix(c( 0, 1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1
),byrow=TRUE,nrow=3,ncol=4)
k <- (f[,1:3,drop=FALSE])
q <- matrix(c(0.00000000, 0.000000000, 0.000000000,
0.15175397, -0.006432653, -0.000383436,
0.08352866, 0.202360319, 0.013218201,
0.10689632, -0.055204665, 0.169694202
),byrow=TRUE,nrow=4,ncol=3)
r <- matrix(c( 0.15248785, 0.0000000, 0.0000000,
0.07597308, 0.2165973, 0.0000000,
0.18955473, -0.1418127, 0.2850152
),byrow=TRUE,nrow=3,ncol=3)
SYL20 <- SS(F=f,H=h,K=k,z0=c( 1.0000000, -4.0243179, -0.9160641 , 0.4561761),
output.names=c("SY1","SY2","SY3"))
SYL20x <- SS(F=f,H=h,Q=q,R=r,z0=c( 1.0000000, -5.3541066, -0.7239263, 0.7703831),
output.names=c("SY1","SY2","SY3"))
print(SYL20)
is.SS(SYL20)
stability(SYL20)
# tfplot(simulate(SYL20,sampleT=100))
SYL20.data <- simulate(SYL20,sampleT=50,noise=matrix(0,20,3))
SYL20.f <- forecast(l(SYL20,SYL20.data),horizon=50)
tfplot(SYL20.f)
AIC(l(SYL20,SYL20.data))
shockDecomposition(SYL20x)
#
# Bootstrap Confidence Intervals
# Keep counterfactuals within LCI-UCI for high probability
#
# LCI Parameter UCI P>=T[1] P< T[1] Std. Dev. Bias Bias-z
# [1,] 0.16225 0.178633 0.193228 0.58 0.42 0.015870 -0.005038 -0.3174
# [2,] -0.03742 -0.013644 0.005267 0.64 0.36 0.017066 0.188232 11.0297
# [3,] -0.04283 -0.014045 0.009960 0.48 0.52 0.024244 0.193590 7.9852
# [4,] 0.99583 1.012095 1.027692 0.31 0.69 0.012594 -0.828864 -65.8151
# [5,] -0.03843 -0.030579 -0.023407 0.58 0.42 0.006251 0.209250 33.4744
# [6,] -0.01400 -0.001345 0.008696 0.52 0.48 0.009112 0.179789 19.7321
# [7,] -0.05726 0.009518 0.075622 0.63 0.37 0.053955 0.152394 2.8245
# [8,] 0.90898 0.964634 1.003664 0.53 0.47 0.035058 -0.781779 -22.2998
# [9,] 0.00157 0.046377 0.084697 0.57 0.43 0.038264 0.126774 3.3132
#[10,] -0.19202 -0.106331 -0.036708 0.53 0.47 0.062871 0.288595 4.5903
#[11,] 0.08539 0.134945 0.183998 0.13 0.87 0.038129 0.080959 2.1233
#[12,] 0.41047 0.595387 0.788288 0.59 0.41 0.156244 -0.462017 -2.9570
#