ATE_estimate: ATE_estimate

Description Usage Arguments Examples

Description

Do dummy regression

Usage

1
ATE_estimate(pred_control, pred_treatment, i, adjusted, Y, X, treatment, ntilen)

Arguments

pred_control
pred_treatment
i
adjusted
Y
X
treatment
ntilen

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function (pred_control, pred_treatment, i, adjusted, Y, X, treatment,
    ntilen)
{
    if (adjusted == T) {
        ate_formula <- as.formula(paste(Y, "~", treatment))
        rbind(pred_control, pred_treatment) %>% mutate(nt = paste("ntile",
            ntile(pred, n = ntilen), sep = "_")) %>% group_by(nt) %>%
            do(mod = lm(data = ., formula = ate_formula)) %>%
            broom::tidy(mod) %>% filter(term == treatment) %>%
            select(nt, ATE = estimate, stder = std.error) %>%
            ungroup() %>% mutate(M = i)
    }
    else if (adjusted == F) {
        ate_formula <- as.formula(paste(Y, "~", treatment, "+",
            paste(X, collapse = " + ")))
        rbind(pred_control, pred_treatment) %>% mutate(nt = paste("ntile",
            ntile(pred, n = ntilen), sep = "_")) %>% group_by(nt) %>%
            do(mod = lm(data = ., formula = ate_formula)) %>%
            broom::tidy(mod) %>% filter(term == treatment) %>%
            select(nt, ATE = estimate, stder = std.error) %>%
            ungroup() %>% mutate(M = i)
    }
    else {
        print("adjusted must be TRUE/FALSE")
        (break)()
    }
  }

yasui-salmon/stRatification documentation built on May 4, 2019, 2:31 p.m.