MatthieuStigler / multiDiff

Multi-period diff and diff
Other
3 stars 0 forks source link

DD_manu: should take values of subperiod as ordered #8

Open MatthieuStigler opened 4 years ago

MatthieuStigler commented 4 years ago

Here it is showing post then pre, inverting the order!?

library(multiDiff)
library(tidyverse)

dat_reprex <- sim_dat_staggered(Time=10, N = 100, timing_treatment=6, perc_treat=0.5, perc_never=0.5,
                               gamma=0.2)

DD_manu(dat_reprex,
        control_gr = "0_0_0_0_0_0_0_0_0_0",
        treat_gr = "0_0_0_0_0_1_1_1_1_1",
        subperiod= rep(c("pre", "post"), each=5))
#> # A tibble: 3 x 5
#>   .period   group_0_0_0_0_0_0_0_0_0_0 group_0_0_0_0_0_1_1_1_1…   diff diff_check
#>   <chr>                         <dbl>                    <dbl>  <dbl>      <dbl>
#> 1 post                         -1.81                    -0.460  1.35       1.35 
#> 2 pre                          -0.801                   -1.07  -0.267     -0.267
#> 3 Diff Time                     1.01                    -0.608 -1.61      -1.61

DD_manu(dat_reprex,
        control_gr = "0_0_0_0_0_0_0_0_0_0",
        treat_gr = "0_0_0_0_0_1_1_1_1_1",
        subperiod= factor(rep(c("pre", "post"), each=5),
                          levels=c("pre", "post")))
#> # A tibble: 3 x 5
#>   .period   group_0_0_0_0_0_0_0_0_0_0 group_0_0_0_0_0_1_1_1_1…   diff diff_check
#>   <chr>                         <dbl>                    <dbl>  <dbl>      <dbl>
#> 1 pre                          -0.801                   -1.07  -0.267     -0.267
#> 2 post                         -1.81                    -0.460  1.35       1.35 
#> 3 Diff Time                    -1.01                     0.608  1.61       1.61

Created on 2020-06-10 by the reprex package (v0.3.0)