# Cut-and-Paste Code Below into Window Above and RUN
#
# LA19 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), (Q-N), X+Q-N-XREAL), (X+Q - XREAL-N), (N+Q-XREAL)
#
# Q N XREAL X
#[1,] 0.491 0.504 0.508 0.497
#[2,] 0.746 -0.344 0.158 -0.548
#[3,] 0.346 -0.492 -0.475 0.642
#
#[4,] 0.289 0.621 -0.701 -0.199
#
# Fraction of Variance
#[1] 0.959 0.991 0.999 1.000
#
f <- matrix( c( 0, 0, 0, -1.02254899, -0.3242925, -0.2155887, 0.0000000000,
0, 0, 0, -0.05099856, -1.1045662, -0.1075610, 0.0000000000,
0, 0, 0, 0.01474891, 0.2782880, -0.8332739, 0.0000000000,
1, 0, 0, 2.02027986, 0.3227060, 0.2461067, 0.0021700240,
0, 1, 0, 0.04672951, 2.1002001, 0.1088545, -0.0041560665,
0, 0 , 1, -0.01111916, -0.2772684, 1.8068335, 0.0006885246,
0, 0, 0, 0.00000000, 0.0000000, 0.0000000, 1.0000000000
),byrow=TRUE,nrow=7,ncol=7)
h <- matrix(c(0, 0, 0, 1, 0, 0, 0,
0 , 0 , 0, 0, 1, 0, 0,
0, 0, 0, 0, 0, 1, 0
),byrow=TRUE,nrow=3,ncol=7)
k <- (f[,4:6,drop=FALSE])
LA19 <- SS(F=f,H=h,K=k,z0=c(0, 0, 0, 0.0021700240, -0.0041560665, 0.0006885246, 1.0000000000),
output.names=c("LA1","LA2","LA3"))
print(LA19)
is.SS(LA19)
stability(m <- SS(F=f[1:6,1:6,drop=FALSE],Q=eye(6,3),R=eye(3),H=h[,1:6,drop=FALSE]))
# tfplot(simulate(LA19,sampleT=100))
LA19.data <- simulate(LA19,sampleT=100,noise=matrix(0,100,3))
LA19.f <- forecast(m1<-l(LA19,LA19.data),horizon=100)
tfplot(LA19.f)
AIC(m1)