# Cut-and-Paste code below into window above and Run
#
# W_GD Model
#
# Measurement Matrix (Growth-XREAL), (Growth-T), (T+XREAL-L)
#
# Q N XREAL X L T
#[1,] 0.39338 0.4707 -0.2323 0.46143 0.47431 0.3631
#[2,] 0.51402 0.1459 0.7424 0.01118 0.08417 -0.3951
#[3,] 0.03753 -0.1915 0.4775 -0.02297 -0.21876 0.8280
#
# Fraction of Variance
#[1] 0.7170 0.9251 0.9822 1.0000 1.0000 1.0000
#
merge.forecast <- function (fx,n=1) {
#
# Merges a forecast with the outputdata
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( 1.002900989, -0.01221580, -0.3389237, 0.11196869,
0.089905713, 1.06700279, 0.3800768, 0.07620913,
-0.001940628, 0.07357085, 0.2758457, -0.02539065,
0.00000000, 0.0000000, 0.0000000, 1.0000000000
),byrow=TRUE,nrow=4,ncol=4)
#
# To Stabilize
# Uncomment next line
# f[1,1] <- 0.944211373; f[2,2] <- 1.00456195; f[3,3] <- 0.2597032
#
h <- eye(3,4)
k <- (f[,1:3,drop=FALSE])
W_GD <- SS(F=f,H=h,K=k,z0=c(0.11196869, 0.07620913, -0.02539065, 1.0000000000),
output.names=c("W1","W2","W3"))
print(W_GD)
is.SS(W_GD)
stability(W_GD)
# tfplot(simulate(W_GD,sampleT=100))
W_GD.data <- simulate(W_GD,sampleT=50,noise=matrix(0,20,3),start=1900)
W_GD.f <- forecast(l(W_GD,W_GD.data),horizon=150)
tfplot(W_GD.f)
AIC(l(W_GD,W_GD.data))
W_GDx <- SS(F=f,H=h,Q=eye(4,3),R=eye(3,3),z0=c(0.11196869, 0.07620913, -0.02539065, 1.0000000000),
output.names=c("W1","W2","W3"))
shockDecomposition(W_GDx,horizon=10,shock=rep(-1,10))