[R] Could not compute QR decomposition of Hessian.
John Fox
jfox at mcmaster.ca
Sun Mar 4 23:25:19 CET 2012
Dear Kino,
As it stands this model doesn't make sense: You've *both* set a reference
indicator for each factor, by fixing a factor loading to 1, and fixed the
variances of the factors 1. You should do one or the other. You say near the
end of your message that you did try freeing the factor variances, so I
suppose that fixing this error doesn't produce a solution.
Some other points:
I don't know whether you're working with the current version of the sem
package, since you're using specify.model(), which is a deprecated function.
The current version of the sem package on CRAN doesn't require you to
specify the error variances for the indicators explicitly, and, in fact, for
a CFA model like this permits a much simpler specification using the cfa()
function; see ?cfa. There's still a newer version of the package,
temporarily called sem3, on R-Forge that might be able to provide a solution
when sem on CRAN cannot.
Also, I noticed that you're fitting the model to a covariance matrix, and
one possible source of numerical instability would be observed variables
with very different variances.
Finally, I don't know whether you've done as suggested in ?sem to try to
diagnose the problem, but without your data, it's very hard to say what's
going on.
Best,
John
> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of Kino Aguilar
> Sent: March-04-12 3:28 PM
> To: r-help at r-project.org
> Subject: [R] Could not compute QR decomposition of Hessian.
>
> Hi,
>
> I created the model below, which returns me the following warning
> message:
>
> In sem.default(ram = ram, S = S, N = N, param.names = pars, var.names =
> vars, :
> Could not compute QR decomposition of Hessian.
> Optimization probably did not converge.
>
> ######### Model ########
> mDPDF =
> data.frame(mj1,mj2,mj3,mj4,mj5,eL1,eL2,eL3,eL4,eL5,aC1,aC2,aC3,aC4,disR
> 1,disR2,disR3,disR4,disR5,
> difR1,difR2,difR3,difR4,difR5,difR6,dC1,dC2,dC3,dC4,aB1,aB2,aB3,aB4,aB5
> ,deh1,deh2,deh3,deh4)
> mydata.cov <- cov(mDPDF)
> model.mydata <- specify.model()
> MJ -> mj1, NA, 1
> MJ -> mj2, lam2, NA
> MJ -> mj3, lam3, NA
> MJ -> mj4, lam4, NA
> MJ -> mj5, lam5, NA
> EL -> eL1, NA, 1
> EL -> eL2, lam7, NA
> EL -> eL3, lam8, NA
> EL -> eL4, lam9, NA
> EL -> eL5, lam10, NA
> AC -> aC1, NA, 1
> AC -> aC2, lam12, NA
> AC -> aC3, lam13, NA
> AC -> aC4, lam14, NA
> DISR -> disR1, NA, 1
> DISR -> disR2, lam16, NA
> DISR -> disR3, lam17, NA
> DISR -> disR4, lam18, NA
> DISR -> disR5, lam19, NA
> DIFR -> difR1, NA, 1
> DIFR -> difR2, lam21, NA
> DIFR -> difR3, lam22, NA
> DIFR -> difR4, lam23, NA
> DIFR -> difR5, lam24, NA
> DIFR -> difR6, lam25, NA
> DC -> dC1, NA, 1
> DC -> dC2, lam27, NA
> DC -> dC3, lam28, NA
> DC -> dC4, lam29, NA
> AB -> aB1, NA, 1
> AB -> aB2, lam31, NA
> AB -> aB3, lam32, NA
> AB -> aB4, lam33, NA
> AB -> aB5, lam34, NA
> DEH -> deh1, NA, 1
> DEH -> deh2, lam36, NA
> DEH -> deh3, lam37, NA
> DEH -> deh4, lam38, NA
> mj1 <-> mj1, e1, NA
> mj2 <-> mj2, e2, NA
> mj3 <-> mj3, e3, NA
> mj4 <-> mj4, e4, NA
> mj5 <-> mj5, e5, NA
> eL1 <-> eL1, e6, NA
> eL2 <-> eL2, e7, NA
> eL3 <-> eL3, e8, NA
> eL4 <-> eL4, e9, NA
> eL5 <-> eL5, e10, NA
> aC1 <-> aC1, e11, NA
> aC2 <-> aC2, e12, NA
> aC3 <-> aC3, e13, NA
> aC4 <-> aC4, e14, NA
> disR1 <-> disR1, e15, NA
> disR2 <-> disR2, e16, NA
> disR3 <-> disR3, e17, NA
> disR4 <-> disR4, e18, NA
> disR5 <-> disR5, e19, NA
> difR1 <-> difR1, e20, NA
> difR2 <-> difR2, e21, NA
> difR3 <-> difR3, e22, NA
> difR4 <-> difR4, e23, NA
> difR5 <-> difR5, e24, NA
> difR6 <-> difR6, e25, NA
> dC1 <-> dC1, e26, NA
> dC2 <-> dC2, e27, NA
> dC3 <-> dC3, e28, NA
> dC4 <-> dC4, e29, NA
> aB1 <-> aB1, e30, NA
> aB2 <-> aB2, e31, NA
> aB3 <-> aB3, e32, NA
> aB4 <-> aB4, e33, NA
> aB5 <-> aB5, e34, NA
> deh1 <-> deh1, e35, NA
> deh2 <-> deh2, e36, NA
> deh3 <-> deh3, e37, NA
> deh4 <-> deh4, e38, NA
> MJ <-> MJ, NA, 1
> EL <-> EL, NA, 1
> AC <-> AC, NA, 1
> DISR <-> DISR, NA, 1
> DIFR <-> DIFR, NA, 1
> DC <-> DC, NA, 1
> AB <-> AB, NA, 1
> DEH <-> DEH, NA, 1
> MJ <-> EL, MJEL, NA
> MJ <-> AC, MJAC, NA
> MJ <-> DISR, MJDISR , NA
> MJ <-> DIFR, MJDIFR , NA
> MJ <-> DC, MJDC , NA
> MJ <-> AB, MJAB , NA
> MJ <-> DEH, MJDEH , NA
> EL <-> AC, ELAC , NA
> EL <-> DISR, ELDISR , NA
> EL <-> DIFR, ELDIFR , NA
> EL <-> DC, ELDC , NA
> EL <-> AB, ELAB , NA
> EL <-> DEH, ELDEH , NA
> AC <-> DISR, ACDISR , NA
> AC <-> DIFR, ACDIFR , NA
> AC <-> DC, ACDC , NA
> AC <-> AB, ACAB , NA
> AC <-> DEH, ACDEH , NA
> DISR <-> DISR, DISRDISR , NA
> DISR <-> DC, DISRDC , NA
> DISR <-> AB, DISRAB , NA
> DISR <-> DEH, DISRDEH , NA
> DIFR <-> DC, DIFRDC , NA
> DIFR <-> AB, DIFRAB , NA
> DIFR <-> DEH, DIFRDEH , NA
> DC <-> AB, DCAB , NA
> DC <-> DEH, DCDEH , NA
> AB <-> DEH, ABDEH , NA
>
> mydata.sem <- sem(model.mydata, mydata.cov, nrow(mDPDF))
>
> ######### Model ########
>
> In addition to this model, I created a number of subset models (i.e.,
> models with fewer latent variables, but otherwise everything the same)
> some of which do not give me the warning message as well as a model
> where none of the exogenous variables' variances are fixed, but I still
> obtained the same message.
>
> I'm wondering if there is anything I can do to address this problem.
>
> Best,
> ~Kino
>
> [[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.
More information about the R-help
mailing list