Differences Between SPSS and Lavaan Correlations.

91 views
Skip to first unread message

bj...@cornell.edu

unread,
May 5, 2017, 12:30:32 PM5/5/17
to lavaan
I am finding slight differences in correlation coefficients between lavaan and SPSS.  For example, whereas SPSS gives me 0.37 between variables X and Y, lavaan gives me 0.39.  Why is this?

And thank you very much in advance.

Edward Rigdon

unread,
May 5, 2017, 12:47:40 PM5/5/17
to lav...@googlegroups.com
Dividing by n vs n-1 ?

On Fri, May 5, 2017 at 12:30 PM, <bj...@cornell.edu> wrote:
I am finding slight differences in correlation coefficients between lavaan and SPSS.  For example, whereas SPSS gives me 0.37 between variables X and Y, lavaan gives me 0.39.  Why is this?

And thank you very much in advance.

--
You received this message because you are subscribed to the Google Groups "lavaan" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lavaan+unsubscribe@googlegroups.com.
To post to this group, send email to lav...@googlegroups.com.
Visit this group at https://groups.google.com/group/lavaan.
For more options, visit https://groups.google.com/d/optout.

Mauricio Garnier-Villarreal

unread,
May 5, 2017, 1:58:05 PM5/5/17
to lavaan
missing data? list-wise deletion vs fiml?


On Friday, May 5, 2017 at 11:47:40 AM UTC-5, Edward Rigdon wrote:
Dividing by n vs n-1 ?
On Fri, May 5, 2017 at 12:30 PM, <bj...@cornell.edu> wrote:
I am finding slight differences in correlation coefficients between lavaan and SPSS.  For example, whereas SPSS gives me 0.37 between variables X and Y, lavaan gives me 0.39.  Why is this?

And thank you very much in advance.

--
You received this message because you are subscribed to the Google Groups "lavaan" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lavaan+un...@googlegroups.com.

bj...@cornell.edu

unread,
May 5, 2017, 1:59:43 PM5/5/17
to lavaan
Thank you, Mauricio.  But there is no missing data.

Bruce Weaver

unread,
May 5, 2017, 2:04:29 PM5/5/17
to lavaan
It might help if you provided a small dataset that illustrates the problem.  Include your code for both SPSS and Lavaan too. 

bj...@cornell.edu

unread,
May 6, 2017, 1:17:54 PM5/6/17
to lavaan
Thank you.  At issue here is the correlation between variables "F" and "G".  In SPSS, this correlation is reported as 0.57.  However, in lavaan, it is reported as 0.53.  Note, however, that the correlations between "D" and "E" are identical between SPSS and lavaan (i.e., 0.41).

Please see attached for (1) a file containing the data in question, (2) a file containing SPSS syntax for the correlation between variables "F" and "G", (3) R output containing the correlation in question, and (4) lavaan syntax.

Any assistance in determining why the F ~~ G correlation differs between SPSS and lavaan is highly appreciated. 

My lavaan syntax is as follows:

model <- '  F ~ d*D + f*E

G ~ e*D

A ~ a*F + c*G

B ~ b*A

B ~ C 

D ~~ E

G ~~ F

B  ~    g*G

               ind1 := a*b

               ind2 := c*b

               ind3 := d*a*b

               ind4 := e*c*b

               ind5 := f*a*b

               ind6 := e*g'

fit<-sem(model,Dataset,fixed.x=FALSE)

summary(fit)

inspect(fit, 'r2')

standardizedsolution(fit)

modindices(fit)

fitmeasures(fit)

Study Data.sav
SPSS Syntax.sps
R Console.txt
Model Syntax.R

Bruce Weaver

unread,
May 9, 2017, 1:46:01 PM5/9/17
to lavaan
Thanks for posting the data and your code.  I am not well-versed enough to guess what lavaan is doing.  But for what it's worth, I get the same results you do with SPSS, except that r(F,G) = -0.57, not 0.57.  Stata's user-written corrci command gives the same results as SPSS:

. corrci F G
(obs=351)
      correlation and 95% limits
F G     -0.570   -0.637   -0.495

. corrci D E
(obs=351)
      correlation and 95% limits
D E      0.411    0.320    0.494

HTH.

Alex Schoemann

unread,
May 9, 2017, 2:40:53 PM5/9/17
to lavaan
The issue isn't a lavaan (or SPSS) specific one. In your lavaan code both F and G are outcome variables. So the covariance between F and G in your model results is a residual covariance (and the correlations are residual correlations). There's no reason to expect that the residual covariance and the bivariate correlation are the same. If you look at the sample statistics lavaan is using in your models the correlation is the same:
cov2cor(inspect(fit, "sampstats")$cov)## gives the correlation between F and G of -.57

The other thing to note, is that your model has non-zero df, so the model implied covariance matrix and the data covariance matrix are different. In the model implied matrix, the correlation between F and G is different from the correlation in the data.
cov2cor(fitted(fit)$cov) ##the correlation in the model implied matrix is -.548

Alex
Reply all
Reply to author
Forward
0 new messages