% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/alpha_sensitivity.R
\name{alpha_sensitivity}
\alias{alpha_sensitivity}
\title{Sensitivity of Cronbach's alpha to scale design parameters}
\usage{
alpha_sensitivity(
  data = NULL,
  k = NULL,
  r_bar = NULL,
  vary = c("r_bar", "k"),
  k_range = NULL,
  r_bar_range = NULL,
  plot = TRUE,
  digits = 3
)
}
\arguments{
\item{data}{A data frame or matrix of item responses. If provided,
\eqn{k} and \eqn{\bar{r}} are computed from the data.}

\item{k}{Number of items. Required if \code{data} is not supplied.}

\item{r_bar}{Average inter-item correlation. Required if \code{data}
is not supplied.}

\item{vary}{Character string indicating which parameter to vary:
\code{"r_bar"} (default) or \code{"k"}.}

\item{k_range}{Numeric vector of item counts to evaluate when
\code{vary = "k"}. Default is \code{2:20}.}

\item{r_bar_range}{Numeric vector of average inter-item correlations
to evaluate when \code{vary = "r_bar"}. Default is
\code{seq(0.05, 0.9, by = 0.05)}.}

\item{plot}{Logical; if \code{TRUE}, a base R plot is produced.
Default is \code{TRUE}.}

\item{digits}{Number of decimal places for rounding output.
Default is \code{3}.}
}
\value{
A data frame with columns:
\itemize{
\item \code{k}: number of items
\item \code{r_bar}: average inter-item correlation
\item \code{alpha}: Cronbach's alpha
}

The returned object includes an attribute \code{"baseline"} containing
the reference \eqn{k} and \eqn{\bar{r}} values.
}
\description{
Computes how Cronbach's alpha changes as a function of either
the average inter-item correlation (\eqn{\bar{r}}) or the number
of items (\eqn{k}), holding the other parameter constant.
}
\details{
The function supports two modes:
\itemize{
\item Empirical: derive \eqn{k} and \eqn{\bar{r}} from a dataset
\item Theoretical: specify \eqn{k} and \eqn{\bar{r}} directly
}
}
\examples{
# Theoretical example

\dontrun{
alpha_sensitivity(k = 6) # produces plot
}

alpha_sensitivity(k = 6, r_bar = 0.4, plot = FALSE)

# Vary number of items
alpha_sensitivity(k = 6, r_bar = 0.4, vary = "k", plot = FALSE)

# Empirical example
df <- data.frame(
  V1 = c(1, 2, 3, 4, 5),
  V2 = c(3, 2, 4, 2, 5),
  V3 = c(2, 1, 5, 4, 3)
)

\dontrun{
alpha_sensitivity(data = df) # produces plot
}

alpha_sensitivity(df, vary = "r_bar", plot = FALSE)

alpha_sensitivity(df, vary = "k", plot = FALSE)

}
\seealso{
\code{\link{alpha}}, \code{\link{reliability}}
}
