# Cut-and-paste code below into window above and Run
#
# Japan (JP) Model (1950-2000)
#
#
#Measurement Matrix (Growth) (XREAL-HOURS) (HOURS + XREAL - N - U)
#
# Q N U HOURS XREAL L
#[1,] 0.4120 0.411 0.412 0.402 0.400 0.412
#[2,] 0.1811 -0.194 0.122 -0.638 0.694 -0.161
#[3,] -0.0347 -0.563 -0.290 0.620 0.439 -0.143
#
# Fraction of Variance
#
#Fraction of Variance
#[1] 0.995 1.000 1.000
#
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)
f <- matrix( c( 0.9946733059, -0.06609345, -0.06755142, 0.15827394,
0.0224205739, 1.06706048, 0.04207700, 0.01267197,
-0.0002452678, -0.06837779, 0.99535499, -0.01042065,
0.00000000, 0.0000000, 0.0000000, 1.0000000000
),byrow=TRUE,nrow=4,ncol=4)
#
# To stabilize model, uncomment next line
# f[1,1] <- f[2,2] <- f[3,3] <- .9
#
#
h <- eye(3,4)
k <- (f[,1:3,drop=FALSE])
JP_LM <- SS(F=f,H=h,K=k,z0=c(0.15827394, 0.01267197 , -0.01042065, 1.0000000000),
output.names=c("JP1","JP2","JP3"))
print(JP_LM)
is.SS(JP_LM)
stability(JP_LM)
JP_LM.data <- simulate(JP_LM,sampleT=100,start=1950)
#JP_LM.data <- simulate(JP_LM,sampleT=100,noise=matrix(0,100,3),start=1950)
JP_LM.f <- forecast(l(JP_LM,JP_LM.data),horizon=150)
JP_LM.fx <- merge.forecast(JP_LM.f)
tfplot(JP_LM.f)
AIC(m <- l(JP_LM,JP_LM.data))
JP_LMx <- SS(F=f,H=h,Q=eye(4,3),R=eye(3,3),z0=c(0.15827394, 0.01267197 , -0.01042065, 1.0000000000),
output.names=c("JP1","JP2","JP3"))
shockDecomposition(JP_LMx)