#
# ES18 BAU Model Spain
#
merge.forecast <- function (fx,n=1) {
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 # overall-X, Q-U, U-HOURS, Q-N, N-U, X-XREAL
#
# Q N U HOURS XREAL X
#[1,] 0.40525 0.44332 0.3813 3.53e-01 -0.4297 -0.4297
#[2,] 0.44612 -0.00431 -0.5123 -6.23e-01 -0.2748 -0.2748
#[3,] -0.07459 0.19228 0.6831 -6.91e-01 0.0834 0.0834
#
#[4,] 0.79330 -0.25152 0.1743 1.05e-01 0.3647 0.3647
#[5,] 0.04260 0.82894 -0.3050 -1.67e-16 0.4193 0.2055
#[6,] 0.00652 0.12678 -0.0466 1.94e-16 -0.6512 0.7468
#
# Fraction of Variance
#[1] 0.845 0.984 1.000 1.000 1.000 1.000
#
f <- matrix( c( 1.021908444, -0.006660552, 0.008169387, 0.08305786,
-0.034558543, 1.021383495, -0.024500402, -0.01036956,
-0.002627521, 0.027285222, 0.991456560, -0.01076334,
0.00000000, 0.0000000, 0.0000000, 1.0000000000
),byrow=TRUE,nrow=4,ncol=4)
#
# To Stabilize, Uncomment next line
# f[1,1] <- f[2,2] <- 0.90
#
h <- eye(3,4)
k <- (f[,1:3,drop=FALSE])
ES18 <- SS(F=f,H=h,K=k,z0=c(0.08305786, -0.01036956, -0.01076334, 1.0000000000),
output.names=c("ES1","ES2","ES3"))
print(ES18)
is.SS(ES18)
stability(m <- SS(F=f[1:3,1:3,drop=FALSE],Q=eye(3),R=eye(3),H=eye(3)))
# tfplot(simulate(ES18,sampleT=100))
ES18.data <- simulate(ES18,sampleT=100,noise=matrix(0,100,3),start=1700)
ES18.f <- forecast(l(ES18,ES18.data),horizon=150)
tfplot(ES18.f)
AIC(l(ES18,ES18.data))
shockDecomposition(m)