i have a dataframe with information of participants' country, demographic characteristics (e.g. age, gender) and biochemical measurements (e.g. weight, bp readings etc). I also have the psu and weights calculated for each participant. i have:
steps_3jan <- STEPS_All_countries_4_ %>% select(country, year,
age,
sex,
m11,
m12,
stratum,
psu,
wstep1,
wstep2,
wstep3)
steps_3jan <- subset(steps_3jan, !is.na(psu))
steps_3jan <- subset(steps_3jan, !is.na(wstep1))
steps_3jan <- subset(steps_3jan, !is.na(stratum))
steps_3jan_matrix <- as.data.frame(steps_3jan)
I was was trying to use svydesign to do this:
steps_3jan_design <- svydesign(id =~psu,
strata =~stratum,
nest = TRUE,
weights = ~wstep1,
data = steps_3jan_matrix)
svymean(~age, steps_3jan_design, na.rm = TRUE)
but got the below error:
Error in onestrat(x[index, , drop = FALSE], clusters[index], nPSU[index][1], : Stratum (0) has only one PSU at stage 1
if anyone is able to help it would be greatly appreciated!