# Cut-and-Paste code below into window above and Run
#
# US_GD Model
#
# Measurement Matrix (Growth) (Hours+XREAL-X-Q) (Q+HOURS-XREAL-X)
# Q N HOURS XREAL X L
#[1,] 0.4041 0.414833 0.3981 0.4123 0.4053 0.41454
#[2,] -0.4774 0.009769 0.7037 0.2063 -0.4818 0.04558
#[3,] 0.7410 0.035540 0.2377 -0.2841 -0.5259 -0.18943
#
# Fraction of Variance
#[1] 0.9684 0.9939 0.9988 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.008952716, -0.04339303, 0.01050584, 0.17033656,
-0.016091116, 0.93613443, 0.17244557, 0.01340404,
0.009518643, -0.08083774, 1.13854519, 0.01724704,
0.00000000, 0.0000000, 0.0000000, 1.0000000000
),byrow=TRUE,nrow=4,ncol=4)
#
# To Stabilize
# Uncomment next line
# f[1,1] <- 0.959503994; f[2,2] <- 0.89025453; f[3,3] <- 1.08274514
#
h <- eye(3,4)
k <- (f[,1:3,drop=FALSE])
US_GD <- SS(F=f,H=h,K=k,z0=c(0.17033656, 0.01340404, 0.01724704, 1.0000000000),
output.names=c("US1","US2","US3"))
print(US_GD)
is.SS(US_GD)
stability(US_GD)
US_GD.data <- simulate(US_GD,sampleT=50,start=1900)
#US_GD.data <- simulate(US_GD,sampleT=50,noise=matrix(0,50,3),start=1900)
US_GD.f <- forecast(m <- l(US_GD,US_GD.data),horizon=150)
tfplot(US_GD.f)
AIC(m)
US_GDx <- SS(F=f,H=h,Q=eye(4,3),R=eye(3,3),z0=c(0.17033656, 0.01340404, 0.01724704,1.0000000000),
output.names=c("US1","US2","US3"))
shockDecomposition(US_GDx,horizon=10,shock=rep(-1,10))