Skip to contents

A wrapper function to return standard errors. Various numerical techniques are employed to obtain a positive-definite covariance matrix in marginal cases.

Usage

get_sdreport(
  obj,
  par.fixed,
  exact = FALSE,
  getReportCovariance = FALSE,
  silent = FALSE,
  ...
)

Arguments

obj

The list returned by RTMB::MakeADFun()

par.fixed

Numeric vector of parameters from which to calculate covariance matrix. Optional

exact

Logical, whether to use autodiff or finite-difference approximation for the hessian. See details.

getReportCovariance

Logical, passed to RTMB::sdreport()

silent

Logical, whether to report progress to console. See details.

...

Other arguments to RTMB::sdreport() besides par.fixed, hessian.fixed, getReportCovariance

Value

Object returned by RTMB::sdreport().

A correlation matrix is generated and stored in: get_sdreport(obj)$env$corr.fixed

The hessian is stored in get_sdreport(obj)$env$hessian

Details

Uses stats::optimHess() if exact = FALSE. Autodiff with exact = TRUE is only available for TMB models without random effects, but is also memory-intensive.

In numerically marginal cases where the determinant of the Hessian matrix is less than 0.1, the function will attempt to calculate the hessian with numDeriv::jacobian() and the gradient from TMB.

Finally, in other marginal cases where chol() identifies a positive-definite Hessian but solve() fails to invert the matrix, the covariance matrix will be updated with chol2inv(chol(h))