The DHS Program User Forum
Discussions regarding The DHS Program data and results
Home » Topics » Water and Sanitation » error using R survey for urban sanitation
Re: error using R survey for urban sanitation [message #13396 is a reply to message #13348] Tue, 31 October 2017 14:29 Go to previous messageGo to previous message
dhswes is currently offline  dhswes
Messages: 6
Registered: June 2017
Member
As a follow-up, I think the problem is with the stratification. For the 2012 household recode file for Gabon, for instance, hv023 has only NA values. So, how does one calculate survey means for Gabon? I have been using the R survey package with this code:

country_recode <- read.dta(filename)
country_survey <- svydesign(id = country_recode$hv021, strata= country_recode$hv023, weights = country_recode$hv005/1000000, nest = TRUE, data=country_recode)
svyby(~hv205, ~hv025, country_survey, svymean)

I see results in the Stat Compiler for Gabon.

Thanks,

Michael
 
Read Message
Read Message
Read Message
Previous Topic: source of drinking water - variables in IR and HR
Next Topic: Query on data inconsistency
Goto Forum:
  


Current Time: Fri Apr 26 18:07:09 Coordinated Universal Time 2024