Melogit and Weights [message #19634] |
Thu, 23 July 2020 10:19 |
Yawo
Messages: 45 Registered: February 2019
|
Member |
|
|
Hello,
I am trying to fit a multilevel model examining HIV risk behaviors among those living with HIV using a pooled data from 23 countries.
My model nests individuals (level 1) into clusters (level 2). For melogit, I am aware I need to set weights at the two levels of my analysis, yet DHS only provides one weight.
From my review of forum here ( https://userforum.dhsprogram.com/index.php?t=msg&goto=13 522&&srch=multilevel+weights#msg_13522), I understand I can svyset my data, using the following:
gen weight=hiv05/1000000
gen weight2=1
svyset idhspsu, weight(weight) strata(idhsstrata) singleunit(centered) || _n, weight(weight2)
When I run my basic melogit, <svy: melogit condomless_spouse sex || idhspsu: >
I get the following error: "weights in variable weight not constant within groups defined by: idhspsu an error occurred when svy executed melogit"
I am sure I may not be doing something wrong here. I would be very grateful if any of you could point me in te right direction.
Thanks in advance of your assistance.
cY
|
|
|
|
Re: Melogit and Weights [message #19636 is a reply to message #19635] |
Thu, 23 July 2020 17:09 |
BillC
Messages: 6 Registered: July 2020
|
Member |
|
|
Hi Trevor,
Am facing the same issue as Yawo. I am examining a multilevel model in Afghanistan and want to run a random intercept model with region (v024) as the second level.
A) Here is my code (based on Shireen's post):
gen wt=v005/1000000
gen wt2=1
svyset region, weight(wt) strata(v023) , singleunit(centered) || _n, weight(wt2)
Stata output follows:
Note: Stage 1 is sampled with replacement; further stages will be ignored for variance estimation.
pweight: <none>
VCE: linearized
Single unit: centered
Strata 1: v023
SU 1: region
FPC 1: <zero>
Weight 1: wt
Strata 2: <one>
SU 2: <observations>
FPC 2: <zero>
Weight 2: wt2
B) Here is the Stata output for the svy: melogit model
(running melogit on estimation sample)
weights in variable wt not constant within groups defined by: region
an error occurred when svy executed melogit
C) Here is the output of the code you suggested to check if there is variation in the min/max of wt2:
wt2 | Freq. Percent Cum.
------------+-----------------------------------
1 | 29,461 100.00 100.00
------------+-----------------------------------
Total | 29,461 100.00
Thoughts?
Thanks!
|
|
|
|
|
Re: Melogit and Weights [message #19639 is a reply to message #19638] |
Thu, 23 July 2020 17:46 |
BillC
Messages: 6 Registered: July 2020
|
Member |
|
|
Hi Trevor,
Many thanks for the quick reply - appreciate it. Its been a long day tussling with code, so my brain is a bit addled.
I used this code for svyset and it worked well for the logit command:
generate wgt = v005/1000000
svyset[pw=wgt], psu(v021) strata(v022)
svy: logit outcome iv1 iv2, or (this worked fine)
If I want to use v024(region) as the clustering variable for Level 2, what is the svyset code?
Thanks again,
|
|
|
|
|
|
|
Re: Melogit and Weights [message #19730 is a reply to message #19723] |
Thu, 06 August 2020 00:40 |
Yawo
Messages: 45 Registered: February 2019
|
Member |
|
|
Hi Trevor:
Thanks very much for your assistance. Here is the code I've been using:
/* creating psu and strata for pooled samples/countries */
egen psupool= group(idhspsu sample)
egen stratapool= group(idhsstrata sample)
gen weight=hiv05/1000000
gen weight2=1
svyset psupool, weight(weight) strata(stratapool) singleunit(centered) || _n, weight(weight2)
My data still shows non-constant weights in some of the PSU's
Below is a sample of 4 PSU's from Angola. I checked and many other data (including freshly downloaded versions from DHS) have non-constant weights within PSUs.
Thanks again, and looking forward to any further advice from you.
best - cY
. list sample idhspsu psupool weight weight2 v005 in 200/250
. list sample idhspsu psupool weight weight2 v005 in 200/250
[font=Courier]
+--------------------------------------------------------------------+
| sample idhspsu psupool weight weight2 v005 |
|--------------------------------------------------------------------|
200. | Angola 2015 2401000011 11 3.262758 1 2.964534 |
201. | Angola 2015 2401000011 11 2.894893 1 2.836539 |
202. | Angola 2015 2401000011 11 2.894893 1 2.836539 |
203. | Angola 2015 2401000011 11 3.262758 1 2.964534 |
204. | Angola 2015 2401000011 11 3.262758 1 2.964534 |
|--------------------------------------------------------------------|
205. | Angola 2015 2401000011 11 2.894893 1 2.836539 |
206. | Angola 2015 2401000011 11 2.894893 1 2.836539 |
207. | Angola 2015 2401000011 11 3.262758 1 2.964534 |
208. | Angola 2015 2401000011 11 3.262758 1 2.964534 |
209. | Angola 2015 2401000011 11 3.262758 1 2.964534 |
|--------------------------------------------------------------------|
210. | Angola 2015 2401000011 11 3.262758 1 2.964534 |
211. | Angola 2015 2401000011 11 3.262758 1 2.964534 |
212. | Angola 2015 2401000011 11 2.894893 1 2.836539 |
213. | Angola 2015 2401000011 11 3.262758 1 2.964534 |
214. | Angola 2015 2401000011 11 2.894893 1 2.836539 |
|--------------------------------------------------------------------|
215. | Angola 2015 2401000011 11 2.894893 1 2.836539 |
216. | Angola 2015 2401000011 11 2.894893 1 2.836539 |
217. | Angola 2015 2401000011 11 3.262758 1 2.964534 |
218. | Angola 2015 2401000011 11 3.262758 1 2.964534 |
219. | Angola 2015 2401000011 11 2.894893 1 2.836539 |
|--------------------------------------------------------------------|
220. | Angola 2015 2401000012 12 .396283 1 .41734 |
221. | Angola 2015 2401000012 12 .40295 1 .437145 |
222. | Angola 2015 2401000012 12 .40295 1 .437145 |
223. | Angola 2015 2401000012 12 .40295 1 .437145 |
224. | Angola 2015 2401000012 12 .396283 1 .41734 |
|--------------------------------------------------------------------|
225. | Angola 2015 2401000012 12 .396283 1 .41734 |
226. | Angola 2015 2401000012 12 .396283 1 .41734 |
227. | Angola 2015 2401000012 12 .40295 1 .437145 |
228. | Angola 2015 2401000012 12 .396283 1 .41734 |
229. | Angola 2015 2401000012 12 .40295 1 .437145 |
|--------------------------------------------------------------------|
230. | Angola 2015 2401000012 12 .40295 1 .437145 |
231. | Angola 2015 2401000012 12 .40295 1 .437145 |
232. | Angola 2015 2401000012 12 .40295 1 .437145 |
233. | Angola 2015 2401000012 12 .40295 1 .437145 |
234. | Angola 2015 2401000012 12 .396283 1 .41734 |
|--------------------------------------------------------------------|
235. | Angola 2015 2401000012 12 .40295 1 .437145 |
236. | Angola 2015 2401000012 12 .396283 1 .41734 |
237. | Angola 2015 2401000012 12 .40295 1 .437145 |
238. | Angola 2015 2401000012 12 .40295 1 .437145 |
239. | Angola 2015 2401000013 13 .586726 1 .595693 |
|--------------------------------------------------------------------|
240. | Angola 2015 2401000013 13 .547652 1 .604053 |
241. | Angola 2015 2401000013 13 .586726 1 .595693 |
242. | Angola 2015 2401000013 13 .547652 1 .604053 |
243. | Angola 2015 2401000013 13 .586726 1 .595693 |
244. | Angola 2015 2401000013 13 .547652 1 .604053 |
|--------------------------------------------------------------------|
245. | Angola 2015 2401000013 13 .547652 1 .604053 |
246. | Angola 2015 2401000013 13 .586726 1 .595693 |
247. | Angola 2015 2401000013 13 .547652 1 .604053 |
248. | Angola 2015 2401000013 13 .547652 1 .604053 |
249. | Angola 2015 2401000014 14 .503401 1 .477899 |
|--------------------------------------------------------------------|
250. | Angola 2015 2401000014 14 .465081 1 .491306 |
+--------------------------------------------------------------------+[/font]
[Updated on: Thu, 06 August 2020 00:42] Report message to a moderator
|
|
|
Re: Melogit and Weights [message #20070 is a reply to message #19730] |
Wed, 23 September 2020 04:26 |
Daniel
Messages: 4 Registered: July 2019
|
Member |
|
|
Hi there-- I am wondering if Yawo or/and BillC came across solutions/suggestions to your concerns, because I am facing the same problem after pooling one recent survey from multiple countries.
I appreciated any assistance.
[Updated on: Wed, 23 September 2020 04:28] Report message to a moderator
|
|
|
Re: Melogit and Weights [message #20079 is a reply to message #20070] |
Wed, 23 September 2020 11:38 |
Trevor-DHS
Messages: 803 Registered: January 2013
|
Senior Member |
|
|
In Yawo's example, I'm not certain exactly what the data is, but it looks to me like this is a combination of data for women and for men, and using the HIV weight (hiv05). Women and men's datasets have separate different weights, but the weights for women in a PSU (cluster) are constant as are the weights for men.
You may be interested in a recent publication Multilevel Modeling Using DHS Surveys: A Framework to Approximate Level-Weights that provides information on how to produce approximate level-1 and level-2 weights from published data.
|
|
|