#
# W_E20 Model2
#
#
# Cut-and-Paste Code below into window above and Run
#
# Measurement Matrix # (Growth-XREAL) (Growth-T) (T+XREAL-L) (X-N-L) (Q-N)
AIC <- function(model) {informationTestsCalculations(model)[3]}
merge.forecast <- function (fx,n=1) {
x <- splice(fx$pred,fx$forecast[[n]])
colnames(x) <- seriesNames(fx$data$output)
return(x)
}
require(dse)
require(matlab)
f <- matrix( c(0.999786547, -0.0240597379, -0.3345180161, 0.207659376, -0.01688057, 0.1078917882,
0.092242828, 1.0758906337, 0.3767707285, -0.090040603, 3.6556120, 0.0792684816,
-0.008180550, 0.0498409889, 0.2846727166, 0.412570476, -0.22675544, -0.0335588961,
-0.011326893, -0.0884080890, 0.1189274920, 0.992370576, 0.56004578, -0.0263901081,
0.000730758, 0.0003718024, 0.0008210908, -0.006695602, 0.89516022, -0.0001696577,
0.000000000, 0.0000000000, 0.0000000000, 0.000000000, 0.00000000, 1.0000000000
),byrow=TRUE,nrow=6,ncol=6)
h <- eye(5,6)
k <- (f[,1:5,drop=FALSE])
WE20 <- SS(F=f,H=h,K=k,z0=c(0.1078917882, 0.0792684816, -0.0335588961, -0.026390108, -0.0001696577, 1.0000000000),
output.names=c("W1","W2","W3","W4","W5"))
WE20.data <- simulate(WE20,sampleT=50,noise=matrix(0,50,5))
WE20.f <- forecast(l(WE20,WE20.data),horizon=50)
WE20.fx <- merge.forecast(WE20.f)
#
# USGD Model (require WE20.fx Input
#
# Measurement Matrix
# (Growth-IMM) (I + CPAPER + FED + EPR+ WPI + P.FUELS + W.AG - LU) (LU + TBILL + FED - W.AG - IMM - G)
# L.US.E. L.U. GNP.US. GNP.C. GNP.I. GNP.X. GNP.G. P.US.TBILL. P.CPAPER. P.FED.FUNDS.
#[1,] 0.2193 0.0343 0.21805 0.2201 0.1707 0.1955 0.1404 0.195 -0.1338 0.0264
#[2,] -0.0174 -0.2720 0.00525 0.0650 0.2130 0.1599 -0.0942 -0.139 0.3703 0.2991
#[3,] -0.0092 0.4216 -0.14585 -0.0515 -0.0263 -0.0649 -0.2549 0.243 0.0333 0.3847
# P.CPI. P.GDP. P.SP500. V.NYSE. P.S.P.DPR. P.S.P.EPR. Q.H.Starts. K.US. M1 M2
#[1,] 0.2070 0.2100 0.1479 0.102 0.194 0.0765 0.141 0.2065 0.2074 0.2157
#[2,] 0.1616 0.1439 0.0171 0.107 -0.195 0.3260 0.198 -0.0654 -0.0353 -0.0216
#[3,] 0.0685 0.0167 0.0910 0.331 0.144 0.0340 -0.124 0.2174 -0.2181 -0.1492
# P.WPI. Q.A. Q.I. O.B. P.FUELS. P.W.AG. P.W.MFG. Q.OIL. N.US. IMM.US. U.US.
#[1,] 0.1733 0.2131 0.2041 -0.0773 0.1561 0.2040 0.2217 0.215 0.2122 -0.151 0.2107
#[2,] 0.2417 -0.0695 -0.0759 0.3980 0.2611 0.0225 0.0201 -0.126 -0.0846 0.143 -0.0888
#[3,] -0.0686 -0.0571 -0.1577 0.1691 0.0666 -0.2419 -0.0734 0.021 0.1495 -0.248 0.1705
#
# Fraction of Variance
# [1] 0.637 0.774 0.855 0.904 0.937 0.958 0.970 0.978 0.984 0.990 0.993 0.996 0.997 0.998 0.998
#[16] 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 1.000 1.000
#[31] 1.000
#
f <- matrix( c( 0.3544726, 0.3316870, -0.4975584, 0.12595911,
-0.3948975, 1.0495071, -0.4709277, -0.06940087,
0.1579351, -0.2102125, 0.8347793, 0.04726658,
0.0000000000, 0.00000000, 0.00000000, 1.000000000
),byrow=TRUE,nrow=4,ncol=4)
g <- matrix(c(1.463459, -0.11438106, -0.957558941, -0.8949903, 27.198299,
0.818524, -0.08958345, -0.765236434, -1.2937936, 9.644429,
-0.406776, -0.23792079, 0.001331638, -1.2969812, -5.026620,
0.000000, 0.00000000, 0.000000000, 0.0000000, 0.000000
),byrow=TRUE,nrow=4,ncol=5)
h <- eye(3,4)
k <- (f[,1:3,drop=FALSE])
US20 <- SS(F=f,H=h,K=k,G=g,z0=c(-4.0239903, -3.0508434, 0.5239851, 1.0000000),
output.names=c("US1","US2","US3"),input.names=c("W1","W2","W3","W4","W5"))
US20.data <- simulate(US20,sampleT=50,noise=matrix(0,50,3),input=WE20.fx)
tfplot(outputData(US20.data))