Skip to main content
deleted 1 character in body
Source Link

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, db0_cal2des_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.

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, db0_cal2)
                   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.

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.

Source Link

Post stratification on a twophase object in the R survey package

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, db0_cal2)
                   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.