I’m trying to calculate a proportion of poor using the survey package. So I create a subset with the variable of the total of population (one) and called n (I’m not sure if it’s the right way to do that). So, I have:
str(base2015$q)
 num [1:117939] 0 0 0 0 0 0 0 0 0 0 ...
str(base2015$one)
 int [1:117939] 1 1 1 1 1 1 1 1 1 1 ...
and a categoric variable region. (y is my svydesign) I tried to use the svyratio function like that, but he give me the result for all dataset, and I want by subgroup (region). In deed I want this for each region (see the image) proportion of poor
svyratio(numerator=~q, 
         ~one, 
         design = y, separate=FALSE, na.rm=TRUE, 
         formula, covmat=FALSE, deff=FALSE)
I also tried create a subset using the population, and then use the svyby:
n <- subset( y , one == 1 )
View(n)
svyby( ~ q , ~ region , n , vartype=c("se","ci","cv"), svytotal )
svyby( ~ q , ~ region , n , vartype=c("se","ci","cv"), svymean )
  region  q  se ci_l ci_u  cv
1      1 NA NaN  NaN  NaN NaN
2      2 NA NaN  NaN  NaN NaN
3      3 NA NaN  NaN  NaN NaN
4      4 NA NaN  NaN  NaN NaN
5      5 NA NaN  NaN  NaN NaN
He give me this. I don't know what I'm doing wrong. Can someone help me with this?