# Cut-and-Paste Code Below into Window Above and Run
#
# WE19 Model
#
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 (Growth), (Q+XREAL-N-HOURS), (N-HOURS-L), ( Q-X ), (Q-XREAL), (L-HOURS)
#
# Q N U HOURS XREAL X L
#[1,] 0.378 0.3887 0.38394 0.3745 3.75e-01 0.3698 0.375
#[2,] 0.372 -0.1350 -0.27344 -0.4299 4.20e-01 0.4806 -0.420
#[3,] 0.570 0.2639 0.22082 -0.2465 3.85e-02 -0.6731 -0.203
#
#[4,] 0.399 0.1304 0.00652 -0.0552 -8.25e-01 0.3740 -0.033
#[5,] 0.345 -0.0313 -0.79250 0.2691 3.68e-02 -0.1896 0.377
#[6,] -0.321 0.7587 -0.25074 -0.4673 1.24e-02 0.0575 0.191
#[7,] -0.109 0.4092 -0.19516 0.5659 4.12e-05 0.0011 -0.680
#
# Fraction of Variance
#[1] 0.937 0.999 1.000 1.000 1.000 1.000 1.000
#
f <- matrix( c(1.014919414, -0.0163225653, 0.02126275, 0.0856707663,
0.014061639, 0.9914806789, 0.04256366, -0.0025942872,
0.002171782, 0.0008180604, 1.00676880, 0.0009502395,
0.00000000, 0.0000000, 0.0000000, 1.0000000000
),byrow=TRUE,nrow=4,ncol=4)
#
# To Stabilize the Model, Uncomment next line
# f[1,1] <- f[3,3] <- 0.90
#
h <- eye(3,4)
k <- (f[,1:3,drop=FALSE])
WE19 <- SS(F=f,H=h,K=k,z0=c(0.0856707663, -0.0025942872, 0.0009502395, 1.0000000000),
output.names=c("WE1","WE2","WE3"))
print(WE19)
is.SS(WE19)
stability(m <- SS(F=f[1:3,1:3,drop=FALSE],Q=eye(3),R=eye(3),H=eye(3)))
# tfplot(simulate(WE19,sampleT=150))
WE19.data <- simulate(WE19,sampleT=100,noise=matrix(0,150,3),start=1800)
WE19.f <- forecast(m1<-l(WE19,WE19.data),horizon=150)
tfplot(WE19.f)