#
# Marx Cyclical (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) (K+KU+R-i) (Growth-R)
# K i LU R KU
#[1,] 0.171 0.0609 0.6273 -0.492 0.576
#[2,] 0.682 -0.4999 -0.0982 0.419 0.316
#[3,] 0.345 0.8623 -0.0929 0.313 0.175
#
# Fraction of Variance
#[1] 0.481 0.841 0.987 1.000 1.000
#
f <- matrix( c(0.97077363, 0.08376097, 0.01752653, 0.08394119,
-0.15545345, 0.90251423, 0.03549574, 0.05609541,
-0.04580092, -0.06870228, 0.90907033, 0.02359125,
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.08394119, 0.05609541, 0.02359125, 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))