# Cut-and-Paste Code Below into Window Above and Run
#
# UK19 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), (XREAL-L), (X-XREAL)
#
# Q N U HOURS XREAL X L
#[1,] 0.384 0.3864 0.3823 0.375 0.371 0.370 0.376
#[2,] 0.198 -0.0571 -0.2698 -0.442 0.502 0.507 -0.425
#[3,] -0.387 -0.2090 -0.0438 0.196 -0.407 0.767 0.106
#
# Fraction of Variance
#[1] 0.956 0.999 1.000 1.000 1.000 1.000 1.000
#
f <- matrix( c(1.013050980, -0.016807108, 0.1068859, 0.086172579,
0.011893936, 0.989544519, 0.0923792, -0.002781924,
-0.002394937, -0.007515403, 1.0284871, -0.002150958,
0.00000000, 0.0000000, 0.0000000, 1.0000000000
),byrow=TRUE,nrow=4,ncol=4)
#
# To Stabilize Model, Uncomment Next Line
# f[1,1] <- f[3,3] <- 0.90
#
h <- eye(3,4)
k <- (f[,1:3,drop=FALSE])
UK19 <- SS(F=f,H=h,K=k,z0=c( 0.086172579, -0.002781924, -0.002150958, 1.0000000000),
output.names=c("UK1","UK2","UK3"))
print(UK19)
is.SS(UK19)
stability(m <- SS(F=f[1:3,1:3,drop=FALSE],Q=eye(3),R=eye(3),H=eye(3)))
# tfplot(simulate(UK19,sampleT=100))
UK19.data <- simulate(UK19,sampleT=100,noise=matrix(0,100,3),start=1800)
UK19.f <- forecast(m1<-l(UK19,UK19.data),horizon=100)
tfplot(UK19.f)
AIC(m1)