# Cut-and-paste code below into window above and Run
#
# United Kingdom (UK) Model (1950-2000)
#
#
#Measurement Matrix (Growth) (HOURS) (X-N)
#
# Q N U HOURS XREAL X L
#[1,] 0.4121 0.3976 0.4107 0.1339 0.4055 0.39230 0.409
#[2,] -0.0721 -0.0962 -0.0936 0.9871 -0.0476 -0.00396 -0.012
#[3,] -0.0455 -0.5402 -0.1348 -0.0507 0.3950 0.66143 -0.303
#
# Fraction of Variance
#[1] 0.837 0.968 1.000 1.000 1.000 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( 1.00544958, 0.006285156, -0.09808932, 0.149479839,
-0.02516952, 1.050391146, -0.44954346, -0.099299692,
0.02889187, 0.005627003, 1.01925177, 0.007017427,
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] <- .98
#
h <- eye(3,4)
k <- (f[,1:3,drop=FALSE])
UK_LM <- SS(F=f,H=h,K=k,z0=c(0.149479839, -0.099299692, 0.007017427, 1.0000000000),
output.names=c("UK1","UK2","UK3"))
print(UK_LM)
is.SS(UK_LM)
stability(UK_LM)
UK_LM.data <- simulate(UK_LM,sampleT=100,start=1950)
#UK_LM.data <- simulate(UK_LM,sampleT=100,noise=matrix(0,100,3),start=1950)
UK_LM.f <- forecast(l(UK_LM,UK_LM.data),horizon=150)
UK_LM.fx <- merge.forecast(UK_LM.f)
tfplot(UK_LM.f)
AIC(m <- l(UK_LM,UK_LM.data))
UK_LMx <- SS(F=f,H=h,Q=eye(4,3),R=eye(3,3),z0=c(0.149479839, -0.099299692, 0.007017427, 1.0000000000),
output.names=c("UK1","UK2","UK3"))
shockDecomposition(UK_LMx)