Learn R Programming

factorH (version 0.5.0)

balance.chisq.datatable: Count-balance chi-square diagnostics across factors

Description

For one factor: chi-square goodness-of-fit vs equal proportions. For two factors: chi-square test of independence. For three or more: log-linear independence (Poisson, main effects only) via deviance and df.

Usage

balance.chisq.datatable(formula, data, force_factors = TRUE, correct = FALSE)

Value

A data.frame with one row per factor combination (Effect) and columns: n, ChiSq (4 decimals), df, p.chisq (4 decimals), OK.

Arguments

formula

A model formula y ~ A + B (+ C ...); the response is ignored.

data

A data frame with the variables.

force_factors

Logical; if TRUE, coerces RHS predictors to factors.

correct

Logical; continuity correction for 2x2 tables in chisq.test (default FALSE).

Details

Uses stats::chisq.test for 1–2 factors. For 3+ factors, prefers MASS::loglm if available; otherwise falls back to a Poisson GLM on the count table.

See Also

plan.diagnostics

Examples

Run this code
if (FALSE) {
balance.chisq.datatable(liking ~ gender + condition + age_cat, data = mimicry)
}

Run the code above in your browser using DataLab