【发布时间】:2019-04-30 14:54:11
【问题描述】:
我正在使用 Afrobarometer 调查数据,其中包含 10 个国家/地区的 2 轮数据。我的 DV 是二进制 0-1 变量。我需要使用逻辑回归、固定效应、聚类标准误差(在国家/地区)和加权调查数据。数据框中已存在权重变量。
我一直在查看以下软件包的帮助文件:clogit、glm、pglm、glm2、zelig、bife 等。典型的错误包括:不能添加权重、不能做固定效果、不能做任何一个等等。
#Glm
t3c1.fixed <- glm(formula = ethnic ~ elec_prox +
elec_comp + round + country, data=afb,
weights = afb$survey_weight,
index c("country", "round"),
family=binomial(link='logit'))
#clogit
t3c1.fixed2 <- clogit(formula = ethnic ~ elec_prox +
elec_comp + round + country, data=afb,
weights = afb$survey_weight,
method=c("within"))
#bife attempt
library(bife)
t3c1.fixed3 <- bife(ethnic ~ elec_prox + elec_comp + round +
country, model = logit,data=afb,
weights = afb$survey_weight,
bias_corr = "ana")
我要么收到错误消息,要么代码不包含我需要包含的条件之一,因此我无法使用它们。在 Stata 中,这个过程似乎非常简单,但在 R 中,这似乎相当乏味。任何帮助,将不胜感激!
【问题讨论】:
-
您可以使用接受权重的包计算 FE logit,例如
clogit并在调整 vcov-matrix 后手动计算集群 SE,例如使用sandwich包。你可能想看看这个有用的答案:stackoverflow.com/a/37529874/6574038也许你也可以考虑固定效果假人。
标签: r logistic-regression weighted