Learn R Programming

nimble (version 1.2.1)

summaryLaplace: Summarize results from Laplace or adaptive Gauss-Hermite quadrature approximation

Description

Process the results of the `findMLE` method of a nimble Laplace or AGHQ approximation into a more useful format.

Usage

summaryLaplace(
  laplace,
  MLEoutput,
  originalScale = TRUE,
  randomEffectsStdError = FALSE,
  jointCovariance = FALSE
)

summaryAGHQ( AGHQ, MLEoutput, originalScale = TRUE, randomEffectsStdError = FALSE, jointCovariance = FALSE )

Value

A list with data frames `params` and `randomEffects`, each with columns for `estimate` and (possibly) `se` (standard error) and row names for model nodes, a matrix `vcov` with the covariance matrix with row and column names, and `originalScale` with the input value of `originalScale` so it is recorded for later use if wanted.

Arguments

laplace

The Laplace approximation object, typically the compiled one. This would be the result of compiling an object returned from `buildLaplace`.

MLEoutput

The maximum likelihood estimate using Laplace or AGHQ, returned from e.g. `approx$findMLE(...)`, where approx is the algorithm object returned by `buildLaplace` or `buildAGHQ`, or (more typically) the result of compiling that object with `compileNimble`. See `help(buildLaplace)` for more information.

originalScale

Should results be returned using the original parameterization in the model code (TRUE) or the potentially transformed parameterization used internally by the Laplace approximation (FALSE). Transformations are used for any parameters and/or random effects that have constrained ranges of valid values, so that in the transformed parameter space there are no constraints.

randomEffectsStdError

If TRUE, calculate the standard error of the estimates of random effects values.

jointCovariance

If TRUE, calculate the joint covariance matrix of the parameters and random effects together. If FALSE, calculate the covariance matrix of the parameters.

AGHQ

Same as laplace. Note that `buildLaplace` and `buildAGHQ` create the same kind of algorithm object that can be used interchangeably. `buildLaplace` simply sets the number of quadrature points (`nQuad`) to 1 to achieve Laplace approximation as a special case of AGHQ.

Details

The numbers obtained by this function can be obtained more directly by `approx$summary(...)`. The added benefit of `summaryLaplace` is to arrange the results into data frames (for parameters and random effects), with row names for the model nodes, and also adding row and column names to the covariance matrix.