lambda_gk() computes Goodman-Kruskal's Lambda, a proportional
reduction in error (PRE) measure for nominal variables.
Usage
lambda_gk(
x,
direction = c("symmetric", "row", "column"),
detail = FALSE,
conf_level = 0.95,
digits = 3L
)Arguments
- x
A contingency table (of class
table).- direction
Direction of prediction:
"symmetric"(default),"row"(column predicts row), or"column"(row predicts column).- detail
Logical. If
FALSE(default), return the estimate as a numeric scalar. IfTRUE, return a named numeric vector including confidence interval and p-value.- conf_level
A single number strictly between 0 and 1 giving the confidence level (default
0.95). Only used whendetail = TRUE. Set toNULLto omit the confidence interval. Any other value – including percentages such as95– raises a classed error (spicy_invalid_input).- digits
Number of decimal places used when printing the result (default
3). Only affects thedetail = TRUEoutput.
Value
Same structure as cramer_v(): a scalar when
detail = FALSE, a named vector when detail = TRUE.
The p-value tests H0: lambda = 0 (Wald z-test).
Details
Lambda measures how much prediction error is reduced when the independent variable is used to predict the dependent variable. It ranges from 0 (no reduction) to 1 (perfect prediction). Lambda can equal zero even when variables are associated if the modal category dominates in every column (or row).
The default direction = "symmetric" follows the SPSS and
DescTools convention: symmetric lambda is a standard,
well-defined variant with its own asymptotic standard error.
somers_d() deliberately differs (its default is "row")
because its symmetric form is a derived quantity without an
analytic SE; see its documentation.
Standard error formulas follow the DescTools implementations
(Signorell et al., 2024); see cramer_v() for full references.
References
Goodman, L. A., & Kruskal, W. H. (1954). Measures of association for cross classifications. Journal of the American Statistical Association, 49(268), 732-764. doi:10.2307/2281536
See also
goodman_kruskal_tau(), uncertainty_coef(),
assoc_measures()
Other association measures:
assoc_measures(),
contingency_coef(),
cramer_v(),
gamma_gk(),
goodman_kruskal_tau(),
kendall_tau_b(),
kendall_tau_c(),
phi(),
somers_d(),
uncertainty_coef(),
yule_q()
Examples
tab <- table(sochealth$smoking, sochealth$education)
lambda_gk(tab)
#> [1] 0
lambda_gk(tab, direction = "row")
#> [1] 0
lambda_gk(tab, direction = "column", detail = TRUE)
#> Estimate SE CI lower CI upper p
#> 0.000 0.000 0.000 0.000 --