#
# Smith Exponential Growth (Cut and paste code into window above and Run (Cmd-Enter)
#
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.7812470, 0.3255224, -0.1022999, 0.028117500,
-0.2466271,0.9, -0.1827155, 0.023367413,
-0.5330617, 0.6412153, 0.8753853, 0.008156255,
0.00000000, 0.0000000, 0, 1.0000000000
),byrow=TRUE,nrow=4,ncol=4)
#
# To stabilize the model, uncomment following line
# f[1,1] <- 0.7281732; f[2,2] <- 1.3319361; f[3,3] <- 0.8159163
# To create unstable cyclical growth, uncomment following line
# f[2,2] <- 1.4290158
#
h <- eye(3,4)
k <- (f[,1:3,drop=FALSE])
Smith <- SS(F=f,H=h,K=k,z0=c(0.028117500, 0.023367413, 0.008156255, 1.0000000000),
output.names=c("Smith1","Smith2","Smith3"))
print(Smith)
is.SS(Smith)
stability(SS(F=f[1:3,1:3,drop=FALSE],H=eye(3),Q=eye(3),R=eye(3)))
# tfplot(simulate(Smith,sampleT=100))
Smith.data <- simulate(Smith,sampleT=100,noise=matrix(0,100,3))
Smith.f <- forecast(l(Smith,Smith.data),horizon=150)
tfplot(Smith.f)
AIC(l(Smith,Smith.data))