Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 用倾向评分计算受试者的平均治疗效果(ATET/ATT)_R_Statistics_Regression_Stata_Propensity Score Matching - Fatal编程技术网

R 用倾向评分计算受试者的平均治疗效果(ATET/ATT)

R 用倾向评分计算受试者的平均治疗效果(ATET/ATT),r,statistics,regression,stata,propensity-score-matching,R,Statistics,Regression,Stata,Propensity Score Matching,我试图用倾向评分来计算被治疗者的平均治疗效果。我使用这些数据来估计母亲在怀孕期间吸烟是否会影响出生体重 数据包括一列出生体重(dbrwt)、一列吸烟状态(tobacco01)和多个协变量 我计算了平均治疗效果(ATE),如下所示: model1 <- lm(dbrwt ~ tobacco01, data = dfc, weights = weight) model1通过应用统计知识,您可以避免使用软件包 倾向评分(ps)很可能还不是加权ATE回归的权重。应使用适当的公式计算权重(参见Mo

我试图用倾向评分来计算被治疗者的平均治疗效果。我使用这些数据来估计母亲在怀孕期间吸烟是否会影响出生体重

数据包括一列出生体重(dbrwt)、一列吸烟状态(tobacco01)和多个协变量

我计算了平均治疗效果(ATE),如下所示:

model1 <- lm(dbrwt ~ tobacco01, data = dfc, weights = weight)

model1通过应用统计知识,您可以避免使用软件包

倾向评分(
ps
)很可能还不是加权ATE回归的权重。应使用适当的公式计算权重(参见Morgan和Winship 2015第7章)

#ATE

dfc$w.ate
zelig
包必须这样做。您只需要使用
zelig()
@paqmo来估计模型,我看不到使用此包包含倾向权重的方法。“zelig()”有一个权重argument@paqmo你知道我能做些什么来回避这个问题吗?我收到以下错误:install.packages中出现警告:包“Zelig”不可用(适用于R版本3.6.2)
# ATE
dfc$w.ate <- with(dfc, ifelse(tobacco01 == 1, 1 / ps, 1 / (1 - ps)))

ate <- lm(dbrwt ~ tobacco01, data=dfc, weights=w.ate)
coef(ate)
# (Intercept)   tobacco01 
#   3817.6932   -178.0539 
dfc$w.att <- with(dfc, ifelse(tobacco01 == 1, 1, ps / (1 - ps)))

att <- lm(dbrwt ~ tobacco01, data=dfc, weights=w.att)
coef(att)
# (Intercept)   tobacco01 
#   3843.0671   -334.1448 
set.seed(42)
n <- 1e3
dfc <- data.frame(dbrwt=rnorm(n, 3500, 500), tobacco01=rbinom(n, 1, .1), ps=runif(n))