#
# USL203 Model (Cut-and-Pase Code Below and Run (Cmd-Enter)
#
AIC <- function(model) {informationTestsCalculations(model)[3]}
require(dse)
require(matlab)
merge.forecast <- function (fx,n=1) {
x <- splice(fx$pred,fx$forecast[[n]])
colnames(x) <- seriesNames(fx$data$output)
return(x)
}#
#Measurement Matrix
# L.US.E. L.US.U. GDP.US. GDP.C. GDP.I. GDP.X. GDP.G. P.US.TBILL. P.CPAPER.
#[1,] 0.1955 0.138 0.1978 0.1972 0.1961 -0.1402 0.1976 0.00429 -0.01554
#[2,] 0.0669 0.200 -0.0462 -0.0554 -0.0355 0.0751 -0.0377 0.40583 0.40460
#[3,] -0.0312 0.239 0.0284 0.0314 -0.0272 0.2229 0.0541 0.07630 -0.00165
# P.FED.FUNDS. P.CPI. P.GDP. P.SP500. V.NYSE. P.S.P.DPR. P.S.P.EPR. Q.H.Starts.
#[1,] 0.0127 0.19773 0.1967 0.1868 0.166 -0.146 -0.112 -0.0202
#[2,] 0.3998 0.00996 0.0337 -0.1076 -0.131 0.144 0.128 0.0392
#[3,] 0.0986 0.02128 0.0240 -0.0277 0.165 0.321 0.384 -0.4666
# K.US. M1 M2 P.WPI. Q.A. Q.I. O.B. P.FUELS. P.W.AG. P.W.MFG.
#[1,] 0.1974 0.1953 0.1979 0.1932 0.1918 0.1967 -0.173 0.1834 0.1983 0.1990
#[2,] -0.0418 -0.0145 -0.0325 0.0612 0.0766 0.0374 0.186 0.0269 0.0131 0.0125
#[3,] 0.0446 -0.0318 0.0472 0.1051 -0.0973 -0.0683 0.110 0.2538 0.0489 0.0232
# Q.OIL. N.US. IMM.US. U.US. CAPU EF Globalization CO2 Q.FOSSIL.
#[1,] -0.113 0.1951 0.1440 0.1967 -0.141 0.1867 0.0818 0.180 0.129
#[2,] 0.312 0.0746 0.0546 0.0477 -0.153 0.1096 -0.2964 0.155 0.283
#[3,] -0.145 -0.0642 -0.1371 -0.0589 -0.164 0.0303 0.3905 -0.110 -0.157
#
# 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 0.998 0.998 0.999
#[15] 0.999 0.999 0.999 1.000 1.000 1.000 1.000 1.000 1.000 1.000 1.000 1.000 1.000 1.000
#
f <- matrix( c(1.00000000 ,0,0,0,0,0,0,
0.27812595, 0.8233150, -0.08125149, -0.000696273, 0.4846840, 0.1432173, -0.04554328,
-0.05302980, -0.3126345, 0.81784283, -0.092396131, 0.4120723, 0.1182771, -0.29037807,
0.08758306, -0.1946872, -0.11094535, 0.615939830, 1.1356920, 0.3652072, -0.35732652,
0.00000000, 0.0000000, 0.00000000, 0.000000000, 0.0000000, 0.0000000, 0.00000000,
0.00000000, 0.0000000, 0.00000000, 0.000000000, 0.0000000, 0.0000000, 0.00000000,
0.00000000, 0.0000000, 0.00000000, 0.000000000, 0.0000000, 0.0000000, 0.00000000
),byrow=TRUE,nrow=7,ncol=7)
g <- matrix(c( 0.00000000, 0.000000, 0.0000000,
-0.14759303, -0.0974411, 0.1827978,
0.03048737, -0.1305864, 0.2719997,
-0.79656558, -1.0263718, 0.5876214,
1.00000000, 0.0000000, 0.0000000,
0.00000000, 1.0000000, 0.0000000,
0.00000000, 0.0000000, 1.0000000
),byrow=TRUE,nrow=7,ncol=3)
h <- eye(3,7)
q <- eye(7)
r <- eye(3)
USL203 <- SS(F=f,H=h,Q=q,R=r,z0=c( 1, -5.7855694, -3.3173937, 1.6381057, -4.5741610, -0.5333017, 0.4163367),
output.names=c("US1","US2","US3"))
print(USL203)
is.SS(USL203)
stability(USL203)
# tfplot(simulate(USL203,sampleT=100))
USL203.data <- simulate(toSSinnov(USL203),sampleT=100,noise=matrix(0,100,3))
USL203.f <- forecast(m <- l(USL203,USL203.data),horizon=100)
tfplot(USL203.f)
AIC(m)
shockDecomposition(m)
#WL20.fx <- merge.forecast(WL203.f)
#tfplot(WL20.fx)