# Cut-and-paste code below into window above and Run
#
# UK17 World Model (1600-1700)
#
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-XREAL, N+XREAL-Q, L-Q-N, Q+XREAL-N
#
# Q N XREAL
#[1,] 0.580 0.575 -0.577
#[2,] -0.163 0.776 0.609
#[3,] 0.798 -0.259 0.544
#
#Fraction of Variance
#[1] 0.989 1.000 1.000
f <- matrix( c(1.008476e+00, 0.018813271, 0.1236848, 0.0609753391,
7.994512e-03, 1.023957617, 0.1461305, 0.0022298776,
3.808761e-05, -0.006870376, 0.9675668, -0.0005602419,
0.000000e+00, 0.000000000, 0.0000000, 1.0000000000
),byrow=TRUE,nrow=4,ncol=4)
#
# To stabilize, uncomment next line
# f[1,1] <- f[2,2] <- 0.96
#
h <- eye(3,4)
k <- (f[,1:3,drop=FALSE])
UK17 <- SS(F=f,H=h,K=k,z0=c(0.0609753391, 0.0022298776, -0.0005602419, 1.0000000000),
output.names=c("UK1","UK2","UK3"))
print(UK17)
is.SS(UK17)
stability(m <- SS(F=f[1:3,1:3,drop=FALSE],H=eye(3),R=eye(3),Q=eye(3)))
# tfplot(simulate(UK17,sampleT=100))
UK17.data <- simulate(UK17,sampleT=150,noise=matrix(0,150,3))
UK17.f <- forecast(l(UK17,UK17.data),horizon=150)
tfplot(UK17.f)
AIC(m2 <- l(UK17,UK17.data))
shockDecomposition(m)