Different number of parameters bewteen different samples

25 views
Skip to first unread message

Jéssica Luz

unread,
Jul 2, 2024, 11:18:12 AM (21 hours ago) Jul 2
to lavaan
Hi everyone!

I'm analazyng data to validate 4 scales in Brazil. We are running CFA, and we have 2 samples. Sample 1: N= 307 (general population); Sample 2: N=94 (police workers).

My thesis advisor told me that the numbers of parameters should be the same for each scale between samples.  I checked the R syntax to be sure that it was the same for both samples, but we are finding different numbers of parameters (same df, though).

Does anybody know why this could happen? He told me that the syntax could be different, but I double checked and it was the same. This happened with all the 4 scales that we are working on.

Thanks a lot!

Shu Fai Cheung (張樹輝)

unread,
Jul 2, 2024, 11:17:03 PM (9 hours ago) Jul 2
to lavaan
Did you specify any of the indicators as ordinal when doing CFA? If you did, and the numbers of unique values in one or more ordinal indicators are not the same, then the number of parameters can be different, as shown below:

``` r
library(lavaan)
#> This is lavaan 0.6-18
#> lavaan is FREE software! Please report any bugs.
```

``` r

dat <- HolzingerSwineford1939

# Artificially convert the scores to 2 or 3 values
dat$x1 <- ifelse(dat$school == "Grant-White", cut(dat$x1, breaks = 3), cut(dat$x1, breaks = 2))
dat$x2 <- ifelse(dat$school == "Grant-White", cut(dat$x2, breaks = 3), cut(dat$x2, breaks = 2))
dat$x3 <- ifelse(dat$school == "Grant-White", cut(dat$x3, breaks = 3), cut(dat$x3, breaks = 2))
dat$x4 <- ifelse(dat$school == "Grant-White", cut(dat$x4, breaks = 3), cut(dat$x4, breaks = 2))

# Verify that the numbers of categorieas are different
xtabs(~ x1 + school, dat)
#>    school
#> x1  Grant-White Pasteur
#>   1          15      56
#>   2         100     100
#>   3          30       0
```

``` r
xtabs(~ x2 + school, dat)
#>    school
#> x2  Grant-White Pasteur
#>   1           4      85
#>   2         105      71
#>   3          36       0
```

``` r
xtabs(~ x3 + school, dat)
#>    school
#> x3  Grant-White Pasteur
#>   1          65      83
#>   2          52      73
#>   3          28       0
```

``` r
xtabs(~ x4 + school, dat)
#>    school
#> x4  Grant-White Pasteur
#>   1          17      99
#>   2          96      57
#>   3          32       0
```

``` r

mod <-
"
f1 =~ x1 + x2 + x3 + x4
"
fit_1 <- cfa(mod, dat[dat$school == "Grant-White", ], ordered = TRUE)
fit_2 <- cfa(mod, dat[dat$school == "Pasteur", ], ordered = TRUE)

# Check the model dfs and the number of parameters
fit_1
#> lavaan 0.6-18 ended normally after 16 iterations
#>
#>   Estimator                                       DWLS
#>   Optimization method                           NLMINB
#>   Number of model parameters                        12
#>
#>   Number of observations                           145
#>
#> Model Test User Model:
#>                                               Standard      Scaled
#>   Test Statistic                                 1.293       2.084
#>   Degrees of freedom                                 2           2
#>   P-value (Chi-square)                           0.524       0.353
#>   Scaling correction factor                                  0.644
#>   Shift parameter                                            0.077
#>     simple second-order correction
```

``` r
fit_2
#> lavaan 0.6-18 ended normally after 21 iterations
#>
#>   Estimator                                       DWLS
#>   Optimization method                           NLMINB
#>   Number of model parameters                         8
#>
#>   Number of observations                           156
#>
#> Model Test User Model:
#>                                               Standard      Scaled
#>   Test Statistic                                 3.309       3.929
#>   Degrees of freedom                                 2           2
#>   P-value (Chi-square)                           0.191       0.140
#>   Scaling correction factor                                  0.860
#>   Shift parameter                                            0.081
#>     simple second-order correction
```

<sup>Created on 2024-07-03 with [reprex v2.1.0](https://reprex.tidyverse.org)</sup>


The following confirmed that the number of thresholds are different, because there are two unique values in one group but three in another:

``` r

parameterEstimates(fit_1)
#>    lhs  op rhs    est    se      z pvalue ci.lower ci.upper
#> 5   x1   |  t1 -1.262 0.141 -8.946  0.000   -1.539   -0.986
#> 6   x1   |  t2  0.817 0.118  6.916  0.000    0.586    1.049
#> 7   x2   |  t1 -1.918 0.215 -8.915  0.000   -2.339   -1.496
#> 8   x2   |  t2  0.680 0.114  5.980  0.000    0.457    0.903
#> 9   x3   |  t1 -0.130 0.105 -1.241  0.215   -0.335    0.075
#> 10  x3   |  t2  0.867 0.120  7.220  0.000    0.631    1.102
#> 11  x4   |  t1 -1.189 0.136 -8.727  0.000   -1.456   -0.922
#> 12  x4   |  t2  0.770 0.117  6.608  0.000    0.542    0.998

```

``` r
parameterEstimates(fit_2)
#>    lhs  op rhs    est    se      z pvalue ci.lower ci.upper
#> 5   x1   |  t1 -0.361 0.103 -3.504  0.000   -0.563   -0.159
#> 6   x2   |  t1  0.113 0.101  1.117  0.264   -0.085    0.310
#> 7   x3   |  t1  0.080 0.101  0.798  0.425   -0.117    0.278
#> 8   x4   |  t1  0.344 0.103  3.345  0.001    0.142    0.546

```


-- Shu Fai
Reply all
Reply to author
Forward
0 new messages