我有以下数据和调查设计:
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
现在我想提取单变量回归系数而不实际拟合多个模型。我尝试了以下代码。
coef_reg=sapply(c(6:(ncol(province.design[[7]]))), function(i)
{
svyglm(ue91 ~ province.design[[7]][i], province.design)$coefficients[2];
}
)
但是它不起作用。有人能帮我解决这个问题吗?
这是我得到的错误:
Error in svyglm.survey.design(ue91 ~ province.design[[7]][i], province.design) :
all variables must be in design= argument
感谢您的帮助。