Returns a survey::svydesign object when survey is available; otherwise
returns a lightweight list with the same fields the morie helpers consume.
Usage
morie_survey_design(
data,
weights_col,
strata_col = NULL,
cluster_col = NULL,
fpc_col = NULL,
nest = FALSE
)
Arguments
- data
data.frame.
- weights_col
Column name of analytic/probability weights.
- strata_col
Optional strata column.
- cluster_col
Optional PSU/cluster column.
- fpc_col
Optional finite-population-correction column.
- nest
If TRUE, treat cluster IDs as nested within strata.
Value
An object of class "morie_survey_design_fallback".
Examples
set.seed(1)
df <- data.frame(y = rnorm(40), w = runif(40, 0.5, 2),
s = rep(c("a", "b"), 20))
d <- morie_survey_design(df, "w", strata_col = "s")
class(d)
#> [1] "survey.design2" "survey.design"