A wrapper function to return standard errors. Various numerical techniques are employed to obtain a positive-definite covariance matrix.
Arguments
- obj
The list returned by
RTMB::MakeADFun()
- getReportCovariance
Logical, passed to
TMB::sdreport()
- silent
Logical, whether to report progress to console. See details.
- ...
Other arguments to
TMB::sdreport()
besidespar.fixed, hessian.fixed, getReportCovariance
Value
Object returned by TMB::sdreport()
. A correlation matrix is generated and stored in: get_sdreport(obj)$env$corr.fixed
Details
In marginal cases where the determinant of the Hessian matrix is less than 0.1, several steps are utilized to obtain a positive-definite covariance matrix, in the following order:
Invert hessian returned by
h <- obj@he(obj$env.last.par.best)
(skipped in models with random effects)Invert hessian returned by
h <- stats::optimHess(obj$env.last.par.best, obj$fn, obj$gr)
Invert hessian returned by
h <- numDeriv::jacobian(obj$gr, obj$env.last.par.best)
Calculate covariance matrix from
chol2inv(chol(h))