Skip to content

Joining separate as_survey objects together #148

@themichjam

Description

@themichjam

I have complex survey data that has phase 1 and phase 2 weights. Is it possible to combine separate as_survey design objects together?

They all exist within the same survey wave, same amount of rows/obs etc, however some variables have their own specific weighting variable (e.g. "condition_2" has its own weighting variable "wt2_var").

Small example below (apologies it's not a reprex, I couldn't find an open df that had this issue):

# phase 1 weighting
weighted <- df1 %>%
  as_survey(
    strata = s_var,
    id = id_var, nest = TRUE,
    weights = wt1_var
  )

# subset specific variables needing weighted
df1_sub <- df1 %>% select("condition_2", "s_var", "id_var", wt2_var")

# phase 2 weighting specific variables within df1
weighted_2 <- df1_sub %>%
  as_survey(
    strata = s_var
    id = id_var, nest = TRUE,
    weights = wt2_var
  )

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions