This function was the first working version and used a
non-vectorized marxss form (aka the form you would write out on paper).
It is replaced by estimate_marss()
but is kept here because the
code might be easier to follow.
estimate_marxss(MLEobj)
A properly formatted MARSS model as output by MARSS_tmb()
A MARSS::marssMLE object
Minimal error checking is done in this function.
Normal calling function is MARSS_tmb()
which in
turn calls this function. Note when MARSS is updated, the
normal calling function will be MARSS::MARSS()
. Restrictions
No time-varying parameters
Currently only DFA models are coded up
x0 and V0 fixed (stochastic prior)
Q is fixed (not estimated)
This function returns MARSS::marssMLE object. For the iter.record
element
of the object, the following are returned as a list:
obj.function
is the raw output from the TMB::MakeADFun()
call.
opt.output
is the raw output from the optimization call (optim or nlminb)
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()
# set-up the model
mod <- MARSS_tmb(dat, model=list(m=3, tinitx=1), form="dfa", fit=FALSE)
# fit
fit <- estimate_marxss(mod)
#> 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