gllvmTMB() computes a TMB TMB::sdreport() at fitting time unless it is
told not to (control = gllvmTMBcontrol(se = FALSE)). Skipping it is
substantially faster, but it used to be a one-way door: the only way to get
standard errors afterwards was to fit the model again. standard_errors()
removes that door by computing the same sdreport() on demand from the
fitted object.
Arguments
- fit
A fitted multivariate model returned by
gllvmTMB().
Value
The same fit, with its sd_report field populated (and
sdreport_error cleared). Standard-error consumers such as
summary.gllvmTMB_multi(), getLV(), getREsd(), and
confint(method = "wald") work on the returned object.
R semantics matter here: the fit is returned, not modified in place.
Assign the result – fit <- standard_errors(fit) – or the standard
errors are discarded.
If the fit already has an sd_report, it is returned unchanged; the
calculation is not repeated.
Details
Fits made with non-unit likelihood weights use a weighted objective rather
than an ordinary likelihood. standard_errors() refuses those fits because
the package does not yet provide sandwich-calibrated uncertainty for them;
point estimates remain available from the fitted model.
When this helps
The saving is real but bounded: it is worth using when a workflow fits many
models and needs standard errors for only some of them (model selection,
simulation loops, a grid of candidate structures). For a single fit whose
summary you intend to read, the default se = TRUE is simpler and costs
nothing extra.
Same-session only
A TMB ADFun object holds external pointers into compiled memory. Those
pointers do not survive saveRDS() / readRDS() or a new R session, so
standard_errors() can only be called on a fit made in the current
session. This is a pre-existing property of every function in this package
that reuses fit$tmb_obj (profiling, bootstrapping, getLV()), not a new
restriction – but this function names it with a clear error rather than
failing obscurely. If you need standard errors from a saved fit, refit it
with se = TRUE.
What these standard errors are
Exactly the ones the fit would have produced at fitting time – the same
TMB sdreport() call, on the same converged parameter vector, to the bit.
Deferring the calculation does not change it, and does not change any
honesty caveat that already applies to Wald standard errors from this
package.
See also
gllvmTMBcontrol() for the se argument that defers the
calculation; getREsd() and getLV() for accessors that read the
resulting sd_report.
