The DHS Program User Forum
Discussions regarding The DHS Program data and results
Home » Data » General Data Questions » Calculating fixed and random effects
Calculating fixed and random effects [message #14875] Thu, 10 May 2018 14:30 Go to next message
Ghose is currently offline  Ghose
Messages: 17
Registered: May 2018
Member
Dear forum members,

I am approaching with regard to Nepal DHS (2016) data that I am using to measure the prevalence of diarrhea in six regions. I'd like to calculate the random effects accounting for the differences across regions. Can anyone kindly mention the process or share the commands to execute this in STATA.

The variables are as follows:

(DV)Diarrhea

(IVs) mother's_age region religion education wealth child's_age sex

Thanks in advance for your help

Best regards
Ghose
Re: Calculating fixed and random effects [message #14887 is a reply to message #14875] Fri, 11 May 2018 11:33 Go to previous messageGo to next message
Bridgette-DHS is currently offline  Bridgette-DHS
Messages: 3199
Registered: February 2013
Senior Member

Following is a response from Senior DHS Stata Specialist, Tom Pullum:

To account for variation across 6 regions, a fixed effects model would be preferable. A rule of thumb for random effects is that you have at least 30 cases at that level, i.e. at least 30 regions. For fixed effects, you only need to include something like "i.v024" on the right hand side of the model.
Re: Calculating fixed and random effects [message #14890 is a reply to message #14887] Fri, 11 May 2018 15:59 Go to previous messageGo to next message
Ghose is currently offline  Ghose
Messages: 17
Registered: May 2018
Member
Dear Tom Pullum,

Thanks indeed for the kind help!

Could you please also write a bit about the process of measuring random effects, lets say across the PSUs, or across countries e.g. when the study includes 5 countries in South Asia. How could I quantify the variations occurring at PSUs or country level.
Am I right in thinking that the difference in R2 for the models with and without PSUs/countries provides some indication of the PSU/country level variations.

Re: Calculating fixed and random effects [message #14913 is a reply to message #14890] Mon, 14 May 2018 14:26 Go to previous messageGo to next message
Bridgette-DHS is currently offline  Bridgette-DHS
Messages: 3199
Registered: February 2013
Senior Member
Following is a response from Senior DHS Stata Specialist, Tom Pullum:

DHS always advises that you make three adjustments for the survey design, with svyset and svy if you are using Stata. In order of importance, these are the sample weights, to eliminate a bias toward the over-sampled strata; an adjustment for the clusters, to account for intra-class correlation within the PSUs or clusters; and an adjustment for stratification. The full svyset command is this: "svyset v001 [pweight=v005], strata(stratmid) singleunit(centered)". Where I have put "centered" you could instead put "scaled" or "uncertainty" with little difference. Where I have put v001 you could put v021 (usually, v001=v021). "stratumid" is v022 or v023 in most surveys. There have been many postings about svyset.

The position for v001 within this command, which identifies it as the primary sampling unit, actually specifies that there is to be a random effect for v001. You do not need a separate specification of a random effect for clusters.

Because you have only 5 countries, you should have fixed effects, rather than random effects, for countries. On the right hand side of the model you would have something like "i.country", where country takes the values 1, 2, 3, 4, 5, say.

Having said this, I strongly advise against pooling countries this way. It makes much more sense to do a separate analysis for each country and then present the results side by side. If you pool the countries, you will be describing an "average" for the five countries, with complexities about whether the countries are weighted by sample size or population size, etc. Wouldn't be more interesting to do separate analyses and see how they are similar and how they are different. Even within a country, particularly within India, there is huge variation. You can do statistical tests of whether coefficients, means, proportions, etc. in one country are significantly different from the corresponding terms in another country.
Re: Calculating fixed and random effects [message #15126 is a reply to message #14913] Wed, 06 June 2018 11:27 Go to previous messageGo to next message
Hassen
Messages: 121
Registered: April 2018
Location: Ethiopia,Africa
Senior Member
Dear Bridgette and Dr.Tom Pullum Thank you very much!! I have learned a lot from your always fruitful posts.
With Best Wishes,Hassen


Hassen Ali(Chief Public Health Professional Specialist)
Re: Calculating fixed and random effects [message #15877 is a reply to message #14913] Wed, 03 October 2018 08:06 Go to previous messageGo to next message
tasnuva is currently offline  tasnuva
Messages: 6
Registered: July 2018
Member

This information is very helpful.

I would like to learn SPSS code for the following stata command: "svyset v001 [pweight=v005], strata(stratmid) singleunit(centered)"

Your sincerely,
Dr. Tasnuva


Dr. Tasnuva Wahed

[Updated on: Wed, 03 October 2018 08:16]

Report message to a moderator

Calculating Fixed Effects [message #18383 is a reply to message #14913] Thu, 21 November 2019 08:03 Go to previous messageGo to next message
alohciN is currently offline  alohciN
Messages: 13
Registered: March 2019
Member
Dear DHS,

I am working with DHS data in STATA for my research and was wondering how to apply mother fixed effect in order to determine how many children are in the same household.

I know you can cluster by household number V002, however, I am unable to determine the total number of children per mother in my regression. I know that applying mother fixed effects will reduce the sample size.

I am very grateful for your assistance on how to apply mother fixed effect.

Regards,
Re: Calculating Fixed Effects [message #18397 is a reply to message #18383] Fri, 22 November 2019 07:44 Go to previous messageGo to next message
Bridgette-DHS is currently offline  Bridgette-DHS
Messages: 3199
Registered: February 2013
Senior Member
Following is a response from DHS Research & Data Analysis Director, Tom Pullum:

"There are probably several ways to do this, but I suggest the following, using b16 in the BR file. Open a BR file and then insert these lines:

tab b16
keep if b16>0 & b16<.
gen nch=1
collapse (sum) nch, by(v001 v002 v003)
tab nch

This will give you the number of the women's children (of any age) who are living in the same household as her. You can attach this number to the woman's record with a merge, but in your analysis you probably want to use a file in which the children are the units, i.e. the BR or KR file. If you are using outcomes that are only in the KR file, you can apply these lines to that file, getting the number of children under 5 who are living in the same household as the mother."


We now have repositories of code written in Stata and SPSS available on Github. Please reference these code repositories as a resource for codes for matching or calculating DHS indicators. The code repositories can be found at:
https://github.com/DHSProgram/DHS-Indicators-Stata
https://github.com/DHSProgram/DHS-Indicators-SPSS

Re: Calculating Fixed Effects [message #18398 is a reply to message #18397] Fri, 22 November 2019 11:41 Go to previous messageGo to next message
alohciN is currently offline  alohciN
Messages: 13
Registered: March 2019
Member
Dear Tom and Bridgette,

Many thanks!

Regards
Re: Calculating fixed and random effects [message #26363 is a reply to message #14875] Mon, 13 March 2023 14:33 Go to previous messageGo to next message
Jenna is currently offline  Jenna
Messages: 6
Registered: September 2021
Member
Dear DHS,

I am using women's (IR) files for Ghana to look at attitude toward domestic violence and decision making. I want to account for unobserved factors/differences across districts. Fixed effects was recommended to account for the differences. So, I just used i.districts. However, when I run the analyses the output only shows 80 districts instead of 135 (there are originally 136 districts, so one should be omitted from the results as the baseline). Reading the responses below from DHS, it appears that I might need to use random effects since I have more than 30 districts, but it is not clear to me. Any advice would be greatly appreciated. Thank you.
Re: Calculating fixed and random effects [message #26377 is a reply to message #26363] Tue, 14 March 2023 13:28 Go to previous message
Bridgette-DHS is currently offline  Bridgette-DHS
Messages: 3199
Registered: February 2013
Senior Member

Following is a response from Senior DHS staff member, Tom Pullum:

With a fixed effects model, Stata will run into problems with the sample size in the districts. The omitted districts didn't have cases in all combinations of the covariates. I believe that if you rerun with "asis" included as an option after the comma, it may work. Otherwise, a random effects model would be ok. A very rough rule of thumb is that a random effects model is ok if there are more than 30 units (and you have 80).
Previous Topic: Migration data: number of visitors
Next Topic: DHS phase in the 2014 Ghana DHS
Goto Forum:
  


Current Time: Tue Nov 26 21:54:23 Coordinated Universal Time 2024