Published on *OpenMx* (http://openmx.psyc.virginia.edu)

By *jb*

Created *07/29/2010 - 13:29*

Thu, 07/29/2010 - 13:29 — jb [1]

Hi all,

First, thanks to do this job for R, it's really needed!

I am trying to do a CFA with 6 factors (psychological self report questionnaire with 6 scales with 14 items each).

I tried to adapt the two factors models. Seeing this discussion, I changed

the starting values and got no warning message. I have a few issues though:

1. For the latent covariance and variances of the 2 factors you give the

example of values=c(1, .5,.5, 1) But how can I organize it with 6 factors? Why do we need

to specify starting values, in sem package none is needed. Is it a specificity of the program ?

2.I fitted the same model with the sem package. I have virtually the same RMSEA

(with 0.001 difference) but the estimates are very different. In the SEM package

I got estimates between latent variables (factor 1 with 2 for instance) quite close

to the actual correlation table between the 6 scales (sum of the 14 items of each scale) with + or - 0.1. With OpenMx it was very far from that and

did not seem the same at all. Is it an error in my model, or are they really different and,

if so, what does it mean?

3. Did not succeed to fit the model with raw data, not finished in 15 hours. Is it normal ?

Some things that would be very useful in psychology and psychiatry, not only for

CFA but for every SEM:

1. More fit indices (at least RMSEA, CFI and SRMR. They are in the package sem

so may be easier to implement ? We are asked for them in reviews.

2. Some easier functions for the labels. When they are many it's difficult to name them all.

Maybe for the labels of Means for instance, a simple function which would had a "M" at the beginning

of the name of the latent variable.

2. Binary and Count variable. They are very important in psychiatry and psycho. And will be necessary

to compete with other programs. For instance, I can't use OpenMx now cause I need counts. And maybe more

examples using these kind of observed variables as outcomes.

Many thanks!!!

Here is the code for the model.

DFan is the data.frame with all the 84 items.

library(OpenMx)

##preparation

manifests <- names(DFan)

latents = c("PL","SE","CA","FE","AN","SA")

freemeans=c(rep(TRUE,84),rep(FALSE,6))

meansvalues=mean(DFan)

ANPSModel<-mxModel("ANcfa",

type="RAM",

mxData(

observed=cov(DFan),

type="cov",

numObs=830,

means=meansvalues),

manifestVars=manifests,

latentVars=latents,

# residual variances

mxPath(

from=manifests,

arrows=2,

free=TRUE,

values=0.8,

),

# latent variances and covariance

mxPath(

from=latents,

arrows=2,

all=TRUE,

free=TRUE,

values=0.8

),

mxPath(

from="PLAY",

to=c("an05", "an13", "an21", "an29", "an37",

"an45bis", "an53bis", "an61bis", "an69bis",

"an77bis","an85bis","an93bis","an101bis","an109bis"),

arrows=1,

free=c(FALSE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE),

values=c(1,rep(0.2,13)),

),

mxPath(

from="SEEK",

to=c("an01bis","an09bis","an17bis","an25bis","an33bis",

"an41bis","an49bis","an57bis","an65bis",

"an73bis","an81bis","an89bis","an97bis","an105bis"),

arrows=1,

free=c(FALSE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE),

values=c(1,rep(0.2,13)),

),

mxPath(

from="CARE",

to=c("an03bis","an11bis","an19bis","an27bis","an35bis",

"an43bis","an51bis","an59bis","an67bis",

"an75bis","an83bis","an91bis","an99bis","an107bis"),

arrows=1,

free=c(FALSE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE),

values=c(1,rep(0.2,13)),

),

mxPath(

from="FEAR",

to=c("an02bis","an10bis","an18bis","an26bis","an34bis",

"an42bis","an50bis","an58bis","an66bis",

"an74bis","an82bis","an90bis","an98bis","an106bis"),

arrows=1,

free=c(FALSE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE),

values=c(1,rep(0.2,13)),

),

mxPath(

from="ANGER",

to=c("an04bis","an12bis","an20bis","an28bis","an36bis",

"an44bis","an52bis","an60bis","an68bis",

"an76bis","an84bis","an92bis","an100bis","an108bis"),

arrows=1,

free=c(FALSE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE),

values=c(1,rep(0.2,13)),

),

mxPath(

from="SAD",

to=c("an06bis","an14bis","an22bis","an30bis","an38bis",

"an46bis","an54bis","an62bis","an70bis",

"an78bis","an86bis","an94bis","an102bis","an110bis"),

arrows=1,

free=c(FALSE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE),

values=c(1,rep(0.2,13)),

),

#means

mxPath(

from="one",

to=c(manifests,latents),

arrows=1,

free=freemeans,

values=c(rep(1,84),rep(0,6)),

)

)

**Links:**

[1] http://openmx.psyc.virginia.edu/users/jb

[2] http://openmx.psyc.virginia.edu/thread/772

[3] http://openmx.psyc.virginia.edu/thread/562

[4] http://openmx.psyc.virginia.edu/forums/opensem-forums/confirmatory-factor-analysis-and-measurement-models