Power calculations for structural equation models

2 replies [Last post]
neale's picture
Offline
Joined: 07/31/2009

So a question was on SEMNET the other day, as to whether there were any free SEM packages that do power calculations. In essence, OpenMx does, given a bit of help from the R package pwr. Basically, one would fit the true model to the data, fix one or more parameters to predetermined values (usually to zero) and refit the model. Suppose that the difference in the -2lnL fit functions (as might be obtained from two mxRun commands

sat<-mxRun(saturated)
and
sub <-mxRun(submodel)

then the difference in the fit of these two models would be:

deltachi<-mxEval(objective,sub) - mxEval(objective,sat)

and the difference in the degrees of freedom would be (sorry this is crude but df is not healthy in OpenMx yet)

deltadf<-length(sat@output$estimate) - length(sub@output$estimate)

To compute the power to reject the null hypothesis at significance level alpha=.05, we could use:

require(stats)
alpha<-.05
1-pchisq(qchisq(1-alpha,deltadf),deltadf,deltachi)

This probably belongs in the documentation somewhere, for now it is just a convenient aide-memoire pour moi.

tbates's picture
Offline
Joined: 07/31/2009
hi Mike, Isn't power about

hi Mike,
Isn't power about detecting an effect when it is present in the data (for a given alpha and n)? So surely you'd need to inject that effect into (simulated?) data, and then see if you can set the modeled effect size to zero without (significant) loss of fit.

PS: where did pwr come into the routine you outlined (or did I miss something?)

detach("package:pwr")
deltachi =1.1
deltadf =3
alpha = .05
1-pchisq(qchisq(1-alpha,deltadf),deltadf,deltachi)
3 [1] 0.1229142

(eagerly anticipating confidence intervals, and thinking the mixture model work you are describing elsewhere sounds nice!)

neale's picture
Offline
Joined: 07/31/2009
Hi Tim Yes, normally the

Hi Tim

Yes, normally the saturated model would include all parameters free and the submodel would fix to zero the parameter(s) of interest. For example, we might simulate data such as A=.8 C=.6 E=.5 in an ACE model. we could fit an ACE model and then fit an AE submodel. The difference would be the non-centrality parameter lambda, named deltachi in the script in the original post. Ordinarily, with covariance matrix input, the ACE model will fit perfectly, with Chi-sq equal to zero. With raw data, the fit function is -2lnL, which would be non-null and which has to be subtracted in order to arrive at a chisq for the lambda non-centrality parameter.

Good point, pwr is not needed for these calculations. stats seems to be; I will amend original post accordingly.