I am working with NHANES survey data and I am trying to use a twophase survey design along with calibration to adjust for item non-response. For now, I am following an example from Lumley's Survey book pretty closely to do this. I have the following code below to set this up.

nhanes_df <- nhanes_df |>
  mutate(w2 = nrow(nhanes_df)/sum(1-MISSING)) |>
  mutate(psu = SDMVPSU + 10*SDMVSTRA)

nar_des <- twophase(id = list(~psu,~1),
                     strata = list(~SDMVSTRA, NULL),
                     subset = ~I(!MISSING),
                     weights = list(~WTMECFULL, ~w2),
                     data = nhanes_df,
                     method = "approx")

design <- calibrate(nar_des, phase = 2, calfun = "raking", formula=~IS_BLACK + IS_FEMALE + AGE_BIN)

However, I wanted to perform a final postStratify to a known Black population. This is to have the totals be consistent with previous results that were post stratified to this same black population. So, since postStratify is not implemented for twophase designs, I tried the following calibration:

pop.totals <- c(`(Intercept)`=us_pop_2018, IS_BLACKTRUE=black_pop_2018)

des_cal <- calibrate(design, formula=~factor(IS_BLACK), population=pop.totals, calfun=cal.raking, phase=2)

I realized that this is not providing the functionality I expected it to after running a svytotal

> svytotal(~IS_BLACK, des_cal)
                   total         SE
IS_BLACKFALSE 1.2539e+12 6.9900e+12
IS_BLACKTRUE  7.3503e+10 4.6717e+11

After some digging into the code, I noticed that the initial sample totals were the following

         (Intercept) factor(IS_BLACK)TRUE 
               91351                21416 

And these are in fact the number of entries in my entire dataframe as the Intercept and the number of Black individuals, not taking into account the overall survey weights. This makes sense given the twophase design, but is not what I am trying to calibrate to.

Is there a way to perform the type of simple post stratification I am trying to do on this twophase survey object? I am having trouble trying to reason about how this can work in conjunction with the twophase design object.


1 Answer 1


I think you want to calibrate phase 1 to the external population, not phase 2. Phase 2 weights shouldn't add up to the external population; they should add up to the phase 1 dataset.

Alternatively, you might calibrate phase 2 to the proportions from the external data, keeping the sample size at the real sample size.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.