Lisa Ullrich
Lisa Ullrich

Reputation: 1

Sampling weights in R with survey package

I am using a large, complex dataset for my analysis, where sampling weights should be used for the analysis to get more unverserable results. The study is the Add Health data, of which I am using two measurement time points (baseline and wave4). Here it is unclear to me how I can include two sample weights (for baseline and wave4) in order to calculate my multilevel model later? I have now decided to use the svydesign() function from the survey package.

My sample weight for baseline is weight_wave1, my sample weight for wave4 is weight_wave4.

load(data_total)
des_wave1 <-svydesign(id=~BA_identify_numb_integer, 
                      strata=~NULL,
                      weights=weight_wave1,
                      data=data_total)

Upvotes: 0

Views: 287

Answers (1)

Thomas Lumley
Thomas Lumley

Reputation: 2765

I have good news and bad news.

The good news: there's no problem with including two weights. Just write your data in 'long' format, so that an individual's record for baseline and for wave 4 are in separate records (with an id variable to link them). Then you can use the baseline weight for the baseline data and the wave 4 weight for the wave 4 data.

Or, if wave 4 is a strict subset of baseline, just use the wave 4 weights and drop the baseline records for people who don't have wave 4.

The bad news: multilevel models for complex survey data are not entirely straightforward. You likely want to ask on stats.stackexchange about how to fit your multilevel model taking weights into account.

Upvotes: 0

Related Questions