# Cut-and-Paste Code below into Window Above and Run
#
# W19 World 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-T), (T+XREAL+Q-L), XREAL-Q-N-T), (X - XREAL), (Q - N-X-L-T), (N-L-Q)
#
# Q N XREAL X L T
#[1,] 0.412 0.4256 0.4082 0.4150 0.402 -0.386
#[2,] 0.363 -0.0478 0.4026 0.3227 -0.480 0.608
#[3,] -0.479 -0.4773 0.5449 0.2467 -0.184 -0.388
#
#[4,] 0.233 -0.2443 -0.5946 0.5959 -0.287 -0.308
#[5,] 0.544 -0.1579 0.1423 -0.5543 -0.391 -0.446
#[6,] -0.343 0.7100 -0.0242 0.0206 -0.583 -0.194
#
# Fraction of Variance
#[1] 0.916 0.997 0.999 1.000 1.000 1.000
f <- matrix( c(1.017250893, -0.020318992, 0.05992186, 0.077760753,
0.017524849, 0.990743759, 0.04984382, -0.002539976,
-0.004654088 ,-0.009242275, 1.04850016, -0.004339670,
0.00000000, 0.0000000, 0.0000000, 1.0000000000
),byrow=TRUE,nrow=4,ncol=4)
#
# To stabilize model, uncomment next line
# f[1,1] <- f[2,2] <- f[3,3] <- 0.90
#
h <- eye(3,4)
k <- (f[,1:3,drop=FALSE])
W19 <- SS(F=f,H=h,K=k,z0=c(0.077760753, -0.002539976, -0.004339670, 1.0000000000),
output.names=c("W1","W2","W3"))
print(W19)
is.SS(W19)
stability(m <- SS(F=f[1:3,1:3,drop=FALSE],Q=eye(3),R=eye(3),H=eye(3)))
# tfplot(simulate(W19,sampleT=100))
W19.data <- simulate(W19,sampleT=100,noise=matrix(0,100,3))
W19.f <- forecast(m1<-l(W19,W19.data),horizon=100)
tfplot(W19.f)
AIC(m1)