#
# UK_L16_ES Model (1450-1640) Cut-and-paste code below into window above and Run
#
# ES_L16 Model (1450-1640)
#
#
# Measurement Matrix (Growth-X), (Q+U+X-N), (N+X-Q)
# Q N U X
#[1,] 0.498 0.503 0.5025 -0.4966
#[2,] 0.600 -0.304 0.3523 0.6507
#[3,] -0.193 0.796 -0.0414 0.5717
#
# Fraction of Variance
#[1] 0.981 1.000 1.000 1.000
#
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.9938492938, 0.028443301, -0.08335018, 0.032501513,
-0.0048445979, 1.017269161, -0.05759700, -0.002428944,
0.0001853692, 0.004889928, 0.99132122, -0.000631717,
0.00000000, 0.0000000, 0.0000000, 1.0000000000
),byrow=TRUE,nrow=4,ncol=4)
h <- eye(3,4)
k <- (f[,1:3,drop=FALSE])
ESL16 <- SS(F=f,H=h,K=k,z0=c( 0.032501513, -0.002428944, -0.000631717 , 1.0000000000),
output.names=c("ES1","ES2","ES3"))
ESL16.data <- simulate(ESL16,sampleT=190,start=1450)
ESL16.f <- forecast(l(ESL16,ESL16.data),horizon=150)
ESL16.fx <- merge.forecast(ESL16.f)
#
# UK_L16 Model ES Input (1450-1640)
#
#
# Measurement Matrix # Growth-X, U-N, Q-N-X
# Q N U X
#[1,] 0.510 0.503 0.479 -0.508
#[2,] -0.142 -0.426 0.859 0.247
#[3,] 0.450 -0.752 -0.168 -0.452
#
# Fraction of Variance
#[1] 0.96 1.00 1.00 1.00
#
f <- matrix( c(0.5078867, 0.07949263, -0.7339109, 0.018032933,
-0.2053840, -0.09023941, 0.5603686, -0.007263594,
-0.1531395, -0.18083384, 0.9330224, -0.005309341,
0.00000000, 0.0000000, 0.0000000, 1.0000000000
),byrow=TRUE,nrow=4,ncol=4)
g <- matrix(c(0.4749698, 0.8551157, -1.1056952,
0.1324260, 1.9184554, -0.8385147,
0.1333004, 0.5477030, -0.4094271,
0.0000000, 0.0000000, 0.0000000
),byrow=TRUE,nrow=4,ncol=3)
h <- eye(3,4)
k <- (f[,1:3,drop=FALSE])
UKL16 <- SS(F=f,H=h,G=g,K=k,z0=c( 0.054495491, 0.012007950, 0.006594153, 1.0000000000),
output.names=c("UK1","UK2","UK3"))
UKL16x <- SS(F=f,H=h,K=k,z0=c( 0.054495491, 0.012007950, 0.006594153, 1.0000000000),
output.names=c("UK1","UK2","UK3"))
print(UKL16)
is.SS(UKL16)
stability(UKL16)
#UKL16.data <- simulate(UKL16x,sampleT=191,start=1450)
UKL16.data <- simulate(UKL16,sampleT=191,start=1450,input=window(ESL16.fx,start=1450,end=1640))
data <- TSdata(output=outputData(UKL16.data),input=window(ESL16.fx,start=1450,end=1640))
UKL16.f <- forecast(l(UKL16,data),conditioning.inputs=ESL16.fx)
tfplot(UKL16.f)
AIC(m <- l(UKL16,data))
shockDecomposition(toSSChol(m))