The DHS Program User Forum
Discussions regarding The DHS Program data and results
Home » Data » Sampling » Survey Design Issue
Survey Design Issue [message #22488] Fri, 19 March 2021 17:44 Go to previous message
hamid is currently offline  hamid
Messages: 9
Registered: November 2018
Member
Recently I am experiencing some issues in setting the DHS survey design in R using the Afghanistan 2015 Standard DHS7.

After loading the Stata format individual recode dataset (AFIR71FL) into R:

library(foreign)
library(survey)

data <- read.dta("AFIR71FL.DTA")
data$wt <- data$v005 /1000000

I simply run the following command (as indicated in the DHS documentation):

DHSdesign<-svydesign(id = data$v021, strata = data$v023, weights = wt, data=data)

and I get the following error:

Error in svydesign.default(id = data$v021, strata = data$v023, weights = wt, data = data) :
Clusters not nested in strata at top level; you may want nest=TRUE.

which is basically telling me that PSU ids are not unique across Strata (Province +rural/urban).

Some additional notes:
- The same code worked just fine over the past month (working on it everyday);
- I tried a fresh install of R + packages without any success;
- R & packages are up to date;
- I get the same error using different machines;
- The AfDHS file in use is the most recent;
- Using the option "nest=T", as suggested by R, is not a working solution as it creates problems when running "svyglm" regressions.

I am wondering if this is a R:suvery package bug or something else.

Thanks,
Hamid

[Updated on: Sat, 20 March 2021 05:33]

Report message to a moderator

 
Read Message
Read Message
Read Message
Previous Topic: Refugees and Internally Displaced People (IDP)
Next Topic: Same PSUs in different survey waves
Goto Forum:
  


Current Time: Thu Feb 22 05:22:29 Coordinated Universal Time 2024