Hi all,
I would like to remove one factor, say "IQ2", from a CFA (script is below). Does it work if I rewrite the model as
cfa2 <- mxModel(cfa, "one factor", mxPath(from = "Q2", to = "Q2", arrows=2, values = 0, free = F), mxPath(from = "Q1", to = "Q2", arrows=2, values = 0, free = F), mxPath(from = "Q1", to = observed, free = F, values = 0) )
Is there any more convinience way to remove path?
Thanks in advance!
observed<-c("reading","writing","math","analytic") latents<-c("Q1", "Q2") cfa<-mxModel("two factors", type="RAM", manifestVars=observed, latentVars=latents, mxPath(from=latents, to=observed, free=c(F,T,T,T),values=c(1,1,1,1),labels=c("l1","l2","l3","l4")), mxPath(from=observed, arrows=2,labels=c("d1","d2","d3","d4")), mxPath(from=latents, arrows=2,connect = "unique.pairs", free = T, labels=c("p11", "p12", "p22")), mxData(cov(intell[,1:4]),type="cov",numObs=100) ) results<-mxRun(cfa)
That should work.
If you want to remove an entire
mxPath()
statement, you can pass the statement back tomxModel()
, along with argumentremove=TRUE
tomxModel()
, and the MxModel object itself as first argument tomxModel()
. Alternately, you could give all of your paths labels (via thelabels
argument tomxPath()
), and fix specific paths to zero viaomxSetParameters()
.Easiest/least error-prone thing to drop a latent in cases like this is often just build a new model. However...
In umx, you could do: