#
# Marx Collapse (Cut and paste code into window above and Run (Cmd-Enter)
#
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-R) (i-KU-K-R) (Growth-KU)
# K i LU R KU
#[1,] 0.491 0.280 -0.526 0.5588 0.302
#[2,] -0.368 0.629 -0.276 0.0847 -0.621
#[3,] 0.120 0.694 0.232 -0.4852 0.463
#
# Fraction of Variance
#[1] 0.611 0.964 0.989 0.998 1.000
#
f <- matrix( c(0.99214016, 0.10870884, 0.20308621, -0.03556595,
-0.05884381, 0.93788966, -0.05639899, -0.10266980,
-0.01817504, -0.01088793, 1.00819194, 0.02899585,
0.00000000, 0.0000000, 0.0000000, 1.0000000000
),byrow=TRUE,nrow=4,ncol=4)
h <- eye(3,4)
k <- (f[,1:3,drop=FALSE])
Marx <- SS(F=f,H=h,K=k,z0=c(-0.03556595, -0.10266980, 0.02899585, 1.0000000000),
output.names=c("Marx1","Marx2","Marx3"))
print(Marx)
is.SS(Marx)
stability(SS(F=f[1:3,1:3,drop=FALSE],H=eye(3),Q=eye(3),R=eye(3)))
# tfplot(simulate(Marx,sampleT=100))
Marx.data <- simulate(Marx,sampleT=100,noise=matrix(0,100,3))
Marx.f <- forecast(l(Marx,Marx.data),horizon=150)
tfplot(Marx.f)
AIC(l(Marx,Marx.data))