Calculates weighted means with 95% confidence intervals for a continuous variable, optionally stratified by a grouping variable.

svymn(formula, design, by = NULL, na.rm = TRUE)

Arguments

formula

A formula (e.g., ~age).

design

A survey design object (from setup_survey_design()).

by

Optional formula for stratification (e.g., ~sex).

na.rm

Logical; if TRUE (default), omit NA values.

Value

A data frame with columns:

  • estimate: estimated mean

  • lower: 95% CI lower bound

  • upper: 95% CI upper bound

  • se: standard error

  • If by is specified: grouping column(s) prepended