View source: R/johnson_neyman.R
| jn_interval | R Documentation |
Identifies the values of the moderating variable at which the conditional effect of the other variable transitions between statistical significance and non-significance.
jn_interval(m, var1, var2, ci = 0.95)
m |
A model object ( |
var1 |
The name (as a string) of the variable whose conditional effect is of interest. |
var2 |
The name (as a string) of the moderating variable. |
ci |
A numeric value defining the confidence level. The default is 0.95. |
The Johnson-Neyman (JN) technique finds the values of the moderating
variable (var2) at which the conditional effect of var1 is
exactly at the boundary of statistical significance. This is computed
analytically from the regression coefficients and their variance-covariance
matrix.
For linear mixed-effects models (lmerMod, glmerMod), a normal
approximation (z-distribution) is used instead of the t-distribution due
to the controversy over appropriate degrees of freedom.
The function does not support factor variables or quadratic terms (var1 == var2).
An object of class jn_interval containing:
All Johnson-Neyman bounds (may be 0, 1, or 2 values).
Bounds that fall within the observed data range of var2.
The range of the moderating variable in the data.
One of "always", "never", "between", "outside", "below", or "above", indicating where the effect is statistically significant.
List of (xmin, xmax) pairs marking non-significant regions.
m <- lm(mpg ~ wt * cyl, data = mtcars)
jn <- jn_interval(m, "cyl", "wt")
print(jn)
# Add JN bounds to an interplot
interplot(m, "cyl", "wt") + jn_layer(jn)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.