如何在R中运行具有聚类标准误差和调查权重的固定效应logit模型?

时间:2019-04-30 14:54:11

标签: r logistic-regression weighted

我正在使用非洲气压计的调查数据,该数据使用了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中,它似乎很乏味。任何帮助,将不胜感激!

1 个答案:

答案 0 :(得分:0)

我将检查wikipedia-top-pages.json软件包,其中提供了您所要求的一切。第一步是创建调查对象,指定调查权重,然后您便可以参加比赛了。

survey

或者如果您使用的是调查数据,至少我会走这条路。