Learn R Programming

OpenMx (version 2.21.13)

mxSE: Compute standard errors in OpenMx

Description

This function allows you to obtain standard errors for arbitrary expressions, named entities, and algebras.

Usage

mxSE(
  x,
  model,
  details = FALSE,
  cov,
  forceName = FALSE,
  silent = FALSE,
  ...,
  defvar.row = as.integer(NA),
  data = "data"
)

Value

SE value(s) returned as a matrix when details is FALSE. When details is TRUE, a list of the SE value(s) and the full sampling covariance matrix.

Arguments

x

the parameter to get SEs on (reference or expression)

model

the mxModel to use.

details

logical. Whether to provide further details, e.g. the full sampling covariance matrix of x.

cov

optional matrix of covariances among the free parameters. If missing, the inverse Hessian from the fitted model is used.

forceName

logical; defaults to FALSE. Set to TRUE if x is an R symbol that refers to a character string.

silent

logical; defaults to FALSE. If TRUE, message-printing is suppressed.

...

further named arguments passed to mxEval

defvar.row

which row to load for any definition variables

data

name of data from which to load definition variables

Details

x can be the name of an algebra, a bracket address, named entity or arbitrary expression. When the details argument is TRUE, the full sampling covariance matrix of x is also returned as part of a list. The square root of the diagonals of this sampling covariance matrix are the standard errors.

When supplying the cov argument, take care that the free parameter covariance matrix is given, not the information matrix. These two are inverses of one another.

This function uses the delta method to compute the standard error of arbitrary and possibly nonlinear functions of the free parameters. The delta method makes a first-order Taylor approximation of the nonlinear function. The nonlinear function is a map from all the free parameters to some transformed subset of parameters: the linearization of this map is given by the Jacobian \(J\). In equation form, the delta method computes standard errors by the following:

$$J^T C J$$

where \(J\) is the Jacobian of the nonlinear parameter transformation and \(C\) is the covariance matrix of the free parameters (e.g., two times the inverse of the Hessian of the minus two log likelihood function).

References

- https://en.wikipedia.org/wiki/Standard_error

See Also

- mxCI

Examples

Run this code
library(OpenMx)
data(demoOneFactor)
# ===============================
# = Make and run a 1-factor CFA =
# ===============================

latents  = c("G") # the latent factor
manifests = names(demoOneFactor) # manifest variables to be modeled
# ===========================
# = Make and run the model! =
# ===========================
m1 <- mxModel("One Factor", type = "RAM", 
	manifestVars = manifests, latentVars = latents, 
	mxPath(from = latents, to = manifests, labels=paste0('lambda', 1:5)),
	mxPath(from = manifests, arrows = 2),
	mxPath(from = latents, arrows = 2, free = FALSE, values = 1),
	mxData(cov(demoOneFactor), type = "cov", numObs = 500)
)
m1 = mxRun(m1)
mxSE(lambda5, model = m1)
mxSE(lambda1^2, model = m1)

Run the code above in your browser using DataLab