Following is a response from DHS Senior Analysis & Research Manager, Shireen Assaf:
# install and load the packages you need
install.packages("survey")
library(survey)
# setting your survey design
# To identify the survey design, you need three variables: weight, psu, and strata
# creating the sampling weight variable.
IRdata$wt <- IRdata$v005/1000000
mysurvey<-svydesign(id=IRdata$v021, data=IRdata, strata=IRdata$v022, weight=IRdata$wt, nest=T)
options(survey.lonely.psu="adjust")
#now you can use the svy commands in the survey package and use the "mysurvey" sample design object. Check the commands you can use in the survey package.
# for example
# table of variable v313 (FP use) this is after you attach your data. You can also use svyby, svyglm, etc.
svytable(~v313, mysurvey)
[Updated on: Mon, 27 March 2023 08:05]
Report message to a moderator