This can be called to fit a DFA with his syntax, but generally no work should be done here.
dfaTMB(
y,
model = list(m = 1, R = "diagonal and equal"),
inits = list(R = 0.05),
EstCovar = FALSE,
Covars = NULL,
indivCovar = FALSE,
Dmat = NULL,
Dfac = NULL,
EstSE = FALSE,
silent = TRUE,
fun.opt = c("nlminb", "optim", "nlminb+optim"),
method = c("Nelder-Mead", "BFGS", "CG", "L-BFGS-B", "SANN", "Brent"),
control = NULL,
form = c("dfa", "marxss")
)
Vector of observations n x T.
list with
R "diagonal and equal", "unconstrained", "diagonal and unequal"
m number of states (x)
list of initial conditions
TRUE/FALSE
An optional matrix, dimensioned nD x T, where nD is the number of covariates
flag for structure of covariates
D initial matrix
What elements of D are fixed
TRUE / FALSE, whether to return the Hessian from the TMB sdreport
Show TMB output when fitting, defaults to TRUE
function to use for optimization: stats::nlminb()
or stats::optim()
to pass to optim call; ignored for fun="nlminb"
a list with the control settings for the optimatization function. See details for the defaults.
The equation form used in the marssTMB() call. The default is "dfa".
A list with Optimization, Estimates, Fits, and AIC
The control defaults for stats::nlminb()
are iter.max = 2000
and eval.max = 2000
.
For stats::optim()
, the defaults are reltol = 1e-12
and maxit = 2000
.
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
m1.em <- MARSS(dat, model=list(R='unconstrained', m=1, tinitx=1), form='dfa', z.score=FALSE)
#> Success! abstol and log-log tests passed at 449 iterations.
#> Alert: conv.test.slope.tol is 0.5.
#> Test with smaller values (<0.1) to ensure convergence.
#>
#> MARSS fit is
#> Estimation method: kem
#> Convergence test: conv.test.slope.tol = 0.5, abstol = 0.001
#> Estimation converged in 449 iterations.
#> Log-likelihood: -772.4017
#> AIC: 1584.803 AICc: 1586.264
#>
#> Estimate
#> Z.11 0.1158
#> Z.21 0.1239
#> Z.31 0.0898
#> Z.41 0.3919
#> Z.51 -0.1652
#> R.(1,1) 0.9364
#> R.(2,1) 0.3157
#> R.(3,1) 0.1475
#> R.(4,1) 0.2863
#> R.(5,1) 0.2006
#> R.(2,2) 0.9284
#> R.(3,2) -0.0404
#> R.(4,2) 0.0636
#> R.(5,2) -0.0233
#> R.(3,3) 0.9641
#> R.(4,3) 0.0314
#> R.(5,3) 0.2919
#> R.(4,4) 0.3587
#> R.(5,4) 0.2605
#> R.(5,5) 0.8792
#> Initial states (x0) defined at t=1
#>
#> Standard errors have not been calculated.
#> Use MARSSparamCIs to compute CIs and bias estimates.
#>
m1.tmb <- dfaTMB(dat, model=list(R='unconstrained', m=1))
c(m1.em$logLik, m1.tmb$logLik)
#> [1] -772.4017 -772.4011