#
# Malthus Basic Population Model Model
# Cut and paste this code into the window above and Run (Cmd-Enter)
#
merge.forecast <-
function (fx,n=1) {
# Merges a forecast with the outputdata
x <- splice(fx$pred,fx$forecast[[n]])
colnames(x) <- seriesNames(fx$data$output)
return(x)
}
require(dse)
require(matlab)
#
AIC <- function(model) {informationTestsCalculations(model)[3]}
f <- matrix( c( 1.040323e+00, 0.009051444, 0.06349123,
0.000000000, 1.000000000, 0.05000000,
0.000000e+00, 0.000000000, 1.00000000
),byrow=TRUE,nrow=3,ncol=3)
h <- eye(2,3)
k <- f[1:3,1:2,drop=FALSE]
Malthus <- SS(F=f,H=h,K=k,z0=c( 0.06349123, 0.05000000, 1.0000000),
output.names=c("N","QA"))
stability(Malthus)
shockDecomposition(toSSChol(Malthus))
tfplot(simulate(Malthus,sampleT=50,noise=matrix(0,50,2),start=1))
Malthus.data <- simulate(Malthus,sampleT=50,start=1)
m <- l(Malthus,Malthus.data)
#tfplot(m)
Malthus.f <- forecast(m,horizon=50)
tfplot(Malthus.f)
AIC(m)