如何使用Match()获取ATT的置信区间

时间:2017-03-19 17:09:18

标签: r statistics inference causality

我在R中使用Match()库,我需要AT的CI。

  1. 有办法搞定吗?我想在计算ATT和CI时使用倾向得分。

  2. 如何计算? (即什么是公式?为什么?)

  3. 干杯,

    PS:我看过那些,但这不是我想要的: https://stats.stackexchange.com/questions/132509/confidence-interval-for-average-treatment-effect-from-propensity-score-weighting

    和:https://stats.stackexchange.com/questions/238431/is-the-average-treatment-effect-on-the-treated-att-a-meaningful-comparison-in

    PS2:附上相关的代码;在找到平衡之后,我尝试使用回归+ confint()方法获得CI,但它不起作用,因为我不知道如何通过倾向得分,我强迫进入回归模型(我确定这是不必要的,但我只知道CI的配置功能。)

    (3) Using the Match() help file code example as a guide, use propensity score matching to produce an estimated treatment effect and confidence interval. Report your results.
    
    ```{r}
    library(Matching)
    
    DataFrame=as.data.frame(data1)
    
    # Estimate the propensity model
    
    glm1  <- glm(treat~age + I(age^2) + education + I(education^2) + black +
                 hispanic + married + nodegree + re74  + I(re74^2) + re75 + I(re75^2) , family=binomial, data=DataFrame)
    #save data objects
    X  <- glm1$fitted
    Y  <- DataFrame$re78
    Tr  <- DataFrame$treat
    
    # One-to-one matching with replacement (the "M=1" option).
    # Estimating the treatment effect on the treated (the "estimand" option defaults to ATT==Average Treatment effect for Treated).
    rr  <- Match(Y=Y, Tr=Tr, X=X, M=1);
    summary(rr)
    ```
    Finding Balance:
    
    ```{r}
    # Let's check the covariate balance:
    mb  <- MatchBalance(treat~age + I(age^2) + education + I(education^2) + black +hispanic + married + nodegree + re74  + I(re74^2) + re75 + I(re75^2), data=DataFrame, match.out=rr, nboots=500)
    
    rr1  <- Match(Y=Y, Tr=Tr, X=X, M=1,Weight.matrix=);
    
    #After obtaining balance, find ATT 
    rr1  <- Match(Y=Y, Tr=Tr, X=X, M=1);
    summary(rr1)
    ```
    
    Find a way to obtain CIs - Doesnt work:
    ```{r}
    X<-mb
    Y<-re78
    RegressionOnMatched<-lm(re78~X,data = )
    confint(RegressionOnMatched)
    #mean(rr$re78)
    #quantile(rr$re78, c(0.025, 0.975))
    ```
    

1 个答案:

答案 0 :(得分:0)

我相信你的问题是你传递给分位数的论点。试试这个:

ci_upper <- 2*mean(rr$re78) - quantile(rr$re78, 0.025)    
ci_lower <- 2*mean(rr$re78) - quantile(rr$re78, 0.975)
ci <- c(ci_lower, ci_upper)