Multiple response analysis in weighted survey data using srvyr

ぐ巨炮叔叔 提交于 2019-12-12 23:28:13

问题


I'm trying to analyse a multiple response question from a weighted survey dataset. I like the srvyr package because it allows me to use the dplyr pipes, but I can't find the reference material on how to handle multiple response questions.

I have a simple dataset looking at different sources of income. Here's an example of how the data looks like

ID <- c(1,2,3,4,5,6,7,8,9,10)
rent_income <- c("Yes", "Yes", "No", "Yes", "No", "Yes", "No", "Yes", "No", "No")
salary_income <- c( "No", "Yes", "No", "Yes", "No", "Yes", "Yes", "No", "Yes", "No")
other_income <- c( "No", "Yes", "No", "No", "No", "No", "Yes", "No", "No", "No")
survey_weights <- c(0.6, 1.2 , 1.1 , 0.7 , 2.4 , 1.1 , 0.3 , 0.6 , 1.0 , 0.8)
df<-data.frame(ID, rent_income, salary_income, other_income, survey_weights)

Note that the data is entirely made up. With srvyr if first have to create a survey object

weighted_dataset <- df %>% as_survey_design(ids=ID, weights=survey_weights)

Now I would want to calculate the weighted percentage of the sample that has different types of incomes. Any ideas on how to do that? In Stata there is a function called mr_tab . But I can't find a similar one in R


回答1:


see the proportions by group block of https://cran.r-project.org/web/packages/srvyr/vignettes/srvyr-vs-survey.html



来源:https://stackoverflow.com/questions/46359437/multiple-response-analysis-in-weighted-survey-data-using-srvyr

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!