The DHS Program User Forum
Discussions regarding The DHS Program data and results
Home » Topics » General » Multilevel modeling (Problems with svy:melogit command while using weights)
Multilevel modeling [message #24792] Tue, 12 July 2022 00:20 Go to next message
w@dhs
Messages: 5
Registered: December 2019
Member
We are following your recent guidelines in'MULTILEVEL MODELING USING DHS SURVEYS: A FRAMEWORK TO APPROXIMATE LEVEL-WEIGHTS' file for weights calculation for domestic violence modules. So, for example,for Maldives, I've tried the following steps.
gen a_c_h=.
quietly levelsof v022, local(lstrata)
quietly foreach ls of local lstrata {
tab v021 if v022==`ls', matrow(T)
scalar stemp=rowsof(T)
replace a_c_h=stemp if v022==`ls'
}

gen A_h = 0
replace A_h =433 if v022 == 1.... to replace A_h = 54 if v022 == 21
gen M_h = 0
replace M_h =51 if v022 == 1....replace M_h = 68 if v022 == 21

gen m_c= 928
gen M = 58277
gen S_h = 25
(*** I have applied wt already so, I skipped this step gen wgt = v005 / 1000000)

gen d_IR = wgt * (M/m_c)
gen f = d_IR / ((A_h/a_c_h) * (M_h/S_h))

local alphas 0 0.1 .25 .50 .75 0.90 1
local i = 1
foreach dom of local alphas{
gen wt2_`i' = (A_h/a_c_h)*(f^`dom')
gen wt1_`i' = d_IR/wt2_`i'
local ++i
}

Then, I tried with the following
svyset v001, weight(wt2_4) strata(v022) , singleunit(centered) || _n, weight(wt1_4)
svy: melogit outcome var i.indpendent var i.independent var i.independent var || v001:

I've got "no observation". So, I re-run the lines "local i=1, ..} separately or all together. Sometimes, I've got the results with only a coefficient without SEs, P-value, and 95% CI results.

But, if I run without svy: in front of melogit, it gives me the result. But when I run post estimation command without svy, the AIC and BIC value are the same for all models (I have 4 models: null model, and using variables of different levels), which does not make sense.
Q1: How can I fix it?

Q2: Also, I used svy:melogit. But, in such case, STATA does not allow to use the post estimation command estat ic, n(#).
The results showed when I omit svy command, again, the AIC and BIC values are the same. W
Any suggestion for fixing it.

Thank you so much.
Re: Multilevel modeling [message #24818 is a reply to message #24792] Fri, 15 July 2022 14:47 Go to previous messageGo to next message
Janet-DHS is currently offline  Janet-DHS
Messages: 258
Registered: April 2022
Senior Member
Following is a response from DHS Senior Sampling Specialist, Mahmoud Elkasabi:

Yourcode has some mistakes, such as using the wrong values for v022 (I believe this is the reason for the errors) and the wrong number of completed HHs.
Below a fixed copy of the code that works in my side.

* a_c_h completed clusters by strata
gen a_c_h=.
quietly levelsof v022, local(lstrata)
quietly foreach ls of local lstrata {
tab v021 if v022==`ls', matrow(T)
scalar stemp=rowsof(T)
replace a_c_h=stemp if v022==`ls'
}


* check v022 values/labels
codebook v022 , tabulate(99)

* A_h total number of census clusters by strata
gen A_h = 0
replace A_h = 433 if v022 == 10
replace A_h = 41 if v022 == 20
replace A_h = 53 if v022 == 21
replace A_h = 32 if v022 == 22
replace A_h = 31 if v022 == 23
replace A_h = 50 if v022 == 24
replace A_h = 28 if v022 == 25
replace A_h = 25 if v022 == 26
replace A_h = 25 if v022 == 27
replace A_h = 15 if v022 == 28
replace A_h = 22 if v022 == 29
replace A_h = 6 if v022 == 30
replace A_h = 14 if v022 == 31
replace A_h = 11 if v022 == 32
replace A_h = 13 if v022 == 33
replace A_h = 29 if v022 == 34
replace A_h = 33 if v022 == 35
replace A_h = 23 if v022 == 36
replace A_h = 32 if v022 == 37
replace A_h = 27 if v022 == 38
replace A_h = 54 if v022 == 39

* M_h average number of households per cluster by strata
gen M_h = 0
replace M_h = 51 if v022 == 10
replace M_h = 62 if v022 == 20
replace M_h = 64 if v022 == 21
replace M_h = 74 if v022 == 22
replace M_h = 65 if v022 == 23
replace M_h = 58 if v022 == 24
replace M_h = 61 if v022 == 25
replace M_h = 62 if v022 == 26
replace M_h = 69 if v022 == 27
replace M_h = 65 if v022 == 28
replace M_h = 58 if v022 == 29
replace M_h = 50 if v022 == 30
replace M_h = 63 if v022 == 31
replace M_h = 59 if v022 == 32
replace M_h = 68 if v022 == 33
replace M_h = 60 if v022 == 34
replace M_h = 70 if v022 == 35
replace M_h = 69 if v022 == 36
replace M_h = 74 if v022 == 37
replace M_h = 56 if v022 == 38
replace M_h = 68 if v022 == 39

* m_c total number of completed households (added from the HR dataset)
gen m_c= 6050

* M total number of households in country
gen M = 58277

* S_h households selected per stratum
gen S_h = 25

gen DHSwt = v005 / 1000000

************************************************************ ************
* Stage B *** Approximate Levels-weight ***
************************************************************ ************

* Steps to approximate Level-1 and Level-2 weights from Household or Individual Weights
*Step 1. De-normalize the final weight, using approximated normalization factor
gen d_HH = DHSwt * (M/m_c)
gen dv_HH = (d005/1000000) * (M/m_c)

*Step 2. Approximate the Level-2 weight
* f the variation factor
gen f = d_HH / ((A_h/a_c_h) * (M_h/S_h))

* Calculating the levels-weight based on different values of alpha
local alphas 0 0.1 .25 .50 .75 0.90 1
local i = 1

foreach dom of local alphas{
gen wt2_`i' = (A_h/a_c_h)*(f^`dom')
gen wt1_`i' = d_HH/wt2_`i'
gen d1_`i' = dv_HH/wt2_`i'
local ++i
}
Re: Multilevel modeling [message #24838 is a reply to message #24818] Mon, 18 July 2022 21:08 Go to previous messageGo to next message
w@dhs
Messages: 5
Registered: December 2019
Member
Thank you so much. It helps. However, I still have two more questions related to the Philippines and Nepal data.
I am aware that there are some previous responses related to the Philippines. However, I still need to have some clarification. Please kindly see the file attached.
Very much appreciated.

Sincerely
w

[Updated on: Mon, 18 July 2022 21:09]

Report message to a moderator

Re: Multilevel modeling [message #24865 is a reply to message #24838] Thu, 21 July 2022 12:31 Go to previous message
Janet-DHS is currently offline  Janet-DHS
Messages: 258
Registered: April 2022
Senior Member
Following is a response from DHS Senior Sampling Specialist, Mahmoud Elkasabi:

Regarding the Philippines, you need to change tabulate (99) to tabulate (118) or to any number that is larger than 117 so all values/labels get printed.

Regarding Nepal, it looks like your problem is related to the melogit not to the clusters weight. Unfortunately, we cannot advise on that. However, I see from the error that it is related to the region codes; I would advise you to check the region variable.
Previous Topic: Trend analysis with different number of 'PSU' and 'Strata'
Next Topic: Variable v034: merging datasets
Goto Forum:
  


Current Time: Wed Nov 30 21:57:34 Coordinated Universal Time 2022