For the first part, the documentation provides an example
library(lavaan)
#> This is lavaan 0.6-5
#> lavaan is BETA software! Please report any bugs.
example(cfa)
#>
#> cfa> ## The famous Holzinger and Swineford (1939) example
#> cfa> HS.model <- ' visual =~ x1 + x2 + x3
#> cfa+ textual =~ x4 + x5 + x6
#> cfa+ speed =~ x7 + x8 + x9 '
#>
#> cfa> fit <- cfa(HS.model, data = HolzingerSwineford1939)
#>
#> cfa> summary(fit, fit.measures = TRUE)
#> lavaan 0.6-5 ended normally after 35 iterations
#>
#> Estimator ML
#> Optimization method NLMINB
#> Number of free parameters 21
#>
#> Number of observations 301
#>
#> Model Test User Model:
#>
#> Test statistic 85.306
#> Degrees of freedom 24
#> P-value (Chi-square) 0.000
#>
#> Model Test Baseline Model:
#>
#> Test statistic 918.852
#> Degrees of freedom 36
#> P-value 0.000
#>
#> User Model versus Baseline Model:
#>
#> Comparative Fit Index (CFI) 0.931
#> Tucker-Lewis Index (TLI) 0.896
#>
#> Loglikelihood and Information Criteria:
#>
#> Loglikelihood user model (H0) -3737.745
#> Loglikelihood unrestricted model (H1) -3695.092
#>
#> Akaike (AIC) 7517.490
#> Bayesian (BIC) 7595.339
#> Sample-size adjusted Bayesian (BIC) 7528.739
#>
#> Root Mean Square Error of Approximation:
#>
#> RMSEA 0.092
#> 90 Percent confidence interval - lower 0.071
#> 90 Percent confidence interval - upper 0.114
#> P-value RMSEA <= 0.05 0.001
#>
#> Standardized Root Mean Square Residual:
#>
#> SRMR 0.065
#>
#> Parameter Estimates:
#>
#> Information Expected
#> Information saturated (h1) model Structured
#> Standard errors Standard
#>
#> Latent Variables:
#> Estimate Std.Err z-value P(>|z|)
#> 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:
#> Estimate Std.Err z-value P(>|z|)
#> 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:
#> Estimate Std.Err z-value P(>|z|)
#> .x1 0.549 0.114 4.833 0.000
#> .x2 1.134 0.102 11.146 0.000
#> .x3 0.844 0.091 9.317 0.000
#> .x4 0.371 0.048 7.779 0.000
#> .x5 0.446 0.058 7.642 0.000
#> .x6 0.356 0.043 8.277 0.000
#> .x7 0.799 0.081 9.823 0.000
#> .x8 0.488 0.074 6.573 0.000
#> .x9 0.566 0.071 8.003 0.000
#> visual 0.809 0.145 5.564 0.000
#> textual 0.979 0.112 8.737 0.000
#> speed 0.384 0.086 4.451 0.000
Created on 2020-01-14 by the reprex package (v0.3.0)
And there is a tutorial
that came out yesterday! But that is many a how to operate
, than how to intepret
. For that we need to go to the paper
The second part of your question, using the same data, is represented by this reprex
library(lavaan)
#> This is lavaan 0.6-5
#> lavaan is BETA software! Please report any bugs.
HS.model <- '
visual =~ x1 + b1*x2 + x3
textual =~ x4 + b2*x5 + x6
speed =~ x7 + b3*x8 + x9
b1 == b2
b2 == b3 '
fit <- cfa(HS.model, data=HolzingerSwineford1939)
lavTestScore(fit, cumulative = TRUE)
#> $test
#>
#> total score test:
#>
#> test X2 df p.value
#> 1 score 12.306 2 0.002
#>
#> $uni
#>
#> univariate score tests:
#>
#> lhs op rhs X2 df p.value
#> 1 b1 == b2 12.060 1 0.001
#> 2 b2 == b3 0.947 1 0.330
#>
#> $cumulative
#>
#> cumulative score tests:
#>
#> lhs op rhs X2 df p.value
#> 1 b1 == b2 12.060 1 0.001
#> 2 b2 == b3 12.306 2 0.002
Created on 2020-01-14 by the reprex package (v0.3.0)
There's a lot to unpack here about the interpretation of the output. I'm still studying it. Some are fairly standard (lower AIC
better than higher, ceteris paribus), but I'll need some more time to answer your specific questions.
In the meantime, I hope others can weigh in on the interpretation using these reprex
s