Iterative proportional fitting of the margins in margins (1-based axis
vectors as loglin), e.g. list(1, 2, 3) for mutual independence (Hedderich,
Sachs & Reynarowych 2023, sec. 8.5.5, eq 8.100), with G^2, Pearson X^2
(eq 8.106), Pearson residuals and df = cells minus the parameters of every
axis subset inside a margin.
Usage
ll3way(table, margins, tol = 1e-12, max_iter = 10000)
Arguments
- table
I x J x K array of counts.
- margins
List of axis vectors.
- tol
Convergence tolerance on the fitted counts.
- max_iter
Iteration limit.
Value
Named list: fit, residuals, lrt, pearson, df, p_lrt, p_pearson.
References
Bishop, Y. M. M., Fienberg, S. E. & Holland, P. W. (1975).
Discrete Multivariate Analysis, ch. 3.
Examples
ll3way(array(c(911, 538, 44, 456, 3, 43, 2, 279), c(2, 2, 2)), list(c(1, 2), c(1, 3), c(2, 3)))$lrt
#> [1] 0.3739859