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 = c("TMB", "BFGS.TMB", "nlminb.TMB"),
form = c("marxss", "dfa"),
fit = TRUE,
silent = FALSE,
control = NULL,
...
)
Vector of observations n x T.
list with
R "diagonal and equal", "unconstrained", "diagonal and unequal"
tinitx = 1 (must be)
(if form="dfa") m the number of states (factors). default is 1
list of initial conditions
A parameter for backcompatibility. Not used.
"TMB" (default), "nlminb.TMB", or "BFGS.TMB". See details.
The equation form used in the marssTMB() call. The default is "dfa".
Whether to fit the model.
Show output when fitting
list for the optimization function. See stats::nlminb()
or stats::optim()
for the options.
Extra parameters. Not used.
A MARSS::marssMLE object
Note in the development version of MARSS() on GitHub, you can use MARSS()
as normal.
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, tinitx=1), form="dfa")
#> Error in if (!(class.x %in% c("marssMODEL", "marssMLE"))) { stop("Stopped in marss_to_marxss(): x$model must be a marssMODEL or marssMLE.", call. = FALSE)}: the condition has length > 1