jacob-long / jacob-long/interactions

`sim_slopes` seemingly not incorporating weights from lm() objects

Open
#79 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
R
Stars
135
Forks
19
PR merge metrics
No merged PRs in 30d

Description

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!

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the weighted and unweighted lm() examples with sim_slopes(), then compare their output with interact_plot() and the svyglm() result. Trace how sim_slopes() handles lm() objects and weights; done means the weighted model's simple-slopes results incorporate its observation weights rather than matching the unweighted model.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
data
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.