sfcheung / semfindr

A find(e)r of influential cases and outliers in SEM
https://sfcheung.github.io/semfindr/
GNU General Public License v3.0
1 stars 0 forks source link

Multi groups issue #116

Open cicadawing opened 1 month ago

cicadawing commented 1 month ago

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 commented 1 month ago

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 commented 1 month ago

No worries ! Thank you for the wonderful package !

Unfortunately, like the example you have provided, my multiple group analysis uses different variables between the groups…

I eagerly await package updates for when this type of analysis can be used !

Best wishes and thanks again, Toby

Sent from Outlook for iOShttps://aka.ms/o0ukef


From: Shu Fai Cheung @.> Sent: Wednesday, May 15, 2024 7:27 PM To: sfcheung/semfindr @.> Cc: cicadawing @.>; Author @.> Subject: Re: [sfcheung/semfindr] Multi groups issue (Issue #116)

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.0https://reprex.tidyverse.org

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?

— Reply to this email directly, view it on GitHubhttps://github.com/sfcheung/semfindr/issues/116#issuecomment-2112019934, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AXRE5NIQTOM32V6SY4N3DA3ZCMTBFAVCNFSM6AAAAABHXUHWAGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMJSGAYTSOJTGQ. You are receiving this because you authored the thread.Message ID: @.***>