Calculates the Hessian, varcov matrix and s.e. of an Apollo model as defined buy its likelihood function and apollo_inputs list of settings. Performs automatic scaling for increased numeric stability.
apollo_varcov(apollo_beta, apollo_fixed, varcov_settings)
Named numeric vector. Names and values of parameters at which to calculate the covariance matrix. Values _must not be scaled_, and they must include any fixed parameter.
Character vector. Names of fixed parameters.
List of settings defining the behaviour of this function. It must contain at least one of teh following: apollo_logLike, apollo_grad or apollo_inputs.
hessianRoutine: Character. Name of routine used to calculate
the Hessian. Valid values are "analytic"
,
"numDeriv"
, "maxLik"
or "none"
to avoid estimating the Hessian and covariance matrix.
scaleBeta: Logical. If TRUE (default), parameters are scaled by their
own value before calculating the Hessian to increase numerical
stability. However, the output is de-scaled, so they are in
the same scale as the apollo_beta
argument.
numDeriv_settings: List. Additional arguments to the Richardson method
used by numDeriv to calculate the Hessian. See
argument method.args
in grad
for more details.
apollo_logLike: Function to calculate the loglikelihood of the model, as returned by apollo_makeLogLike.
apollo_grad: Function to calculate the gradient of the model, as returned by apollo_makeGrad.
apollo_probabilities: Function. Likelihood function of the model. Must receive three arguments:
apollo_beta: Named numeric vector.
apollo_inputs: List of settings.
functionality: Character.
apollo_inputs: List of inputs to estimate a model, as returned by apollo_validateInputs.
List with the following elements
hessian: Numerical matrix. Hessian of the model at parameter estimates (model$estimate
).
varcov: Numerical matrix. Variance-covariance matrix.
se: Named numerical vector. Standard errors of parameter estimates.
corrmat: Numerical matrix. Correlation between parameter estimates.
robvarcov: Numerical matrix. Robust variance-covariance matrix.
robse: Named numerical vector. Robust standard errors of parameter estimates.
robcorrmat: Numerical matrix. Robust correlation between parameter estimates.
apollo_beta: Named numerical vector. Parameter estimates (model$estimate
, not scaled).
methodUsed: Character. Name of method used to calculate the Hessian.
methodsAttempted: Character vector. Name of methods attempted to calculate the Hessian.
hessianScaling: Named numeric vector. Scales used on the paramaters to calculate the Hessian (non-fixed only).
It calculates the Hessian, variance-covariance, and standard errors at apollo_beta
values of an
estimated model. At least one of the following settings must be provided (ordered by speed): apollo_grad
,
apollo_logLike
, or (apollo_probabilities
and apollo_inputs
). If more than one is provided,
then the priority is: apollo_grad
, apollo_logLike
, (apollo_probabilities
and apollo_inputs
).