Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi groups issue #116

Open
cicadawing opened this issue May 15, 2024 · 2 comments
Open

Multi groups issue #116

cicadawing opened this issue May 15, 2024 · 2 comments

Comments

@cicadawing
Copy link

Hi there!

I am trying to run lavaan_rerun() on a fitted object with a lavaan object with 2 groups.

I thought that multi-group data was supported by semfindr per documentation, but I get the following error:

>   approx_check(fit_bass_ack_base)
[1] -2
attr(,"info")
[1] "Multigroup models are not yet supported."                                                                                                        
[2] "The approximation method is tested only for models fitted by ML, with normal theory standard errors and normal theory chi-square test requested."
>   fit_bass_ack_base_LOO <- lavaan_rerun(fit_bass_ack_base, parallel=TRUE)
Error in rbind(deparse.level, ...) : 
  numbers of columns of arguments do not match
> fit_bass_ack_base
lavaan 0.6.17 ended normally after 1 iteration

  Estimator                                         ML
  Optimization method                           NLMINB
  Number of model parameters                       100

  Number of observations per group:                   
    Never_Experienced                              386
    Experienced                                    250
  Number of missing patterns per group:               
    Never_Experienced                                1
    Experienced                                      1

Model Test User Model:
                                              Standard      Scaled
  Test Statistic                                18.913      18.073
  Degrees of freedom                                20          20
  P-value (Chi-square)                           0.528       0.583
  Scaling correction factor                                  1.046
    Yuan-Bentler correction (Mplus variant)                       
  Test statistic for each group:
    Never_Experienced                           12.580      12.022
    Experienced                                  6.333       6.051

I am using:
semfindr_0.1.8
lavaan_0.6-17

@sfcheung
Copy link
Owner

Thanks for reporting this.

Regarding approx_check(), we forgot to change the default value of the argument multiple_group. When called by fucntions like est_change_approx(), they correctly set multiple_group to TRUE. Therefore, despite the default value of approx_check(), other functions know that multiple group models are supported by the approximation method. Therefore, this default value will not affect other function. We will fix this issue in the nex version.

Regarding the error message, do the within-group models in your multiple group model has different variables, as in the following example?

library(lavaan)
#> This is lavaan 0.6-17
#> lavaan is FREE software! Please report any bugs.
library(semfindr)

HS.model <-
"
group: Grant-White

visual  =~ x1 + x2 + x3 + x7
textual =~ x4 + x5 + x6 + x8

group: Pasteur

visual  =~ x1 + x2 + x3 + x7
textual =~ x4 + x5 + x6
"

fit <- cfa(HS.model,
           data = HolzingerSwineford1939,
           group = "school")
fit_rerun <- lavaan_rerun(fit)
#> Error in rbind(deparse.level, ...): numbers of columns of arguments do not match

Created on 2024-05-15 with reprex v2.1.0

If this is the case, unfortunately, semfindr does not (yet) support this kind of multigroup models.

If your model is not like this one, may you run traceback() right after the error message such that I can learn more where the error occured?

@cicadawing
Copy link
Author

cicadawing commented May 15, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants