Skip to contents

S7 class produced by survey_glm(). Holds all regression output from a survey-weighted generalised linear model: design-based coefficient estimates, variance-covariance matrix, fitted values, residuals, and model metadata.

Usage

survey_glm_fit(
  coefficients = integer(0),
  vcov = NULL,
  fitted_values = integer(0),
  residuals = integer(0),
  weights = integer(0),
  design = survey_base(),
  degf = integer(0),
  family = list(),
  formula = NULL,
  null_deviance = integer(0),
  deviance = integer(0),
  df_null = integer(0),
  df_residual = integer(0),
  converged = logical(0),
  call = NULL,
  fit_ = NULL,
  term_assign = integer(0)
)

Arguments

coefficients

Named numeric vector of length p.

vcov

p x p design-based variance-covariance matrix.

fitted_values

Numeric vector of length n (response scale).

residuals

Working residuals from IRLS, length n.

weights

Survey weights used in fitting, length n.

design

The original survey_base survey design object.

degf

Raw design degrees of freedom (positive scalar). For survey_taylor designs (including SRS, which is absorbed into Taylor): number of PSUs minus number of strata. For survey_replicate designs: number of replicates minus one. For survey_twophase: Phase 1 PSUs minus Phase 1 strata. For survey_nonprob: Inf (no design-based df). This is not the residual degrees of freedom used for t-statistics and confidence intervals; those are computed as degf - (p - 1) where p is the number of model coefficients.

family

GLM family object (e.g. gaussian(), binomial()).

formula

Model formula.

null_deviance

Null model deviance.

deviance

Residual deviance.

df_null

Classical null df (fit$df.null from stats::glm()).

df_residual

Classical residual df (fit$df.residual, i.e. n - p). Used for the deviance display; not the design-based residual df.

converged

Logical; whether IRLS converged.

call

The survey_glm() call (language object or NULL).

fit_

Internal raw stats::glm() result; NULL after serialisation.

term_assign

Integer vector: attr(model.matrix(fit_), "assign") captured at fit time. Maps design-matrix columns to formula terms (0 = intercept; positive values index attr(terms(formula), "term.labels")). Required by get_anova()'s serialization-safe Wald path (spec §3.3.1): after @fit_ is stripped via saveRDS(), the term-to-column map survives in this slot. Default integer(0).

Value

A survey_glm_fit object.

Examples

# survey_glm_fit objects are created by survey_glm(), not directly
d <- as_survey(
  gss_2024,
  ids = vpsu,
  weights = wtssps,
  strata = vstrat,
  nest = TRUE
)
fit <- survey_glm(d, age ~ sex)
fit@coefficients
#> (Intercept)         sex 
#>  47.5603545   0.2595301