Fit a MARSS model with TMB + optimization. TMB does fast computation of the
likelihood gradients and this is used
with stats::nlminb()
or stats::optim()
to optimize the likelihood. The
former is much faster than the later and is the default.
MARSS.tmb(
y,
model = NULL,
inits = NULL,
miss.value = as.numeric(NA),
method = "TMB",
form = "dfa",
fit = TRUE,
silent = FALSE,
control = NULL,
...
)
Vector of observations n x T.
list with
R "diagonal and equal", "unconstrained", "diagonal and unequal"
m the number of states (factors). default is 1
list of initial conditions
to pass to optim call; ignored for fun="nlminb"
The equation form used in the marssTMB() call. The default is "dfa".
Whether to fit the model.
Show TMB output when fitting
list for the optimization function. stats::nlminb()
or stats::optim()
, control$fun.opt
allows you to choose optim or nlminb as the optimization function. control$optim.method
allows you to choose method for optim()
.
A list with Optimization, Estimates, Fits, and AIC
Note. Goal is to have the user call with the MARSS package as
MARSS(y, method="tmb")
, which then calls MARSStmb()
. This is the mimics
the behavior of method="BFGS"
and method="kem"
in MARSS::MARSS()
which
looks for a fitting function called MARSSxyz
, where xyz
is the method.
Further arguments for the optimization method can be passed into control
.
library(MARSS)
data(lakeWAplankton, package = "MARSS")
phytoplankton <- c("Cryptomonas", "Diatoms", "Greens", "Unicells", "Other.algae")
dat <- as.data.frame(lakeWAplanktonTrans) |>
subset(Year >= 1980 & Year <= 1989) |>
subset(select=phytoplankton) |>
t() |>
MARSS::zscore()
#fit with MARSS
fit <- MARSS.tmb(dat, model=list(m=3))