mxStandardizeRAMpaths: Standardize RAM models' path coefficients

View source: R/MxSummary.R

mxStandardizeRAMpathsR Documentation

Standardize RAM models' path coefficients

Description

Provides a dataframe containing the standardized values of all nonzero path coefficients appearing in the A and S matrices of models that use RAM expectation (either of type="RAM" or containing an explicit mxExpectationRAM() statement). These standardized values are what the path coefficients would be if all variables in the analysis–both manifest and latent–were standardized to zero mean and unit variance. If the means are being modeled in addition to the covariance structure, then the dataframe will also contain values of the nonzero elements of the M matrix after they have been re-scaled to standard deviation units. Can optionally include asymptotic standard errors for the standardized and re-scaled coefficients, computed via the delta method. Not intended for use with models that contain definition variables.

Usage

mxStandardizeRAMpaths(model,SE=FALSE,cov=NULL)

Arguments

model

An mxModel object, that either uses RAM expectation or contains at least one submodel that does.

SE

Logical. Should standard errors be included with the standardized point estimates? Defaults to FALSE. Certain conditions are required for use of SE=TRUE; see "Details" below.

cov

A repeated-sampling covariance matrix for the free-parameter estimates–say, from the robust "sandwich estimator," or from bootstrapping–used to calculate SEs for the standardized path coefficients. Defaults to NULL, in which case twice the inverse of the Hessian matrix at the ML solution is used. See below for details concerning concerning cases when model contains independent RAM submodels.

Details

Matrix A contains the Asymmetric paths, i.e. the single-headed arrows. Matrix S contains the Symmetric paths, i.e. the double-headed arrows. The function will work even if mxMatrix objects named "A" and "S" are absent from the model, since it identifies which matrices in the model have been assigned the roles of A and S in the mxExpectationRAM statement. Note that, in models of type="RAM", the necessary matrices and expectation statement are automatically assembled from the mxPath objects. If present, the M matrix will contain the means of exogenous variables and the intercepts of endogenous variables.

If model contains any submodels with independent=TRUE that use RAM expectation, mxStandardizeRAMpaths() automatically applies itself recursively over those submodels. However, if a non-NULL matrix has been supplied for argument cov, that matrix is only used for the "container" model, and is not passed as argument to the recursive calls of the function. To provide a covariance matrix for calculating SEs in an independent submodel, use mxStandardizeRAMpaths() directly on that submodel.

Use of SE=TRUE requires that package numDeriv be installed. It also requires that model contain no mxConstraint statements. Finally, if cov=NULL, it requires model to have a nonempty hessian element in its output slot. There are three common reasons why the latter condition may not be met. First, the model may not have been run yet, i.e. it was not output by mxRun(). Second, mxOption "Hessian" might be set to "No". Third, computing the Hessian matrix might possibly have been skipped per a user-defined mxCompute* statement (if any are present in the model). If model contains RAM-expectation submodels with independent=TRUE, these conditions are checked separately for each such submodel.

In any event, using these standard errors for hypothesis-testing or forming confidence intervals is not generally advised. Instead, it is considered best practice to conduct likelihood-ratio tests or compute likelihood-based confidence intervals (from mxCI()), as in examples below.

The user should note that mxStandardizeRAMpaths() only cares whether an element of A or S (or M) is nonzero, and not whether it is a fixed or free parameter. So, for instance, if the function is used on a model not yet run, any free parameters in A or S initialized at zero will not appear in the function's output.

The user is warned to interpret the output of mxStandardizeRAMpaths() cautiously if any elements of A or S depend upon "definition variables" (you have definition variables in your model if the labels of any MxPath or MxMatrix begin with "data."). Typically, either mxStandardizeRAMpaths()'s results will be valid only for the first row of the raw dataset (and any rows identical to it), or some of the standardized coefficients will be incorrectly reported as zero.

Value

If argument model is a single-group model that uses RAM expecation, then mxStandardizeRAMpaths() returns a dataframe, with one row for each nonzero path coefficient in A and S (and M, if present), and with the following columns:

name

Character strings that uniquely identify each nonzero path coefficient in terms of the model name, the matrix ("A", "S", or "M"), the row number, and the column number.

label

Character labels for those path coefficients that are labeled elements of an mxMatrix object, and NA for those that are not. Note that path coefficients having the same label (and therefore the same UNstandardized value) can have different standardized values, and therefore the same label may appear more than once in this dataframe.

matrix

Character strings of "A", "S", or "M", depending on which matrix contains the given path coefficient.

row

Character. The rownames of the matrix containing each path coefficient; row numbers are used instead if the matrix has no rownames.

col

Character. The colnames of the matrix containing each path coefficient; column numbers are used instead if the matrix has no colnames.

Raw.Value

Numeric values of the raw (i.e., UNstandardized) path coefficients.

Raw.SE

Numeric values of the asymptotic standard errors of the raw path coefficients if if SE=TRUE, or "not_requested" otherwise.

Std.Value

Numeric values of the standardized path coefficients.

Std.SE

Numeric values of the asymptotic standard errors of the standardized path coefficients if SE=TRUE, or "not_requested" otherwise.

If model is a multi-group model containing at least one submodel with RAM expectation, then mxStandardizeRAMpaths() returns a list. The list has a number of elements equal to the number of submodels that either have RAM expectation or contain a submodel that does. List elements corresponding to RAM-expectation submodels contain a dataframe, as described above. List elements corresponding to "container" submodels are themselves lists, of the kind described here.

See Also

mxBootstrapStdizeRAMpaths()

Examples

library(OpenMx)
data(demoOneFactor)
manifests <- names(demoOneFactor)
latents   <- c("G")
factorModel <- mxModel(model="One Factor", type="RAM",
      manifestVars = manifests,
      latentVars   = latents,
      mxPath(from=latents, to=manifests),
      mxPath(from=manifests, arrows=2, values=0.1),
      mxPath(from=latents, arrows=2,free=FALSE, values=1.0),
      mxData(cov(demoOneFactor), type="cov",numObs=500)
)
factorFit <-mxRun(factorModel)
summary(factorFit)$parameters
mxStandardizeRAMpaths(model=factorFit,SE=FALSE)

## Likelihood ratio test of variable x1's factor loading:
factorModelNull <- omxSetParameters(factorModel,labels="One Factor.A[1,6]",
                    values=0,free=FALSE)
factorFitNull <- mxRun(factorModelNull)
mxCompare(factorFit,factorFitNull)[2,"p"] #<--p-value

## Confidence intervals for all standardized paths:
factorModel2 <- mxModel(model=factorModel,
                        mxMatrix(type="Iden",nrow=nrow(factorModel$A),name="I"),
                        mxAlgebra( vec2diag(diag2vec( solve(I-A)%*%S%*%t(solve(I-A)) )%^%-0.5) ,
                                   name="InvSD"),
                        mxAlgebra( InvSD %*% A %*% solve(InvSD),
                                   name="Az",dimnames=dimnames(factorModel$A)),
                        mxAlgebra( InvSD %*% S %*% InvSD, 
                                   name="Sz",dimnames=dimnames(factorModel$S)),
                        mxCI(c("Az","Sz"))
)

factorFit2 <- mxRun(factorModel2,intervals=TRUE)
## Contains point values and confidence limits for all paths:
summary(factorFit2)$CI


OpenMx documentation built on Oct. 19, 2024, 9:06 a.m.