[R] Question on Chi-square of null model in sem package

Guo Wei-Wei wwguocn at gmail.com
Mon Sep 4 07:33:55 CEST 2006

Dear all,

I met a problem while doing SEM by sem package. I got a negative
chi-square of null model. Because the theoretical value of chi-square
cannot be negative, I checked the source code of sem.R in sem package
and I found the Chi-square of null model was computed by the following

result$chisqNull <- (N - 1) * (sum(diag(S %*% diag(1/diag(S)))) +

I think the reason for negative Chi-square is the too small value of
prod(diag(S)) of my data. I'm working on a data.frame named emc.data
from a sample of a 16-item questioinnaire. The variance of items are

> diag(cov(emc.data))
     EMC1      EMC2      EMC3      EMC4      EMC5      EMC6      EMC7      EMC8
0.3622224 0.2350041 0.2488009 0.2901653 0.3195399 0.3107343 0.3436622 0.2345912
     EMC9     EMC10     EMC11     EMC12     EMC13     EMC14     EMC15     EMC16
0.2621680 0.3230400 0.4039245 0.3803105 0.2773370 0.4348342 0.2757216 0.3405252

The fit indices of RMSEA and GFI are good, so I think the problem
might be solve by another way for computing the Chi-square of null
model. I'm not well trained in maths, so I come for help. Any advise
is appreciated.

Best wishes,

More information about the R-help mailing list