我在学习lavaan时用了这个例子:
> library(lavaan)
This is lavaan 0.5-16
lavaan is BETA software! Please report any bugs.
> ?HolzingerSwineford1939
starting httpd help server ... done
> data(HolzingerSwineford1939)
> head(HolzingerSwineford1939)
id sex ageyr agemo school grade x1 x2 x3 x4 x5
1 1 1 13 1 Pasteur 7 3.333333 7.75 0.375 2.333333 5.75
2 2 2 13 7 Pasteur 7 5.333333 5.25 2.125 1.666667 3.00
3 3 2 13 1 Pasteur 7 4.500000 5.25 1.875 1.000000 1.75
4 4 1 13 2 Pasteur 7 5.333333 7.75 3.000 2.666667 4.50
5 5 2 12 2 Pasteur 7 4.833333 4.75 0.875 2.666667 4.00
6 6 2 14 1 Pasteur 7 5.333333 5.00 2.250 1.000000 3.00
x6 x7 x8 x9
1 1.2857143 3.391304 5.75 6.361111
2 1.2857143 3.782609 6.25 7.916667
3 0.4285714 3.260870 3.90 4.416667
4 2.4285714 3.000000 5.30 4.861111
5 2.5714286 3.695652 6.30 5.916667
6 0.8571429 4.347826 6.65 7.500000
> HS.model <- ' visual =~ x1 + x2 + x3
+ textual =~ x4 + x5 + x6
+ speed =~ x7 + x8 + x9 '
> HS.model
[1] " visual =~ x1 + x2 + x3\ntextual =~ x4 + x5 + x6\nspeed =~ x7 + x8 + x9 "
> fit <- cfa(HS.model, data = HolzingerSwineford1939)
然后:
> summary(fit)
得到:
lavaan (0.5-16) converged normally after 35 iterations
Number of observations 301
Estimator ML
Minimum Function Test Statistic 85.306
Degrees of freedom 24
P-value (Chi-square) 0.000
Parameter estimates:
Information Expected
Standard Errors Standard
Estimate Std.err Z-value P(>|z|)
Latent variables:
visual =~
x1 1.000
x2 0.554 0.100 5.554 0.000
x3 0.729 0.109 6.685 0.000
textual =~
x4 1.000
x5 1.113 0.065 17.014 0.000
x6 0.926 0.055 16.703 0.000
speed =~
x7 1.000
x8 1.180 0.165 7.152 0.000
x9 1.082 0.151 7.155 0.000
Covariances:
visual ~~
textual 0.408 0.074 5.552 0.000
speed 0.262 0.056 4.660 0.000
textual ~~
speed 0.173 0.049 3.518 0.000
Variances:
x1 0.549 0.114
x2 1.134 0.102
x3 0.844 0.091
x4 0.371 0.048
x5 0.446 0.058
x6 0.356 0.043
x7 0.799 0.081
x8 0.488 0.074
x9 0.566 0.071
visual 0.809 0.145
textual 0.979 0.112
speed 0.384 0.086
为什么:
Estimate Std.err Z-value P(>|z|)
Latent variables:
visual =~
x1 1.000
x2 0.554 0.100 5.554 0.000
x3 0.729 0.109 6.685 0.000
中“x1”后Estimate为1.000,后面都是空的?(其他两个隐变量与下面的显变量关系的结构也是这样)是什么意思? 这个结果每一步如何解释?
其实默认的将每个潜变量的第一个显变量的因子载荷固定为1,如果不想这样,将std.lv参数改为T即可:
fit<-cfa(HS.model,data=HolzingerSwineford1939,std.lv=T)
> summary(fit)
lavaan (0.5-16) converged normally after 22 iterations
Number of observations 301
Estimator ML
Minimum Function Test Statistic 85.306
Degrees of freedom 24
P-value (Chi-square) 0.000
Parameter estimates:
Information Expected
Standard Errors Standard
Estimate Std.err Z-value P(>|z|)
Latent variables:
visual =~
x1 0.900 0.081 11.127 0.000
x2 0.498 0.077 6.429 0.000
x3 0.656 0.074 8.817 0.000
textual =~
x4 0.990 0.057 17.474 0.000
x5 1.102 0.063 17.576 0.000
x6 0.917 0.054 17.082 0.000
speed =~
x7 0.619 0.070 8.903 0.000
x8 0.731 0.066 11.090 0.000
x9 0.670 0.065 10.305 0.000
Covariances:
visual ~~
textual 0.459 0.064 7.189 0.000
speed 0.471 0.073 6.461 0.000
textual ~~
speed 0.283 0.069 4.117 0.000
Variances:
x1 0.549 0.114
x2 1.134 0.102
x3 0.844 0.091
x4 0.371 0.048
x5 0.446 0.058
x6 0.356 0.043
x7 0.799 0.081
x8 0.488 0.074
x9 0.566 0.071
visual 1.000
textual 1.000
speed 1.000
暂无数据