jacob-long / jacob-long/interactions

Different Johnson-Neyman intervals from johnson_neyman and sim_slopes when including quadratic terms

Open
#46 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
R
Stars
135
Forks
19
PR merge metrics
No merged PRs in 30d

Description

Thanks for this great package. I am getting inconsistent Johnson-Neyman intervals where I would expect the same output. I am not entirely sure if my analysis strategy is correct - I am including squared terms for the two variables that interact to ensure that the interaction is not just a spurious result due to the presence of a quadratic effect and a correlation between the two variables. If it is not, this problem might never arise with correct analyses - as it stands, however, I cannot explain the discrepancy between the two results shown below:

``` r
library(interactions)
mod <- lm(mpg ~ wt*cyl + I(wt^2) + I(cyl^2), mtcars)
johnson_neyman(mod, pred = "wt", modx = "cyl")
#> JOHNSON-NEYMAN INTERVAL
#>
#> When cyl is OUTSIDE the interval [-3.56, 1.29], the slope of wt is p < .05.
#>
#> Note: The range of observed values of cyl is [4.00, 8.00]
```

``` r
sim_slopes(mod, pred = "wt", modx = "cyl")
#> JOHNSON-NEYMAN INTERVAL
#>
#> When cyl is INSIDE the interval [3.99, 6.61], the slope of wt is p < .05.
#>
#> Note: The range of observed values of cyl is [4.00, 8.00]
#>
#> SIMPLE SLOPES ANALYSIS
#> (omitted)
```

Created on 2021-02-01 by the [reprex package](https://reprex.tidyverse.org) (v0.3.0)

The documentation of ` sim_slopes` refers to `johnson_neyman` for information on that test - if it calculates the interval differently, and that difference is intended, a note to that effect might be needed there?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the supplied mtcars model in R and compare the johnson_neyman() and sim_slopes() entry points, including their printed intervals and observed-range notes. Trace how each handles quadratic terms; done means the discrepancy is resolved or the intended difference is documented in sim_slopes for this case.

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
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.