The DHS Program User Forum
Discussions regarding The DHS Program data and results
Home » Data » Weighting data » Using R to weight data for domestic violence
Using R to weight data for domestic violence [message #20418] Fri, 30 October 2020 13:13 Go to next message
banakani is currently offline  banakani
Messages: 1
Registered: October 2020
Hello everyone,

I would like to set up the survey design for Cote d'Ivoire DHS 2011-2012 using R. I am focused on domestic violence.

I used this code:

wt <- ipv_studyf$d005/1000000 # creating the variable weight

ipvdesign <- svydesign(ids = ipv_studyf$v021, # clustering- psu
strata = ipv_studyf$v023, # strata variable
weights = wt, # the weighting variable
data = ipv_studyf, # the dataset
variance="HT" ) # Horvitz-Thompson estimator

However, I keep getting this error message:

Error in na.weight(data.frame(weights)) : missing values in `weights'

I read some comments in the weighting data/ How to Weight Data in R, however, nobody has faced this issue before.

    Would you mind to help me with this?
    Should I remove all the missing values for this column?
    How can I fix this error message?
Could you please help me to fix it?
Re: Using R to weight data for domestic violence [message #20446 is a reply to message #20418] Tue, 03 November 2020 08:29 Go to previous message
Bridgette-DHS is currently offline  Bridgette-DHS
Messages: 2113
Registered: February 2013
Senior Member

Following is a response from DHS Senior Sampling Specialist, Mahmoud Elkasabi:

ipv_studyf <- subset(ipv_studyf, ! )
ipv_studyf$wt <- ipv_studyf$d005/1000000 

ipvdesign <- svydesign(id = v021, strata = v023, weights = wt, data = ipv_studyf)

[Updated on: Tue, 03 November 2020 08:31]

Report message to a moderator

Previous Topic: Pooled Cross sections
Next Topic: Sampling Weights for HbA1c SA DHS 2017
Goto Forum:

Current Time: Tue Jan 26 01:34:00 Coordinated Universal Time 2021