Learn R Programming

OpenMx (version 2.2.2)

mxComputeNumericDeriv: Numerically estimate Hessian using Richardson extrapolation

Description

For N free parameters, Richardson extrapolation requires (iterations * (N^2 + N)) function evaluations.

Usage

mxComputeNumericDeriv(freeSet = NA_character_, ...,
  fitfunction = "fitfunction", parallel = TRUE, stepSize = 1e-04,
  iterations = 4L, verbose = 0L, knownHessian = NULL)

Arguments

freeSet
names of matrices containing free variables
...
Not used. Forces remaining arguments to be specified by name.
fitfunction
name of the fitfunction (defaults to 'fitfunction')
parallel
whether to evaluate the fitfunction in parallel (defaults to TRUE)
stepSize
starting set size (defaults to 0.0001)
iterations
number of Richardson extrapolation iterations (defaults to 4L)
verbose
Level of debugging output.
knownHessian
an optional matrix of known Hessian entries

Details

The implementation is closely based on the numDeriv R package.

Examples

Run this code
library(OpenMx)
data(demoOneFactor)
factorModel <- mxModel(name ="One Factor",
	mxMatrix(type = "Full", nrow = 5, ncol = 1, free = FALSE, values = .2, name = "A"),
	mxMatrix(type = "Symm", nrow = 1, ncol = 1, free = FALSE, values = 1 , name = "L"),
	mxMatrix(type = "Diag", nrow = 5, ncol = 5, free = TRUE , values = 1 , name = "U"),
	mxAlgebra(A %*% L %*% t(A) + U, name = "R"),
	mxExpectationNormal(covariance = "R", dimnames = names(demoOneFactor)),
	mxFitFunctionML(),
	mxData(cov(demoOneFactor), type = "cov", numObs = 500),
	mxComputeSequence(
		list(mxComputeNumericDeriv(), mxComputeReportDeriv())
	)
)
factorModelFit <- mxRun(factorModel)
factorModelFit$output$hessian

Run the code above in your browser using DataLab