#
# Cut-and-Paste Code Below into Window Above and RUN
#
# RE Roman Empire (RE)
# ROMAN EMPIRE (500BC - 1500AD)
#
# Measurement Matrix
# (Growth) (T-N) (AREA-N)
# N Q T AREA
#[1,] 0.560 0.5802 0.145 0.5736
#[2,] -0.203 0.0278 0.976 -0.0779
#[3,] -0.771 0.1798 -0.117 0.5999
#
# Fraction of Variance
#[1] 0.730 0.976 0.994 1.000
#
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)
f <- matrix( c(0, 0, 0, -0.69066054, 0.075557550, 0.13445684, 0.000000000,
0, 0, 0, -0.07750604, -0.934172103, 0.05325588, 0.000000000,
0, 0, 0, -0.03679107, -0.004695734, -0.51970124, 0.000000000,
1, 0, 0, 1.66924556, -0.025423574, -0.09554433, -0.003370278,
0, 1, 0 , 0.07652123, 1.904990451, -0.04415323, -0.003394268,
0, 0, 1, 0.02847876, 0.003969387, 1.27392724, 0.002355218,
0, 0, 0, 0.00000000, 0.000000000, 0.00000000, 1.000000000
),byrow=TRUE,nrow=7,ncol=7)
#
# Eliminate Nonlinearities (Limits-to-Growth)
# Uncomment Next Line
# A <- SystemMatrix(RE); A[1:3,4:6] <- 0; f <- A;
#
h <- eye(3,7)
k <- (f[,4:6,drop=FALSE])
RE <- SS(F=f,H=h,K=k,z0=c(0.000000000, 0.000000000, 0.000000000, -0.003370278,
-0.003394268, 0.002355218, 1.000000000),
output.names=c("RE1","RE2","RE3"))
print(RE)
is.SS(RE)
stability(SS(f[1:6,1:6,drop=FALSE],Q=eye(6,3),R=eye(3,3),H=eye(3,6)))
#
tfplot(RE.data <- simulate(RE,sampleT=200,start=1))
#RE.data <- simulate(RE,sampleT=200,noise=matrix(0,200,3))
RE.f <- forecast(m <- l(RE,RE.data),horizon=200)
tfplot(RE.f)
AIC(m)
shockDecomposition(m)