This function creates a survey design object using the srvyr
package. It takes a data frame and specified columns for IDs, strata, weights, and variables, and returns a survey design object.
mps_design(df = NULL, ids, strata, weight, vars)
A data frame containing the survey data. Default is NULL.
A column name in the data frame representing the cluster or primary sampling unit (PSU) IDs.
A column name in the data frame representing the strata.
A column name in the data frame representing the survey weights.
A character vector of variable names to include in the survey design.
A survey design object created using the srvyr
package.
if (FALSE) { # \dontrun{
# Example usage:
survey_design <- mps_design(df = your_dataframe, ids = "psu_id", strata = "strata", weight = "weight", vars = c("var1", "var2", "var3"))
} # }