Reputation: 71
I am analysing a complex survey data. I want to calculate the proportion of smoking among rural men and urban men and alcohol consumption. I used separate code like below. Is it possible to get the same result using one code for urban_rural and alcohol?
svyciprop(~smoking, subset(svs1, urban_rural =='rural'), method = "likelihood")
svyciprop(~smoking, subset(svs1, urban_rural =='urban'), method = "likelihood")
svyciprop(~smoking, subset(svs1, alcohol =='yes'), method = "likelihood")
svyciprop(~smoking, subset(svs1, alcohol =='no'), method = "likelihood")
Upvotes: 0
Views: 446
Reputation: 2765
Up to a point, yes, you can use svyby
to get the answers for each category of a variable
svyby(~smoking, ~urban_rural, design=svs1, svyciprop, method="likelihood", vartype="ci")
svyby(~smoking, ~alcohol, design=svs1, svyciprop, method="likelihood", vartype="ci")
There isn't any way to do this for a list of variables without some sort of explicit loop or mapping function.
Upvotes: 2