Dear Brad,
It's impossible to know from the information given whether the model is
identified or not. Including a reproducible example of your problem, as the
r-help posting guide asks, is a good idea.
Assuming that OCB is an observed variable, however, the model is identified,
but implausible. That is, you've specified that the three latent exogenous
variables, STA, SA, DA, are uncorrelated. That likely would produce
difficulties in maximizing the likelihood, which could explain the error you
encountered. Again, without a reproducible example, one can only guess.
Some other points:
(1) It's generally easier to use specifyEquations() in preference to
specifyModel() to define the model. See ?specifyEquations.
(2) Even if you use specifyModel(), you need not supply error-variance
parameters for endogenous variables; these will be added to the model by
default. If you look closely, you'll see that this was done for OCB, for
which you omitted the error-variance parameter. See ?specifyModel.
(3) You're better off letting sem() compute the observed-variable covariance
matrix rather than supplying it as an argument. Among other things, that
will allow you to compute robust coefficient standard errors and tests on
the fitted model. See ?sem and
<http://socserv.mcmaster.ca/jfox/Books/Companion/appendix/Appendix-SEMs.pdf>
.
I hope this helps,
John
-----------------------------------------------
John Fox
McMaster University
Hamilton, Ontario, Canada
http://socserv.socsci.mcmaster.ca/jfox/
> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of Yumeng Yue
> Sent: Sunday, September 15, 2013 8:31 AM
> To: r-help at r-project.org
> Subject: [R] Failed path analysis using sem package
>
> Dear R users:
>
> I am trying to run a path analysis using sem package in R. But I have
> encountered one problem, below is my code:
>
> SEMEX<-read.csv("D:/Documents and
Settings/z3409964/Desktop/Hospital
> 1.csv")
> library(sem)
> cov.matrixSEMEX<-cov(na.omit(SEMEX))
>
> SEMEX<-specifyModel()
> CWB->CWB13,NA,1
> CWB->CWB23,deviance1
> CWB->CWB33,deviance2
> CWB->CWB43,deviance3
> STA->STA13,NA,1
> STA->STA23,citizenship1
> STA->STA33,citizenship2
> STA->STA43,citizenship3
> STA->STA53,citizenship4
> SA->SA13,NA,1
> SA->SA23,surface1
> SA->SA33,surface2
> DA->DA13,NA,1
> DA->DA23,deep1
> DA->DA33,deep2
> NA->NA13,NA,1
> NA->NA23,negative1
> NA->NA33,negative2
> PA->PA13,NA,1
> PA->PA23,positive1
> PA->PA33,positive2
> CWB13<->CWB13,error1
> CWB23<->CWB23,error2
> CWB33<->CWB33,error3
> CWB43<->CWB43,error4
> STA13<->STA13,error5
> STA23<->STA23,error6
> STA33<->STA33,error7
> STA43<->STA43,error8
> STA53<->STA53,error9
> SA13<->SA13,error10
> SA23<->SA23,error11
> SA33<->SA33,error12
> DA13<->DA13,error13
> DA23<->DA23,error14
> DA33<->DA33,error15
> NA13<->NA13,error16
> NA23<->NA23,error17
> NA33<->NA33,error18
> PA13<->PA13,error19
> PA23<->PA23,error20
> PA33<->PA33,error21
> CWB<->CWB,var1
> STA<->STA,var2
> SA<->SA,var3
> DA<->DA,var4
> PA<->PA,var5
> NA<->NA,var6
> SA->NA,beta1
> NA->CWB,beta2
> DA->PA,beta3
> PA->OCB,beta4
> SA->PA,beta5
> DA->NA,beta6
> OCB<->CWB,cov2
>
> SEMEX<-sem(SEMEX,cov.matrixSEMEX, nrow(SEMEX))
>
summary(SEMEX,fit.indices=c("CFI","GFI","AGFI","RMSEA"))
>
> Yet the output shows the following:
>
> Error in summary.objectiveML(SEMEX, fit.indices = c("CFI",
"GFI",
> "AGFI", :
> coefficient covariances cannot be computed
> In addition: Warning message:
> In vcov.sem(object, robust = robust, analytic = analytic.se) :
> singular Hessian: model is probably underidentified.
>
> Can you help figure out what is going on? Thank you very much
>
> Brad
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-
> guide.html
> and provide commented, minimal, self-contained, reproducible code.