我正在尝试使用以下代码运行带有logit结果的GEE模型。
mod.gee <- geeglm(general_elec~activity_outside_home+econ_scale_6_pt,
data=D_work_small, id="pidlink",
family=binomial(link="logit"), corstr="ar1")
但我一直收到这个错误:
Error in model.frame.default(formula = general_elec ~ activity_outside_home+ :
variable lengths differ (found for '(id)')
我的数据来自两次调查的纵向数据。我试过用NAs省略响应,并改变变量的数据类型,但没有任何效果。有什么建议,或者有没有人遇到过这个问题?
我的数据结构如下:
> head(D_work_small)
pidlink econ_scale_6_pt activity_outside_home general_elec wave age female java educ_level pid_unit
1 001220001 3 1 1 3 48 0 0 1 0012200013
10 001220002 3 1 1 3 47 1 0 1 0012200023
19 001220003 2 1 1 3 27 0 0 4 0012200033
77 001250003 2 1 1 3 27 0 0 1 0012500033
79 001290001 2 1 1 3 52 0 0 1 0012900013
88 001290002 2 1 1 3 49 1 0 1 0012900023
> summary(D_work_small)
pidlink econ_scale_6_pt activity_outside_home general_elec wave
Length:44106 Min. :1.000 Min. :0.0000 Min. :0.0000 Min. :3.000
Class :character 1st Qu.:2.000 1st Qu.:0.0000 1st Qu.:1.0000 1st Qu.:3.000
Mode :character Median :3.000 Median :1.0000 Median :1.0000 Median :4.000
Mean :2.894 Mean :0.7048 Mean :0.8304 Mean :3.608
3rd Qu.:3.000 3rd Qu.:1.0000 3rd Qu.:1.0000 3rd Qu.:4.000
Max. :6.000 Max. :1.0000 Max. :1.0000 Max. :4.000
age female java educ_level pid_unit
Min. : 14.00 Min. :0.0000 Min. :0.0000 Min. :1.0 Length:44106
1st Qu.: 26.00 1st Qu.:0.0000 1st Qu.:0.0000 1st Qu.:1.0 Class :character
Median : 35.00 Median :1.0000 Median :0.0000 Median :2.0 Mode :character
Mean : 37.35 Mean :0.5118 Mean :0.4171 Mean :2.2
3rd Qu.: 47.00 3rd Qu.:1.0000 3rd Qu.:1.0000 3rd Qu.:3.0
Max. :999.00 Max. :1.0000 Max. :1.0000 Max. :5.0