The DHS Program User Forum
Discussions regarding The DHS Program data and results

Home » Data » Dataset use in Stata » Multi-level mixed effect Poisson regression in Stata
Multi-level mixed effect Poisson regression in Stata [message #23236] Wed, 04 August 2021 13:38 Go to next message
iqbalnowshad is currently offline  iqbalnowshad
Messages: 1
Registered: August 2021
Member
Dear User forum members,
I am using the individual DHS survey data (IR file) where subjects are nested within households, and households are nested within clusters. My outcome of interest is a count variable and I have several categorical predicts. I would like to fit a multi-level mixed effect Poisson regression model with robust variance to identify factors associated with the outcome in Stata (version 15.1).

However, I am having difficulty in writing the code in Stata. For survey data we usually use "SVY" command. However, Stata documentation (https://www.stata.com/manuals/memepoisson.pdf) shows below command for "mepoisson" multi-level mixed effect Poisson regression which is very confusing to me.

svyset psu, weight(wvar3) || ssu, weight(wvar2) || _n, weight(wvar1)
svy: mepoisson y x || psu: || ssu:

How do I incorporate weight (v005), primary sampling unit (v021) and strata (v022) variable in the above code? Also how to estimate values for ICC, PCV, AIC, and BIC after model fitting.

I was hoping someone could help me with this or if anyone has done similar analysis and shares the code that will be much appreciated.

Thank you,
Iqbal
Re: Multi-level mixed effect Poisson regression in Stata [message #23284 is a reply to message #23236] Mon, 16 August 2021 10:44 Go to previous messageGo to next message
Shireen-DHS is currently offline  Shireen-DHS
Messages: 140
Registered: August 2020
Location: USA
Senior Member
Hello,

Multilevel models require a weight for each level.

The generic code for instance for two levels would be the following:

svyset v001, weight(wt) strata(v023) , singleunit(centered) || _n, weight(wt2)

v001 is the psu and v023 is the strata if using DHS data. To check the strata for older surveys please refer to the Survey_strata.do file here: https://github.com/DHSProgram/DHS-Analysis-Code

We only supply one weight in the DHS data (v005). However, recently we have published a report to estimate the second level weight. Please refer to this report for more detail. It also contains examples and Stata code: https://www.dhsprogram.com/publications/publication-mr27-met hodological-reports.cfm

Good luck with your research.

Best,
Shireen Assaf
The DHS Program
Re: Multi-level mixed effect Poisson regression in Stata [message #31929 is a reply to message #23236] Mon, 29 June 2026 08:49 Go to previous message
Khawar is currently offline  Khawar
Messages: 22
Registered: April 2023
Member
I am working on multilevel Poisson. I also face a problem with the svy command when I run mepoisson. As I am working on the DHS in Pakistan. Average household size per cluster is also not available. I have calculated this from this formula: Empirically derived from the 2017 Census: 32,205,111 total households / 168,943 total EBs. The first question is, 'Is it correct?' This table is my coding scheme for 2-level calculations according to DHS report 27.

************************************************************ **********
* Stage A *** Compile parameters/inputs for Level-weights calculations
************************************************************ **********
* 1. a_c_h completed clusters by strata
gen a_c_h=.
quietly levelsof v023, local(lstrata)
quietly foreach ls of local lstrata {
tab v021 if v023==`ls', matrow(T)
scalar stemp=rowsof(T)
replace a_c_h=stemp if v023==`ls'
}

* 2. A_h total number of census clusters by strata
gen A_h = 0

* Punjab
replace A_h = 26958 if v023 == 1 // Punjab Urban
replace A_h = 60048 if v023 == 2 // Punjab Rural

* Sindh
replace A_h = 21916 if v023 == 3 // Sindh Urban
replace A_h = 17223 if v023 == 4 // Sindh Rural

* KPK
replace A_h = 3221 if v023 == 5 // KPK Urban
replace A_h = 18777 if v023 == 6 // KPK Rural

* Balochistan
replace A_h = 1826 if v023 == 7 // Baluchistan Urban
replace A_h = 8386 if v023 == 8 // Baluchistan Rural

* Islamabad
replace A_h = 727 if v023 == 9 // Islamabad Urban
replace A_h = 787 if v023 == 10 // Islamabad Rural

* FATA
replace A_h = 43 if v023 == 11 // FATA Urban
replace A_h = 3763 if v023 == 12 // FATA Rural


*** 3. Average household size per cluster (M_h) ***
* Empirically derived from 2017 Census: 32,205,111 total households / 168,943 total EBs
gen M_h = 190.63

*** 4. Define Population Denominator (M) ***
* Based on Census 2017 total minus AJK/GB households
* (Calculation: 32,205,111 total - 1,004,241 AJK/GB)
gen M = 31200870

*** 5. Total number of completed households (m_c) ***
* verified this is 14,540 from the Household (HR) file
gen m_c = 11869

*** 6. Households selected per cluster (S_h) ***
gen S_h = 28

*** 7 ***************************
gen DHSwt = d005 / 1000000

************************************************************ **********
* Stage B *** Approximate Level-weights ***
************************************************************ **********
* 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)
*Step 2. Approximate the Level-2 weight
* f the variation factor
gen f = d_HH / ((A_h/a_c_h) * (M_h/S_h))

scalar alpha = 0.5
gen wt2_05 = (A_h/a_c_h) * (f^alpha)
gen wt1_05 = d_HH / wt2_05

First I am working for Alpha 0.5

* Create a constant cluster-level weight
bysort v001: egen wt2_05_constant = mean(wt2_05)
mepoisson children_born i.dv_any_violence i.region v012 i.education ///
i.marriage_age_group i.terminated_preg i.ethnicity_final ///
i.wealth_3cat i.residence i.ever_used_binary ///
lom_prof_community ///
[pweight=wt1_05] || v001:, pweight(wt2_05_constant) irr vce(robust)

My code is correct for multilevel Poisson, as the svy command does not support the mepoisson command. Also, I have followed the Stata manual for multilevel Poisson modelling to create the above command. your kind response will be very appreciated.

Regards,
KA
Previous Topic: Family structure in DHS
Next Topic: MULTILEVEL WEIGHT FOR POISSON
Goto Forum:
  


Current Time: Sat Nov 14 00:21:18 EST 2026