#
# USL20 Hardship BAU
#
# help(dse)
# help(SS)
merge.forecast <- function (fx,n=1) {
#
# Merges a forecast with the outputdata
x <- splice(fx$pred,fx$forecast[[n]])
colnames(x) <- seriesNames(fx$data$output)
return(x)
}
AIC <- function(model) {informationTestsCalculations(model)[3]}
require(dse)
require(matlab)
#
# Measurement Matrix
# NY.GDP.DEFL.KD.ZG SI.POV.DDAY FP.CPI.TOTL NE.CON.PRVT.PC.KD SL.UEM.TOTL.ZS
#[1,] -0.224 0.186 0.287 0.287 0.2305
#[2,] -0.364 -0.427 -0.085 -0.128 0.4649
#[3,] 0.303 0.605 0.144 0.105 -0.0394
# SL.UEM.TOTL.NE.ZS SP.DYN.IMRT.MA.IN SI.POV.GINI SP.DYN.LE00.IN
#[1,] -0.120 -0.2924 0.2890 0.290
#[2,] 0.657 -0.0691 -0.0401 0.013
#[3,] 0.632 0.0977 -0.0375 0.181
# SH.STA.SMSS.ZS SH.XPD.GHED.CH.ZS SH.XPD.CHEX.GD.ZS SL.FAM.WORK.ZS
#[1,] 0.2957 0.2955 0.2956 -0.2894
#[2,] 0.0346 0.0549 0.0250 0.0522
#[3,] 0.0898 -0.0569 0.0293 -0.0122
# SL.TLF.PART.ZS
#[1,] -0.28930
#[2,] 0.00196
#[3,] 0.23026
#
#
f <- matrix( c( 0.97899268, -0.01756984, 0.01681586, 0.22578953,
-0.02873468, 0.67995410, 0.07476549, -0.01382950,
0.02487113, -0.21844801, 0.92614160, 0.05265287,
0.00000000, 0.00000000, 0.00000000, 1.00000000
),nrow=4,ncol=4, byrow=TRUE)
h <- eye(3,4)
k <- (f[,1:3,drop=FALSE])
US_HARD <- SS(F=f,H=h,K=k,z0=c( 0.22578953, -0.01382950, 0.05265287, 1.00),
output.names=c("HARD1", "HARD2","HARD3"))
print(US_HARD)
is.SS(US_HARD)
stability(m <- SS(F=f[1:3,1:3,drop=FALSE],H=eye(3),Q=eye(3),R=eye(3)))
US_HARD.data <- simulate(US_HARD,sampleT=150,noise=matrix(0,150,3),start=1960)
tfplot(US_HARD.data)
US_HARD.f <- forecast(l(US_HARD,US_HARD.data),horizon=150)
tfplot(US_HARD.f )
shockDecomposition(m)
#
# Bootstrap Confidence Intervals
#
# LCI Parameter UCI P>=T[1] P< T[1] Std. Dev. Bias Bias-z
# [1,] 0.96194 0.97899 0.994443 0.24 0.76 0.01323 0.009793 0.740
# [2,] -0.05266 -0.02873 -0.005136 0.61 0.39 0.01974 0.999876 50.652
# [3,] 0.01121 0.02487 0.037244 0.33 0.67 0.01078 0.959304 88.962
# [4,] -0.09094 -0.01757 0.066266 0.83 0.17 0.06040 0.934713 15.474
# [5,] 0.48382 0.67995 0.877763 0.43 0.57 0.15004 0.318113 2.120
# [6,] -0.29531 -0.21845 -0.132298 0.94 0.06 0.06858 1.096814 15.993
# [7,] -0.05566 0.01682 0.070516 0.33 0.67 0.05246 0.991905 18.907
# [8,] -0.07299 0.07477 0.197482 0.26 0.74 0.09826 0.971790 9.890
# [9,] 0.85150 0.92614 0.994310 0.09 0.91 0.05883 0.127783 2.172
#[10,] 0.18409 0.22579 0.260047 0.46 0.54 0.02915 0.762614 26.159
#[11,] -0.09443 -0.01383 0.064516 0.48 0.52 0.06556 0.989139 15.087
#[12,] 0.01091 0.05265 0.096056 0.15 0.85 0.03798 0.960089 25.276
#