Skip to contents
# The famous Holzinger and Swineford (1939) example
HS.model <- "
  visual  =~ x1 + x2 + x3
  textual =~ x4 + x5 + x6
  speed   =~ x7 + x8 + x9
"
utils::data("HolzingerSwineford1939", package = "lavaan")

# Fit a CFA model with standardised latent variables
fit <- acfa(HS.model, data = HolzingerSwineford1939, std.lv = TRUE)
#> ℹ Using MVN log-likelihood.
#> ℹ Finding posterior mode.
#> ✔ Finding posterior mode. [148ms]
#> 
#> ℹ Computing the Hessian.
#> ✔ Computing the Hessian. [362ms]
#> 
#> ℹ Performing VB correction.
#> ✔ Performing VB correction. [312ms]
#> 
#> ℹ Using skew normal approximation.
#> ⠙ Fitting skew normal to 0/21 marginals.
#> ⠹ Fitting skew normal to 6/21 marginals.
#> ✔ Fitting skew normal to 21/21 marginals. [1.7s]
#> 
#> ⠙ Computing ppp and DIC.
#> ⠹ Computing ppp and DIC.
#> ✔ Computing ppp and DIC. [2s]
#> 
summary(fit)
#> INLAvaan 0.2.0.9004 ended normally after 56 iterations
#> 
#>   Estimator                                      BAYES
#>   Optimization method                           NLMINB
#>   Number of model parameters                        21
#> 
#>   Number of observations                           301
#> 
#> Model Test (User Model):
#> 
#>    Marginal log-likelihood                   -3830.969 
#>    PPP (Chi-square)                              0.000 
#> 
#> Information Criteria:
#> 
#>    Deviance (DIC)                             7519.099 
#>    Effective parameters (pD)                    21.675 
#> 
#> Parameter Estimates:
#> 
#>    Marginalisation method                     SKEWNORM
#>    VB correction                                  TRUE
#> 
#> Latent Variables:
#>                    Estimate       SD     2.5%    97.5%      KLD    Prior       
#>   visual =~                                                                    
#>     x1                0.907    0.083    0.746    1.071    0.003    normal(0,10)
#>     x2                0.501    0.081    0.343    0.663    0.003    normal(0,10)
#>     x3                0.663    0.078    0.511    0.818    0.006    normal(0,10)
#>   textual =~                                                                   
#>     x4                0.999    0.058    0.888    1.116    0.021    normal(0,10)
#>     x5                1.112    0.063    0.990    1.238    0.023    normal(0,10)
#>     x6                0.926    0.054    0.820    1.032    0.019    normal(0,10)
#>   speed =~                                                                     
#>     x7                0.617    0.077    0.463    0.766    0.012    normal(0,10)
#>     x8                0.734    0.077    0.587    0.887    0.010    normal(0,10)
#>     x9                0.681    0.079    0.530    0.838    0.058    normal(0,10)
#> 
#> Covariances:
#>                    Estimate       SD     2.5%    97.5%      KLD    Prior       
#>   visual ~~                                                                    
#>     textual           0.449    0.064    0.317    0.568    0.000       beta(1,1)
#>     speed             0.474    0.085    0.298    0.630    0.024       beta(1,1)
#>   textual ~~                                                                   
#>     speed             0.284    0.071    0.141    0.420    0.004       beta(1,1)
#> 
#> Variances:
#>                    Estimate       SD     2.5%    97.5%      KLD    Prior       
#>    .x1                0.558    0.121    0.351    0.825    0.000 gamma(1,.5)[sd]
#>    .x2                1.144    0.107    0.952    1.370    0.002 gamma(1,.5)[sd]
#>    .x3                0.849    0.097    0.676    1.056    0.000 gamma(1,.5)[sd]
#>    .x4                0.378    0.049    0.289    0.481    0.001 gamma(1,.5)[sd]
#>    .x5                0.453    0.059    0.347    0.579    0.000 gamma(1,.5)[sd]
#>    .x6                0.363    0.044    0.283    0.457    0.002 gamma(1,.5)[sd]
#>    .x7                0.825    0.090    0.664    1.017    0.039 gamma(1,.5)[sd]
#>    .x8                0.508    0.093    0.349    0.711    0.033 gamma(1,.5)[sd]
#>    .x9                0.553    0.090    0.398    0.751    0.053 gamma(1,.5)[sd]
#>     visual            1.000                                                    
#>     textual           1.000                                                    
#>     speed             1.000