#
# Cut-and-Paste Code below and RUN
#
merge.forecast <- function (fx,n=1) {
x <- splice(fx$pred,fx$forecast[[n]])
colnames(x) <- seriesNames(fx$data$output)
return(x)
}
#
# W_MA_CHACO Chaco Canyon Model
#
AIC <- function(model) {informationTestsCalculations(model)[3]}
require(dse)
require(matlab)
#
#Measurement Matrix
#
# (Growth) (T-GROWTH) (Q-N-T)
# N Q T
#[1,] 0.580 0.630 0.517
#[2,] -0.564 -0.148 0.813
#[3,] -0.588 0.763 -0.269
# Fraction of Variance
#[1] 0.772 0.960 1.000
#
#
f <- matrix( c( 0, 0, 0, -0.996069422, -0.009363776, 0.02299434, 0.0000000000,
0, 0, 0, 0.011156930, -1.010001892, 0.02420908, 0.0000000000,
0, 0, 0, 0.007819715, 0.014322496 ,-0.97260252, 0.0000000000,
1, 0, 0, 1.993258504, 0.007065797, -0.02934768, -0.0056132936,
0, 1, 0, -0.012139586, 2.006853506, -0.02743926, -0.0039572022,
0, 0, 1, -0.007524662, -0.014152934, 1.97297984, 0.0004630367,
0, 0, 0, 0.000000000, 0.000000000, 0.00000000, 1.0000000000
),byrow=TRUE,nrow=7,ncol=7)
#
# To eliminate Nonlinearities, uncomment next line
# f[1:3,4:4] <- 0
# To Stabilize Model, uncomment next line
# f[4,4] <- f[5,5] <- f[6,6] <- 0.90
#
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[1:7,4:6,drop=FALSE]
CHACO <- SS(F=f,H=h,K=k,z0=c( 0.0000000000, 0.0000000000, 0.0000000000,
-0.0056132936, -0.0039572022, 0.0004630367, 1.0000000000),
output.names=c("CHACO1","CHACO2","CHACO3"))
print(CHACO)
is.SS(CHACO)
stability(m1 <- SS(F=f,H=h,Q=eye(7,3),R=eye(3)))
tfplot(simulate(CHACO,sampleT=100,start=900))
CHACO.data <- simulate(CHACO,sampleT=100,noise=matrix(0,100,3),start=900)
CHACO.f <- forecast(m <- l(CHACO,CHACO.data),horizon=100)
tfplot(CHACO.f)
AIC(m)
shockDecomposition(m1)