# Cut-and-Paste code into Window Above and Run
#
#
# WL20 World 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-LP) (LP+OIL-TEMP) (P.OIL. - OIL - EF)
#
# N OIL QA GWP P.Wheat. P.Oil. TEMP CO2
#[1,] 0.2845 0.271 0.2821 0.2824 0.236 0.243 0.251 0.2837
#[2,] -0.0161 0.241 0.0985 -0.1413 0.411 0.066 -0.235 -0.0983
#[3,] -0.1112 -0.241 -0.0883 0.0213 0.461 0.712 0.190 -0.0201
# Carbon TotalFootprint Earths WorldGlobal LivingPlanet URBAN
#[1,] 0.2833 0.275 0.279 0.2819 -0.1839 0.2840
#[2,] 0.0925 0.182 0.148 -0.0926 0.7705 -0.0868
#[3,] -0.0955 -0.293 -0.231 -0.0943 -0.0576 -0.0707
#
# Fraction of Variance
# [1] 0.874 0.941 0.973 0.986 0.995 0.998 0.999 0.999 1.000 1.000 1.000
#[12] 1.000 1.000 1.000
#
f <- matrix( c(1.000000000, 0.00000000, 0.00000000, 0.00000000,
0.210941578, 1.01169571, -0.02519461, -0.09358484,
-0.003862528, -0.01360718, 0.96330129, -0.05250691,
0.018115378, 0.02303607, -0.03631204, 0.93554760
),byrow=TRUE,nrow=4,ncol=4)
#
# Growth-and-Collapse Model
# To create a high-level steady state, uncomment next line
# f[2,2] <- 0.90
#
h <- matrix(c(0, 1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1
),byrow=TRUE,nrow=3,ncol=4)
k <- (f[,2:4,drop=FALSE])
WL20 <- SS(F=f,H=h,K=k,z0=c(1.0000000, -5.3541066, -0.7239263, 0.7703831),
output.names=c("W1","W2","W3"))
print(WL20)
is.SS(WL20)
stability(SS(F=f[2:4,2:4,drop=FALSE],H=eye(3),R=eye(3),Q=eye(3)))
# tfplot(simulate(WL20,sampleT=150))
WL20.data <- simulate(WL20,sampleT=150,noise=matrix(0,150,3))
WL20.f <- forecast(l(WL20,WL20.data),horizon=50)
WL20.fx <- merge.forecast(WL20.f)
tfplot(WL20.f)
AIC(l(WL20,WL20.data))