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,
  ...
)

Arguments

y

Vector of observations n x T.

model

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

inits

list of initial conditions

miss.value

A parameter for backcompatibility. Not used.

method

"TMB" (default), "nlminb.TMB", or "BFGS.TMB". See details.

form

The equation form used in the marssTMB() call. The default is "dfa".

fit

Whether to fit the model.

silent

Show output when fitting

control

list for the optimization function. See stats::nlminb() or stats::optim() for the options.

...

Extra parameters. Not used.

Value

A MARSS::marssMLE object

Details

Note in the development version of MARSS() on GitHub, you can use MARSS() as normal.

Author

Eli Holmes

Examples

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