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

sim_slopes seemingly not incorporating weights from lm() objects #79

Open
tgravelle opened this issue Dec 2, 2024 · 0 comments
Open
Labels
bug Something isn't working

Comments

@tgravelle
Copy link

Hello, in probing an interaction from a weighted linear model fit using lm() the simple slopes analysis from sim_slopes() that is output does not (apparently) make use of the observation weights.

For example, the model and simple slopes analysis below...

m_wtd <- lm(FB_manipulate ~ fb_fact_check
            + Gender + ln_age_years + Edu + RaceEthn + Region + Consp_Mentality + Ideology + PID
            + fb_fact_check*Consp_Mentality*Ideology, data = data.2a, weights = weight)

sim_slopes(m_wtd, pred = fb_fact_check, modx = Consp_Mentality, mod2 = Ideology,
           modx.values = cm_min_mean_max,
           modx.labels = c("Low", "Mean", "High"),
           mod2.values = ideol_lib_mod_con,
           mod2.labels = c("Very liberal", "Moderate", "Very conservative"),
           pvals = TRUE, interval = TRUE, digits = 5)

... returns the following results:

███████████████████████████████████ While Ideology (2nd moderator) =  0.509530222 (Very conservative) ███████████████████████████████████ 

SIMPLE SLOPES ANALYSIS

Slope of fb_fact_check when Consp_Mentality =  0.3555157 (High): 

     Est.      S.E.    t val.         p
--------- --------- --------- ---------
  0.07079   0.03593   1.97046   0.04890

Slope of fb_fact_check when Consp_Mentality =  0.0000000 (Mean): 

      Est.      S.E.     t val.         p
---------- --------- ---------- ---------
  -0.01930   0.02311   -0.83507   0.40376

Slope of fb_fact_check when Consp_Mentality = -0.6444843 (Low): 

      Est.      S.E.     t val.         p
---------- --------- ---------- ---------
  -0.18261   0.07417   -2.46222   0.01388

████████████████████████████████████████ While Ideology (2nd moderator) =  0.009530222 (Moderate) ███████████████████████████████████████ 

SIMPLE SLOPES ANALYSIS

Slope of fb_fact_check when Consp_Mentality =  0.3555157 (High): 

     Est.      S.E.    t val.         p
--------- --------- --------- ---------
  0.03080   0.02018   1.52637   0.12705

Slope of fb_fact_check when Consp_Mentality =  0.0000000 (Mean): 

      Est.      S.E.     t val.         p
---------- --------- ---------- ---------
  -0.00191   0.01151   -0.16592   0.86824

Slope of fb_fact_check when Consp_Mentality = -0.6444843 (Low): 

      Est.      S.E.     t val.         p
---------- --------- ---------- ---------
  -0.06120   0.03476   -1.76064   0.07843

██████████████████████████████████████ While Ideology (2nd moderator) = -0.490469778 (Very liberal) █████████████████████████████████████ 

SIMPLE SLOPES ANALYSIS

Slope of fb_fact_check when Consp_Mentality =  0.3555157 (High): 

      Est.      S.E.     t val.         p
---------- --------- ---------- ---------
  -0.00920   0.03993   -0.23034   0.81784

Slope of fb_fact_check when Consp_Mentality =  0.0000000 (Mean): 

     Est.      S.E.    t val.         p
--------- --------- --------- ---------
  0.01548   0.02137   0.72413   0.46906

Slope of fb_fact_check when Consp_Mentality = -0.6444843 (Low): 

     Est.      S.E.    t val.         p
--------- --------- --------- ---------
  0.06020   0.04869   1.23637   0.21644

Warning message:
Johnson-Neyman intervals are not available for factor predictors or moderators. 

... but removing the weights argument from the call to lm() as below...

m_unwtd <- lm(FB_manipulate ~ fb_fact_check
              + Gender + ln_age_years + Edu + RaceEthn + Region + Consp_Mentality + Ideology + PID
              + fb_fact_check*Consp_Mentality*Ideology, data = data.2a)

... and then running sim_slopes() with an unweighted linear model results returns the same simple slopes results as above.

Notably, submitting the weighted and unweighted lm() objects yields different results from interact_plot(). Further, the interaction plot generated by the weighted lm() object matches one generated by a svyglm() object, suggesting that interaction_plot() is incorporating the weights but sim_slopes() is not.

Thank you in advance!

@tgravelle tgravelle added the bug Something isn't working label Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant