Last data update: 2014.03.03

R: Estimate Modification Indices for MxModel Objects
mxMIR Documentation

Estimate Modification Indices for MxModel Objects

Description

This function estimates the change in fit function value resulting from freeing currently fixed parameters.

Usage

mxMI(model, matrices=NA, full=TRUE)

Arguments

model

An MxModel for which modification indices are desired.

matrices

Character vector. The names of the matrices in which to search for modification

full

Logical. Whether or not to return the full modification index in addition to the restricted.

Details

Modification indices provide an estimate of how much the fit function value would change if a parameter that is currently fixed was instead freely estimated. There are two versions of this estimate: a restricted version and an full version. The restricted version is reported as the MI and is much faster to compute. The full version is reported as MI.Full. The full version accounts for the total change in fit function value resulting from the newly freed parameter. The restricted version only accounts for the change in the fit function due to the movement of the new free parameter. In particular, the restricted version does not account for the change in fit function value due to the other free parameters moving in response to the new parameter.

The algorithm respects fixed parameter labels. That is, when a fixed parameter has a label and occurs in more than one spot, then that fixed parameter is freed in all locations in which it occurs to evaluate the modification index for that fixed parameter.

When the fit function is in minus two log likelihood units (e.g. mxFitFunctionML), then the MI will be approximately chi squared distributed with 1 degree of freedom. Using a p-value of 0.01 has been suggested. Hence, a MI greater than qchisq(p=1-0.01, df=1), or 6.63, is suggestive of a modification.

Users should be cautious in their use of modification indices. If a model was created with the aid of MIs, then it should always be reported. Do not pretend that you have a theoretical reason for part of a model that was put there because it was suggested by a modification index. This is fraud. When using modification indices there are two options for best practices. First, you can report the analyses as exploratory. Document all the explorations that you did, and know that your results may or may not generalize. Second, you can use cross-validation. Reserve part of your data for exploration, and use the remaining data to test if the exploratory model generalizes to new data.

Value

A named list with components

MI

The restricted modification index.

MI.Full

The full modification index.

plusOneParamModels

A list of models with one additional free parameter

References

Sörbom, D. (1989). Model Modification. Psychometrika, 54, 371-384.

The OpenMx User's guide can be found at http://openmx.psyc.virginia.edu/documentation.

Examples

# Create a model
require(OpenMx)
data(demoOneFactor)
manifests <- names(demoOneFactor)
latents <- c("G")
factorModel <- mxModel("One Factor",
      type="RAM",
      manifestVars = manifests,
      latentVars = latents,
      mxPath(from=latents, to=manifests),
      mxPath(from=manifests, arrows=2),
      mxPath(from=latents, arrows=2,
            free=FALSE, values=1.0),
      mxPath(from = 'one', to = manifests),
      mxData(observed=cov(demoOneFactor), type="cov", numObs=500,
             means = colMeans(demoOneFactor)))
#No SEs for speed
factorModel <- mxOption(factorModel, 'Standard Errors', 'No')
factorRun <- mxRun(factorModel)

# See if it should be modified
# Notes
#  Using full=FALSE for faster performance
#  Using matrices= 'A' and 'S' to not get MIs for
#    the F matrix which is always fixed.
fim <- mxMI(factorRun, matrices=c('A', 'S'), full=FALSE)
round(fim$MI, 3)
plot(fim$MI, ylim=c(0, 10))
abline(h=qchisq(p=1-0.01, df=1)) # line of "significance"

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(OpenMx)
Loading required package: digest
Loading required package: MASS
Loading required package: Matrix
Loading required package: Rcpp
Loading required package: parallel

Attaching package: 'OpenMx'

The following objects are masked from 'package:Matrix':

    %&%, expm

> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/OpenMx/mxMI.Rd_%03d_medium.png", width=480, height=480)
> ### Name: mxMI
> ### Title: Estimate Modification Indices for MxModel Objects
> ### Aliases: mxMI
> 
> ### ** Examples
> 
> # Create a model
> require(OpenMx)
> data(demoOneFactor)
> manifests <- names(demoOneFactor)
> latents <- c("G")
> factorModel <- mxModel("One Factor",
+       type="RAM",
+       manifestVars = manifests,
+       latentVars = latents,
+       mxPath(from=latents, to=manifests),
+       mxPath(from=manifests, arrows=2),
+       mxPath(from=latents, arrows=2,
+             free=FALSE, values=1.0),
+       mxPath(from = 'one', to = manifests),
+       mxData(observed=cov(demoOneFactor), type="cov", numObs=500,
+              means = colMeans(demoOneFactor)))
> #No SEs for speed
> factorModel <- mxOption(factorModel, 'Standard Errors', 'No')
> factorRun <- mxRun(factorModel)
Running One Factor with 15 parameters
> 
> # See if it should be modified
> # Notes
> #  Using full=FALSE for faster performance
> #  Using matrices= 'A' and 'S' to not get MIs for
> #    the F matrix which is always fixed.
> fim <- mxMI(factorRun, matrices=c('A', 'S'), full=FALSE)
Running One Factor with 1 parameter
Running One Factor with 1 parameter
Running One Factor with 1 parameter
Running One Factor with 1 parameter
Running One Factor with 1 parameter
Running One Factor with 1 parameter
Running One Factor with 1 parameter
Running One Factor with 1 parameter
Running One Factor with 1 parameter
Running One Factor with 1 parameter
Running One Factor with 1 parameter
Running One Factor with 1 parameter
Running One Factor with 1 parameter
Running One Factor with 1 parameter
Running One Factor with 1 parameter
Running One Factor with 1 parameter
Running One Factor with 1 parameter
Running One Factor with 1 parameter
Running One Factor with 1 parameter
Running One Factor with 1 parameter
Running One Factor with 1 parameter
Running One Factor with 1 parameter
Running One Factor with 1 parameter
Running One Factor with 1 parameter
Running One Factor with 1 parameter
Running One Factor with 1 parameter
Running One Factor with 1 parameter
Running One Factor with 1 parameter
Running One Factor with 1 parameter
Running One Factor with 1 parameter
Running One Factor with 1 parameter
Running One Factor with 1 parameter
Running One Factor with 1 parameter
Running One Factor with 1 parameter
Running One Factor with 1 parameter
Running One Factor with 1 parameter
Running One Factor with 1 parameter
Running One Factor with 1 parameter
Running One Factor with 1 parameter
Running One Factor with 1 parameter
Running One Factor with 1 parameter
Running One Factor with 1 parameter
Running One Factor with 1 parameter
Running One Factor with 1 parameter
Running One Factor with 1 parameter
Running One Factor with 1 parameter
Running One Factor with 1 parameter
> round(fim$MI, 3)
One Factor.A[1,1] One Factor.A[2,1] One Factor.A[3,1] One Factor.A[4,1] 
            0.000             0.000             0.274             0.044 
One Factor.A[5,1] One Factor.A[6,1] One Factor.A[1,2] One Factor.A[2,2] 
            0.043             0.000             0.000             0.000 
One Factor.A[3,2] One Factor.A[4,2] One Factor.A[5,2] One Factor.A[6,2] 
            0.148             0.341             0.056             0.000 
One Factor.A[1,3] One Factor.A[2,3] One Factor.A[3,3] One Factor.A[4,3] 
            0.132             0.119             0.000             0.009 
One Factor.A[5,3] One Factor.A[6,3] One Factor.A[1,4] One Factor.A[2,4] 
            0.290             0.000             0.013             0.167 
One Factor.A[3,4] One Factor.A[4,4] One Factor.A[5,4] One Factor.A[6,4] 
            0.006             0.000             0.088             0.000 
One Factor.A[1,5] One Factor.A[2,5] One Factor.A[3,5] One Factor.A[4,5] 
            0.008             0.017             0.112             0.056 
One Factor.A[5,5] One Factor.A[6,5] One Factor.A[6,6] One Factor.S[1,2] 
            0.000             0.000             0.000             0.000 
One Factor.S[1,3] One Factor.S[2,3] One Factor.S[1,4] One Factor.S[2,4] 
            1.454             1.304             0.227             2.801 
One Factor.S[3,4] One Factor.S[1,5] One Factor.S[2,5] One Factor.S[3,5] 
            0.099             0.218             0.472             2.770 
One Factor.S[4,5] One Factor.S[1,6] One Factor.S[2,6] One Factor.S[3,6] 
            1.416             0.000             0.000             0.000 
One Factor.S[4,6] One Factor.S[5,6] One Factor.S[6,6] 
            0.000             0.000             0.000 
> plot(fim$MI, ylim=c(0, 10))
> abline(h=qchisq(p=1-0.01, df=1)) # line of "significance"
> 
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>