% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/johnson_neyman.R
\name{jn_interval}
\alias{jn_interval}
\title{Compute Johnson-Neyman Interval for Interaction Effects}
\usage{
jn_interval(m, var1, var2, ci = 0.95)
}
\arguments{
\item{m}{A model object (\code{lm}, \code{glm}, \code{lmerMod}, or \code{glmerMod}).}

\item{var1}{The name (as a string) of the variable whose conditional effect is of interest.}

\item{var2}{The name (as a string) of the moderating variable.}

\item{ci}{A numeric value defining the confidence level. The default is 0.95.}
}
\value{
An object of class \code{jn_interval} containing:
\describe{
  \item{bounds}{All Johnson-Neyman bounds (may be 0, 1, or 2 values).}
  \item{bounds_in_range}{Bounds that fall within the observed data range of \code{var2}.}
  \item{var2_range}{The range of the moderating variable in the data.}
  \item{sig_pattern}{One of \code{"always"}, \code{"never"}, \code{"between"}, \code{"outside"}, \code{"below"}, or \code{"above"}, indicating where the effect is statistically significant.}
  \item{ns_regions}{List of \code{(xmin, xmax)} pairs marking non-significant regions.}
}
}
\description{
Identifies the values of the moderating variable at which the
conditional effect of the other variable transitions between
statistical significance and non-significance.
}
\details{
The Johnson-Neyman (JN) technique finds the values of the moderating
variable (\code{var2}) at which the conditional effect of \code{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 (\code{lmerMod}, \code{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 (\code{var1 == var2}).
}
\examples{
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)

}
