Home » Data » Weighting data » Replicating Step 7 and Level-2 Weight from Report 27
Replicating Step 7 and Level-2 Weight from Report 27 [message #27257] |
Fri, 07 July 2023 22:48 ![Go to next message Go to next message](/theme/default/images/down.png) |
Yawo
Messages: 45 Registered: February 2019
|
Member |
|
|
Hello,
I am replicating the calculation of level weights, so I can clone them for other countries. I realized that the codes provided are almost identical for calculating the weights for HH and for women in Zimbabwe 2015. For example, step 7 advises us to use the following formula to generate the sample weights:
gen DHSwt = v005 / 1000000
However, on pg 10 of the report, there are directions (bullet 6 & 7) to get projected population figures for women for the survey year and divide those by number of women interviewed. But the code provided for Zimbabwe did not follow this approach. Out of curiosity, I went ahead and retrieved the pertinent population figures and calculated a new weight as follows:
gen newwt =.
replace newwt =(v005/1000000)*(4098000/9955)
gen DHSwt_2 = newwt/1000000
Of course, the figures are different, as I expected.
Question 1: Why is it the case that the procedures for approximating household and individual weights are identical for the Zimbabwe illustration and that the population figures were not used? More specifically, under what conditions would you use the projected population figures or not?
Question 2: Secondly, I fitted the test run (below) using the new weights:
svyset v001, strata(v022) weight(wt2) singleunit(centered) || _n, weight(wt1)
svy: melogit v474 i.sex ||v001:, or
I received the much-discussed error: "weights in variable wt2 not constant within groups defined by: v001" Following the advice of Tom reported in this post: https://userforum.dhsprogram.com/index.php?t=msg&th=9098 &start=0&, I generated the geometric mean version of wt2, as Tom advised below, and avoided the dreaded error.
Given that wt1 is revised from wt2? (ie: gen wt1 = d_HH/wt2), should we adjust wt1 as well with the revised wt2 (i.e., gen rev_wt1 = d_HH/rev_wt2?
Question 3 : But I have a follow-up question about the code below:
bysort v001: gen dif = 0
replace dif = 1 if v001 == v001[_n-1] & wt2 != wt2[_n-1]
browse if dif == 1
count if dif==1
I can see the code is trying to check for an error or consistency, and replacing missing values. But could you please clarify what it is exactly doing, and what answer one should be looking for?
I get very different results of the count variable depending on whether I use the original wt2 or the revised version:
wt2 count if dif==1 reports 7,652 cases
rev_wt2 count if dif2 == 1 reports 0 cases
Thanks in advance... Yy
[Updated on: Sun, 09 July 2023 10:14] Report message to a moderator
|
|
|
|
Re: Replicating Step 7 and Level-2 Weight from Report 27 [message #27279 is a reply to message #27276] |
Wed, 12 July 2023 17:20 ![Go to previous message Go to previous message](/theme/default/images/up.png) ![Go to next message Go to next message](/theme/default/images/down.png) |
Yawo
Messages: 45 Registered: February 2019
|
Member |
|
|
Thanks for your response. I understand the procedure, so just to be clear, I have two related questions:
Q1: Given that I am combining the data for both men and women, are the following codes ok now?
**************** STAGE A ********************
* 7: Prepare the adjusted final/individual adjusted weight for men and women: dividing population of women or men by the appropriate number interviewed; de-normalize the final weight */
gen newwt =.
replace newwt =(v005/1000000)*(4764000/10060) if sex==1
replace newwt =(v005/1000000)*(5538000/5135) if sex==2
label variable newwt "Population adjusted sample weight"
************ STAGE B: APPROXIMATE LEVEL-1 AND LEVEL-2 WEIGHTS ************
/*Step 1: De-normalize the final weight, using approximated normalization factor. */
gen d_HH = newwt * (M/m_c)
/* Step 2: Approximate the level-2 weight (get f variation factor; set alpha based equal split method (α=0.5), then generate wt 2) */
gen f = d_HH / ((A_h/a_c_h) * (M_h/S_h))
scalar alpha = 0.5
gen wt2 = (A_h/a_c_h)*(f^alpha)
/* Step 2B - OPTIONAL: Generate a revised level-2 weight by replacing it with its geometric mean [if needed to get resolve the "weights in variable wt2 not constant within groups defined by: v001" error - based on advice by Tom here in [message #21803]:https://userforum.dhsprogram.com/index.php?t=msg& ;amp ;amp ;amp;th=9098&goto=21803&#msg_21803
gen ln_wt2=log(wt2)
egen mean_wt2=mean(ln_wt2), by(v001)
gen rev_wt2=exp(mean_wt2)
drop ln_wt2
/* Step 3: Approximate the level-1 weight */
Q2: If rev_wt2 is used, then should we adjust the formula for wt1 as well: gen rev_wt1 = d_HH/rev_wt? By the same token, should we also change to the rev_wt2 in the loop (i.e, gen wt1_`i' = d_HH/wt2_`i')?
With much appreciation for your assistance.
Cy
[Updated on: Wed, 12 July 2023 22:51] Report message to a moderator
|
|
|
|
|
|
|
Goto Forum:
Current Time: Mon Sep 9 03:15:46 Coordinated Universal Time 2024
|