Reporting number of cases used in each missing pattern

79 views
Skip to first unread message

Guilherme

unread,
Mar 27, 2023, 4:58:54 AM3/27/23
to lavaan
Hello evryone, 

I'm fitting a sem model that includes different latent variables and regressions.
I have some missing data that will affect the whole model, therefore I had to use the pairwise method.

I wonder if lavaan could give me the number of cases (observations) used for calculating each regression, considering that this number will vary due to the pairwise method. It is important to me to know the percentage of data used for each regression.

I tried the semTable package but it seems to not have this feature.  

That's the main part of my code: 

``` r
    model <- lavaan::sem(
        model = syntax,
        data = data,
        estimator = "DWLS",
        missing = "pairwise",
        verbose = TRUE,
        control = list(iter.max = 5000),
        optim.method = list("NLMINB"),
    )
sum <- summary(model, standardized = TRUE, fit.measures = TRUE)
```

And the main output is the following (notice the number of missing patterns):

```
lavaan 0.6.13 ended normally after 1187 iterations

  Estimator                                       DWLS
  Optimization method                           NLMINB
  Number of model parameters                       481

  Number of observations                          1368
  Number of missing patterns                        13

Model Test User Model:
                                                     
... 
```

I can share the complete script and output if needed.

Regards,
Guilherme

Terrence Jorgensen

unread,
Mar 30, 2023, 6:05:48 AM3/30/23
to lavaan
  Number of missing patterns                        13

I think the mice package provides what you are looking for.

?md.pattern 

The far-left column will be the sample size per pattern.

Terrence D. Jorgensen    (he, him, his)
Assistant Professor, Methods and Statistics
Research Institute for Child Development and Education, the University of Amsterdam
http://www.uva.nl/profile/t.d.jorgensen


Reply all
Reply to author
Forward
0 new messages