Rao-Scott design-based ANOVA for survey_glm() fits. Accepts three input
shapes on object:
Arguments
- object
A survey_glm_fit, a list of survey_glm_fit objects, or a survey design (survey_base subclass).
- formula
A model formula (e.g.
y ~ x1 + x2). Only used whenobjectis a survey design. Passed through tosurvey_glm(); supplyingformulaalongsideresponse/predictorsis rejected bysurvey_glm()'s validator.- response
Character string naming the outcome variable. Only used when
objectis a survey design. Forwarded tosurvey_glm().- predictors
Character vector of predictor variable names. Only used when
objectis a survey design. Forwarded tosurvey_glm().- ...
Additional arguments forwarded to
survey_glm()whenobjectis a survey design (e.g.family,na.action,quiet). For fit or list inputs,...must be empty — any extras error viarlang::check_dots_empty()with fuzzy typo detection.- method
Character(1).
"LRT"(default) or"Wald".- test
Character(1).
"F"(default) or"Chisq"reference distribution.- null
Numeric or
NULL. Hypothesized value for the tested coefficients (Wald only). Only used whenobjectis a single survey_glm_fit or a survey design (reducing to single-model mode); ignored with warningsurveycore_warning_anova_null_ignoredwhenobjectis a list of fits.- tolerance
Numeric(1). Reciprocal-condition-number threshold for the naive-covariance near-singular gate in the Rao-Scott LRT. Default
sqrt(.Machine$double.eps).- decimals
Integer(1) or
NULL. Round double output columns.- label_vars
Logical(1). When
TRUE, compose term-row labels from@metadata@variable_labelsfor thetermcolumn. DefaultTRUE.- name_style
Character(1).
"surveycore"(default) or"broom".
Value
A survey_anova tibble with columns term, statistic, df,
ddf, deff, p_value, stars and a .meta attribute.
Details
A single survey_glm_fit — sequential mode, one row per term.
A list of survey_glm_fit objects — chained pairwise comparison, producing
length(object) - 1rows.A survey design (any survey_base subclass) — fits the model internally via
survey_glm()usingformula(orresponse+predictors), then runs sequential anova on the fit.
Supports the four method x test combinations shared with
survey::anova.svyglm(): Rao-Scott working-LRT with F or Chisq reference,
and design-based Wald with F or Chisq reference.
See also
Other analysis:
clean(),
get_corr(),
get_covariance(),
get_diffs(),
get_freqs(),
get_means(),
get_pairwise(),
get_quantiles(),
get_ratios(),
get_t_test(),
get_totals(),
get_variance(),
meta()
Examples
gss_cc <- gss_2024[
stats::complete.cases(gss_2024[, c("age", "sex", "educ")]),
]
gss_design <- as_survey(
gss_cc, ids = vpsu, weights = wtssps,
strata = vstrat, nest = TRUE
)
# Single fit
fit <- survey_glm(gss_design, age ~ sex + educ)
get_anova(fit)
#> # A tibble: 2 × 7
#> term statistic df ddf deff p_value stars
#> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <chr>
#> 1 sex 52.2 1 66 734. 0.784 ""
#> 2 educ 4521. 1 65 700. 0.0141 "*"
# Design + formula (fits internally)
get_anova(gss_design, age ~ sex + educ)
#> # A tibble: 2 × 7
#> term statistic df ddf deff p_value stars
#> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <chr>
#> 1 sex 52.2 1 66 734. 0.784 ""
#> 2 educ 4521. 1 65 700. 0.0141 "*"
# List of fits (chained pairwise comparison)
fit_s <- survey_glm(gss_design, age ~ sex)
fit_b <- survey_glm(gss_design, age ~ sex + educ)
get_anova(list(fit_s, fit_b))
#> # A tibble: 1 × 7
#> term statistic df ddf deff p_value stars
#> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <chr>
#> 1 educ | sex 4521. 1 65 700. 0.0141 *
