I have the following data and the survey design:
province <-
read.table( text =
"id str clu wt ue91 meanz hou85 diffhou85 smplrat
1 1 1 4 4123 2867 26881 -24014 .25
2 1 4 4 760 2867 4896 -2029 .25
3 1 5 4 721 2867 3730 -863 .25
4 1 15 4 142 2867 556 2311 .25
5 1 18 4 187 2867 1463 1404 .25
6 1 26 4 331 2867 1946 921 .25
7 1 30 4 127 2867 834 2033 .25
8 1 31 4 219 2867 932 1935 .25" ,
header = TRUE
)
require(survey)
province.design <-
svydesign(
id = ~clu ,
strata = ~str ,
data = province ,
weights = ~wt ,
)
> head(province.design[[7]])
id str clu wt ue91 meanz hou85 diffhou85 smplrat
1 1 1 1 4 4123 2867 26881 -24014 0.25
2 2 1 4 4 760 2867 4896 -2029 0.25
3 3 1 5 4 721 2867 3730 -863 0.25
Now I want to extract the univariate regression coefficients without actually fitting multiple models. I tried the following code.
coef_reg=sapply(c(6:(ncol(province.design[[7]]))), function(i)
{
svyglm(ue91 ~ province.design[[7]][i], province.design)$coefficients[2];
}
)
But it is not working. Can anybody help me to figure this out?
This is the error I am getting:
Error in svyglm.survey.design(ue91 ~ province.design[[7]][i], province.design) :
all variables must be in design= argument
Thank you for your help.