# (Cut-and-Paste Code into Window Above and Run (Cmd-Enter)
#
# DEL19 Model (1872-1907)
#
# Measurement Matrix
# Q L I K W N
#[1,] 0.4293 0.4218 0.38667 0.425 0.4298 0.35000
#[2,] -0.0535 -0.0636 -0.48407 -0.122 -0.0301 0.86200
#[3,] 0.0101 -0.4686 0.73404 -0.342 -0.1366 0.32515
#[4,] 0.7117 -0.5167 -0.27761 -0.146 0.3204 -0.15934
#[5,] -0.5500 -0.3884 0.00128 0.234 0.7013 -0.00447
#[6,] 0.0603 -0.4251 -0.01677 0.782 -0.4486 0.05763
#
# Fraction of Variance
#[1] 0.895 0.967 0.996 0.999 1.000 1.000
#
#
AIC <- function(model) {informationTestsCalculations(model)[3]}
require(dse)
require(matlab)
f <- matrix( c( 1.028709948, -0.15157849, -0.0969659, 0.216248062,
-0.037176740, 0.66612338, 0.4171702, 0.058414986,
0.005725789, -0.02203582, 0.7522939, -0.006697577,
0.00000000, 0.00000000, 0.0000000, 1.000000000
),byrow=TRUE,nrow=4,ncol=4)
#
# To Stabilize Model, uncomment next line
# f[1,1] <- 0.95
#
h <- eye(3,4)
k <- (f[,1:3,drop=FALSE])
DEL19C <- SS(F=f,H=h,K=k,z0=c( 0.216248062, 0.058414986, -0.006697577, 1.000000000),
output.names=c("DE1","DE2","DE3"))
print(DEL19C)
is.SS(DEL19C)
stability(SS(F=f[1:3,1:3,drop=FALSE],Q=eye(3),R=eye(3),H=eye(3)))
n <- 50
DEL19C.data <- simulate(DEL19C,sampleT=n,noise=matrix(0,n,3),start=1872)
DEL19C.data2 <- simulate(DEL19C,sampleT=n,start=1)
tfplot(DEL19C.data)
AIC(l(DEL19C,DEL19C.data))
tfplot(DEL19C.data2)
shockDecomposition(toSSChol(DEL19C))
#
# DEL19 Controlled Model W Input Held Constant
#
f <- matrix( c( 0.2568621, 0.06170521, 0.3612876, -0.002867862,
-0.2835427, 0.60782446, 0.7004361, 0.008146236,
-0.5108574, 0.14733003, 0.9090658, -0.159315011,
0.00000000, 0.00000000, 0.0000000, 1.000000000
),byrow=TRUE,nrow=4,ncol=4)
DEL19CW <- SS(F=f,H=h,K=k,z0=c( -1.668745, -0.614395, -1.068699, 1.000000000),
output.names=c("DE1","DE2","DE3"))
print(DEL19CW)
is.SS(DEL19CW)
stability(SS(F=f[1:3,1:3,drop=FALSE],Q=eye(3),R=eye(3),H=eye(3)))
n <- 150
DEL19CW.data <- simulate(DEL19CW,sampleT=n,noise=matrix(0,n,3),start=1872)
DEL19CW.data2 <- simulate(DEL19CW,sampleT=n,start=1872)
tfplot(DEL19CW.data)
AIC(l(DEL19CW,DEL19CW.data))
tfplot(DEL19CW.data2)
shockDecomposition(toSSChol(DEL19CW))