The DHS Program User Forum
Discussions regarding The DHS Program data and results
Home » Countries » India » survey weights in R (stuck up in integrating survey weights in analyzing the DHS7 India data)
survey weights in R [message #25942] Thu, 12 January 2023 21:44 Go to next message
dhivvyajp@am.amrita.edu is currently offline  dhivvyajp@am.amrita.edu
Messages: 4
Registered: January 2023
Member
I am currently working on this dataset IAMR7DFL.DTA
I am looking forward to use survey weights for the chi-square test and logistic regression. After searching in the internet, I came across this piece of code.

my_design <-svydesign(id=~Mendata$psu, weights=~Mendata$wt, strata=Mendata$strata, data=Mendata, survey.lonely.psu = "adjust")

It worked and my_design shows this

> my_design
Stratified 1 - level Cluster Sampling design (with replacement)
With (9102) clusters.
svydesign(id = ~Mendata$psu, weights = ~Mendata$wt, strata = Mendata$strata,
data = Mendata, survey.lonely.psu = "adjust")

After that when I am doing the chi-square test like this,
I am getting the following error.

> svychisq(~InternetUsage+RuralOrUrban, my_design, statistic="adjWald")
Error in onestrat(x[index, , drop = FALSE], clusters[index], nPSU[index][1], :
Stratum (51) has only one PSU at stage 1

Kindly help me to resolve this issue and also please specify the analysis of chi-square test and logistic regression with and without survey weights.
Re: survey weights in R [message #25946 is a reply to message #25942] Fri, 13 January 2023 12:14 Go to previous messageGo to next message
Shireen-DHS is currently offline  Shireen-DHS
Messages: 140
Registered: August 2020
Location: USA
Senior Member

Hello,

I have done this recently in R and the code below works. I see you have the option to adjust for error your received but can you try the following code for your data?


# setting the survey design using the weight (wt), psu, and strata
mysurvey<-svydesign(id=Mendata$v021, data=IRdata, strata=Mendata$v022, weight=Mendata$wt, nest=T)
options(survey.lonely.psu="adjust")


# chi-square results
svychisq(~InternetUsage+RuralOrUrban, mysurvey)

Best,
Shireen Assaf
The DHS Program
Re: survey weights in R [message #25947 is a reply to message #25946] Fri, 13 January 2023 12:17 Go to previous messageGo to next message
Shireen-DHS is currently offline  Shireen-DHS
Messages: 140
Registered: August 2020
Location: USA
Senior Member
Hello,

I forgot to add one more thing.
You may have done this already but for the men's file you would compute the weight variable (wt) in this way:

# creating the sampling weight variable.
Mendata$wt <- Mendata$mv005/1000000


For the women's file you would use v005.

Thank you.
Best,
Shireen Assaf
The DHS Program
Re: survey weights in R [message #25965 is a reply to message #25947] Tue, 17 January 2023 22:09 Go to previous message
dhivvyajp@am.amrita.edu is currently offline  dhivvyajp@am.amrita.edu
Messages: 4
Registered: January 2023
Member
Thanks a lot. It worked now.
Previous Topic: Missing Region for 2015 SPSS India dataset
Next Topic: Inconsistencies in heights between NFHS-3 NFHS-4
Goto Forum:
  


Current Time: Sat Nov 30 17:52:49 Coordinated Universal Time 2024