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

[Bug]: Equality Constraints in Multigroup SEM have at least 2 bugs #2225

Closed
2 of 3 tasks
HeikoBreitsohl opened this issue Jul 14, 2023 · 7 comments · Fixed by jasp-stats/jaspSem#211 or jasp-stats/jaspSem#215
Closed
2 of 3 tasks
Assignees
Labels
Bug: High Bugs that are negatively affecting the area of the program, but don't need immediate fix. Module: jaspSem

Comments

@HeikoBreitsohl
Copy link

JASP Version

0.17.2.1

Commit ID

No response

JASP Module

SEM

What analysis are you seeing the problem on?

Multigroup SEM with Equality Constraints

What OS are you seeing the problem on?

Windows 10

Bug Description

When adding equality constraints, some constraint options add unwanted constraints, while others don't do anything:

  • "Loadings" adds constraints on loadings AND factor covariances
  • "Means" adds constraints, but does not add labels to the output table
  • "Factor variances" does not change anything
  • "Factor covariances" does not change anything
    The others seem to work. [I did not check "Thresholds".]

[By the way, this all works fine in the CFA module.]

Expected Behaviour

Each constraint option should add only one type of constraint (and the corresponding labels).

Steps to Reproduce

  1. Open the Holzinger-Swineford data (Data Library -> Mental Ability)

  2. Specify factors, e.g.
    Factor1=~x1+x2+x3
    Factor2=~x4+x5+x6
    Factor3=~x7+x8+x9

  3. Select grouping variable "School"

  4. Add equality constraints
    See screenshots for some examples.
    SEM_Constraining_FactorVariances_does_nothing
    SEM_FactorCovariances_constrained_erroneously

Log (if any)

No response

Final Checklist

  • I have included a screenshot showcasing the issue, if possible.
  • I have included a JASP file (zipped) or data file that causes the crash/bug, if applicable.
  • I have accurately described the bug, and steps to reproduce it.
@tomtomme
Copy link
Member

tomtomme commented Feb 7, 2024

@HeikoBreitsohl
Thx for reporting. Is this still an issue with jasp 0.18.3?

@HeikoBreitsohl
Copy link
Author

@tomtomme
Yes, the issues are still there:

Loadings: the same issue remains (JASP adds constraints on loadings AND factor covariances).
Intercepts: Works fine (as before).
Residuals: Works fine (as before).
Residual covariances: Works fine.
Means: same issue (adds constraints, but does not add labels to the output table).
Regressions: Works fine.
Latent variances: same issue (does not change anything).
Latent covariances: same issue (does not change anything).

@tomtomme tomtomme added Bug: High Bugs that are negatively affecting the area of the program, but don't need immediate fix. and removed Bug labels Feb 7, 2024
@tomtomme
Copy link
Member

@juliuspfadt
This one seems to be a serious bug. It is also mentioned here that equality constraints worked with jasp 0.16.4 just fine: #2046

@juliuspfadt
Copy link
Contributor

I will check it

@juliuspfadt
Copy link
Contributor

Okay. so there was a spelling error in the R code so the factor variances constraint was not taken into account properly. Some of the errors are not actually errors though.

  • "Loadings" adds constraints on loadings AND factor covariances:
    that is fixed by correcting the typo
  • "Means" adds constraints, but does not add labels to the output table
    Sine latent intercepts are fixed to zero, clicking "means" will actually do nothing, that is correct. We might add a note to the table
  • "Factor variances" does not change anything:
    In your code the factor variances are fixed to unity for the factor scaling, so these are not subject to constraints anymore. We might add a note here.
  • "Factor covariances" does not change anything: fixed by correcting the typo.

@HeikoBreitsohl
Copy link
Author

Thanks for the clarification, and sorry for my confusion.

To be sure, I went through (almost) all options for invariance testing, for each method of factor scaling.
I used this model:
Factor1=~ x1+x2+x3
Factor2=~ x4+x5+x6
Factor3=~ x7+x8+x9
x1~~x4
Factor3~Factor1+Factor2

Factor scaling: Factor loadings

  1. Adding constraints on factor loadings: Adds unwanted constraints on factor covariances
  2. Adding constraints on intercepts: Works fine (adds constraints to intercepts, free factor means in the second group)
  3. Adding constraints on residuals: Works fine
  4. Adding constraints on residual covariances: Works fine
  5. Adding constraints on means: Does add constraints (or, more precisely, fixes; see also my summary below), but does not label them
  6. [I did not test thresholds.]
  7. Adding constraints on regressions: Works fine
  8. Adding constraints on factor variances: Does not do anything (remain freely estimated)
  9. Adding constraints on factor covariances: Adds constraints on the variances!

Factor scaling: Factor variance

  1. Adding constraints on factor loadings: Adds unwanted constraints on factor covariances (but does correctly free factor variances in the second group)
  2. Adding constraints on intercepts: Works fine (adds constraints to intercepts, free factor means in the second group)
  3. Adding constraints on residuals: Works fine
  4. Adding constraints on residual covariances: Works fine
  5. Adding constraints on means: Does add constraints (or, more precisely, fixes), but does not label them
  6. [I did not test thresholds.]
  7. Adding constraints on regressions: Works fine
  8. Adding constraints on factor variances: Does not do anything (remain freely estimated)
  9. Adding constraints on factor covariances: Adds constraints on the variances!

Factor scaling: Effects coding

  1. Adding constraints on factor loadings: Adds unwanted constraints on factor covariances
  2. Adding constraints on intercepts: Works fine
  3. Adding constraints on residuals: Works fine
  4. Adding constraints on residual covariances: Works fine
  5. Adding constraints on means: Does not do anything (Before adding these constraints, factor means were correctly freely estimated in both groups.)
  6. [I did not test thresholds.]
  7. Adding constraints on regressions: Works fine
  8. Adding constraints on factor variances: Does not do anything (remain freely estimated)
  9. Adding constraints on factor covariances: Adds constraints on the variances!

Summary and some observations:

  • Some (partially known) bugs involve the commands for constraints on factor loadings, factor variances, and factor covariances.
  • There is also an issue with constraining factor means, particularly with effects coding.
  • I find it inconvenient that you have to actively "Include mean structure" after adding constraints that affect the mean structure (e.g., on the manifest intercepts). I think it would be an improvement if the mean structure option would be activated automatically when adding constraints on manifest intercepts and/or factor means.
  • Not providing the labeling when constraining factor means seems like an inconsistent procedure. I do like that the labels are numbered, so users can check the total number of constraints. But this only works if all invariance constraints are labeled!
  • It might be confusing to users that, by default, there is a checkmark indicating that factor means are fixed to zero. Perhaps this option could be "inverted" and renamed ("Free latent intercepts")? That way, none of the boxes would be checked by default, which seems more intuitive.

@juliuspfadt
Copy link
Contributor

@HeikoBreitsohl Thanks a lot for the detailed list. I will get on some more fixes soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug: High Bugs that are negatively affecting the area of the program, but don't need immediate fix. Module: jaspSem
Projects
None yet
4 participants