View source: R/alpha_sensitivity.R
| alpha_sensitivity | R Documentation |
Computes how Cronbach's alpha changes as a function of either
the average inter-item correlation (\bar{r}) or the number
of items (k), holding the other parameter constant.
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
)
data |
A data frame or matrix of item responses. If provided,
|
k |
Number of items. Required if |
r_bar |
Average inter-item correlation. Required if |
vary |
Character string indicating which parameter to vary:
|
k_range |
Numeric vector of item counts to evaluate when
|
r_bar_range |
Numeric vector of average inter-item correlations
to evaluate when |
plot |
Logical; if |
digits |
Number of decimal places for rounding output.
Default is |
The function supports two modes:
Empirical: derive k and \bar{r} from a dataset
Theoretical: specify k and \bar{r} directly
A data frame with columns:
k: number of items
r_bar: average inter-item correlation
alpha: Cronbach's alpha
The returned object includes an attribute "baseline" containing
the reference k and \bar{r} values.
alpha, reliability
# Theoretical example
## Not run:
alpha_sensitivity(k = 6) # produces plot
## End(Not run)
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)
)
## Not run:
alpha_sensitivity(data = df) # produces plot
## End(Not run)
alpha_sensitivity(df, vary = "r_bar", plot = FALSE)
alpha_sensitivity(df, vary = "k", plot = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.