#
# USL201 World Model Input (requires WL20.fx)
#
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)
#
# WL20 World Model
#
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"))
WL20.data <- simulate(WL20,sampleT=150,noise=matrix(0,150,3),start=1950)
WL20.f <- forecast(l(WL20,WL20.data),horizon=50)
WL20.fx <- merge.forecast(WL20.f)
#
# USL201 World Model Input (requires WL20.fx)
#
#
# Measurement Matrix (Growth)
# L.US.E. L.US.U. GDP.US. GDP.C. GDP.I. GDP.X. GDP.G.
#[1,] 0.1955 0.138 0.1978 0.1972 0.1961 -0.1402 0.1976
# P.US.TBILL. P.CPAPER. P.FED.FUNDS. P.CPI. P.GDP. P.SP500.
#[1,] 0.00429 -0.01554 0.0127 0.19773 0.1967 0.1868
# V.NYSE. P.S.P.DPR. P.S.P.EPR. Q.H.Starts. K.US. M1
#[1,] 0.166 -0.146 -0.112 -0.0202 0.1974 0.1953
# M2 P.WPI. Q.A. Q.I. O.B. P.FUELS. P.W.AG. P.W.MFG.
#[1,] 0.1979 0.1932 0.1918 0.1967 -0.173 0.1834 0.1983 0.1990
# Q.OIL. N.US. IMM.US. U.US. CAPU EF Globalization
#[1,] -0.113 0.1951 0.1440 0.1967 -0.141 0.1867 0.0818
# CO2 Q.FOSSIL.
#[1,] 0.180 0.129
#
# Fraction of Variance
# [1] 0.698 0.854 0.900 0.935 0.955 0.972 0.981 0.987 0.991 0.995 0.997
#
f <- matrix( c( 0.8591446, 0.2138536,
0.0000000, 1.0000000
),byrow=TRUE,nrow=2,ncol=2)
h <- eye(1,2)
k <- f[1:2,1,drop=FALSE]
g <- matrix(c(0.2246092, -0.152583, 0.1470327,
0.0000000, 0.000000, 0.0000000
),byrow=TRUE,nrow=2,ncol=3)
US1 <- SS(F=f,H=h,K=k,G=g,z0=c( -0.7710952, 1.0000000),
output.names=c("US1"),input.names=c("W1","W2","W3"))
print(US1)
tfplot(simulate(US1,sampleT=150,noise=matrix(0,150,1),start=1950,input=WL20.fx))
#