#
# Cut-and-Paste Code Below into Window Above and Run
#
# JP19 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 # (Overall), (Q-L-HOURS-U), (Q-N) MARX-MALTHUS
# Q N U HOURS L
#[1,] 0.3648 0.4663 0.4653 0.4648 0.4657
#[2,] 0.8617 0.1588 -0.2794 -0.2832 -0.2722
#[3,] 0.3523 -0.8690 0.1601 0.2347 0.1999
#
# Fraction of Variance
#[1] 0.8833 0.9932 1.0000 1.0000 1.0000
#
f <- matrix( c( 1.011355376, 0.007412169, 0.07951812, 0.075736431,
0.018129715, 0.994002927, 0.14393299, -0.001908968,
-0.004141524, -0.028884237, 1.02660256, -0.009851419,
0.000000000, 0.000000000, 0.00000000, 1.000000000
),byrow=TRUE,nrow=4,ncol=4)
#
# To Stabilize Model, Uncomment Next Line
# f[1,1] <- f[3,3] <- f[2,2]
#
h <- eye(3,4)
k <- (f[,1:3,drop=FALSE])
#
JP19 <- SS(F=f,H=h,K=k,z0=c(0.075736431, -0.001908968, -0.009851419, 1.0000000000),
output.names=c("JP1","JP2","JP3"))
print(JP19)
#
is.SS(JP19)
stability(m <- SS(F=f[1:3,1:3,drop=FALSE],Q=eye(3),R=eye(3),H=eye(3)))
# tfplot(simulate(JP19,sampleT=100))
JP19.data <- simulate(JP19,sampleT=150,noise=matrix(0,150,3),start=1800)
JP19.f <- forecast(m1<-l(JP19,JP19.data),horizon=150)
tfplot(JP19.f)
AIC(m1)