# Cut-and-Paste Code Below into Window Above and Run
#
# US_LM 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), (X-N), (L+XREAL-X-N)
#
# Q N HOURS XREAL X L
#[1,] 0.4124 0.403 0.413 0.410 0.399 0.412
#[2,] -0.1464 -0.580 -0.122 0.310 0.711 -0.160
#[3,] -0.0825 -0.546 0.137 0.358 -0.466 0.575
#
# Fraction of Variance
#[1] 0.977 0.999 1.000 1.000 1.000 1.000
#
f <- matrix( c( 1.026261160, -0.04873236, 0.04995449, 0.166789178,
0.023195483, 1.01292512, 0.06694359, 0.004293523,
-0.002685722, -0.04074830, 1.04458649, -0.006797188,
0.00000000, 0.0000000, 0.0000000, 1.0000000000
),byrow=TRUE,nrow=4,ncol=4)
#
# To stabilize, Uncomment Next Line
# f[1,1] <- 0.99377254; f[2,2] <- 0.97301183; f[3,3] <- 1.00342561
#
#
h <- eye(3,4)
k <- (f[,1:3,drop=FALSE])
US_LM <- SS(F=f,H=h,K=k,z0=c( 0.33740965, 0.01205627, -0.01452034, 1.0000000000),
output.names=c("US1","US2","US3"))
print(US_LM)
is.SS(US_LM)
stability(m <- SS(F=f[1:3,1:3,drop=FALSE],R=eye(3),Q=eye(3),H=eye(3)))
US_LM.data <- simulate(US_LM,sampleT=100,noise=matrix(0,100,3),start=1950)
US_LM.f <- forecast(l(US_LM,US_LM.data),horizon=100)
US_LM.fx <- merge.forecast(US_LM.f)
tfplot(US_LM.f)