The DHS Program User Forum - RDF feed https://userforum.dhsprogram.com/index.php Multilevel modeling https://userforum.dhsprogram.com/index.phpindex.php?t=rview&goto=24792&th=11846#msg_24792 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.
]]>
w@dhs 2022-07-12T04:20:22-00:00
Re: Multilevel modeling https://userforum.dhsprogram.com/index.phpindex.php?t=rview&goto=24818&th=11846#msg_24818
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
}
]]>
Janet-DHS 2022-07-15T18:47:52-00:00
Re: Multilevel modeling https://userforum.dhsprogram.com/index.phpindex.php?t=rview&goto=24838&th=11846#msg_24838 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]]>
w@dhs 2022-07-19T01:08:58-00:00
Re: Multilevel modeling https://userforum.dhsprogram.com/index.phpindex.php?t=rview&goto=24865&th=11846#msg_24865
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.
]]>
Janet-DHS 2022-07-21T16:31:59-00:00