Skip to contents

Takes in all of the filled diff df CSV files and uses them to compute group level ATTs as well as the aggregate ATT and its standard errors and p-values.

Usage

undid_stage_three(
  dir_path,
  agg = "silo",
  weights = TRUE,
  covariates = FALSE,
  interpolation = FALSE,
  save_csv = FALSE,
  filename = "UNDID_results.csv",
  filepath = tempdir(),
  nperm = 1001,
  verbose = TRUE
)

Arguments

dir_path

A character specifying the filepath to the folder containing all of the filled diff df CSV files.

agg

A character which specifies the aggregation methodology for computing the aggregate ATT in the case of staggered adoption. Options are: "silo", "g", or "gt". Defaults to "silo".

weights

A logical value (either TRUE or FALSE) which determines whether or not the weights should be used in the case of common adoption. Defaults to TRUE.

covariates

A logical value (either TRUE or FALSE) which specifies whether to use the diff_estimate column or the diff_estimate_covariates column from the filled diff df CSV files when computing ATTs.

interpolation

A logical value or a character which specifies which, if any, method of interpolation/extrapolation for missing values of diff_estimate or diff_estimate_covariates should be used. There must be at least one diff_estimate or diff_estimate_covariates value for the (silo,g) group for which a missing value is being estimated in order for interpolation to work. Options are: "linear_function", "nearest_value", or "piecewise_linear". Defaults to FALSE.

save_csv

A logical value, either TRUE or FALSE (default), which determines if a CSV copy of the UNDID results will be saved or not.

filename

A string filename for the created CSV file. Defaults to "UNDID_results.csv"

filepath

Filepath to save the CSV file. Defaults to tempdir().

nperm

Number of random permutations of gvar & silo pairs to consider when calculating the randomization inference p-value. Defaults to 1001.

verbose

A logical value (either TRUE or FALSE) which toggles messages showing the progress of the randomization inference. Defaults to TRUE.

Value

A data frame containing the aggregate ATT and its standard errors and p-values from two-sided tests of agg_ATT == 0. Also returns group (silo, g, or gt) level ATTs for staggered adoption.

Details

The agg parameter specifies the aggregation method used in the case of staggered adoption. By default it is set to "silo" so that the ATTs are aggregated across silos with each silo having equal weight, but can be set to "gt" or "g" instead. Aggregating across "g" calculates ATTs for groups based on when the treatment time was, with each "g" group having equal weight. Aggregating across "gt" calculates ATTs for groups based on when the treatment time was and the time for which the ATT is calculated. The agg parameter is ignored in the case of a common treatment time and only takes effect in the case of staggered adoption. For common adoption, refer to the weights parameter.

Examples


# Execute `undid_stage_three()`
dir <- system.file("extdata/staggered", package = "undidR")
undid_stage_three(dir, agg = "g", nperm = 501, verbose = FALSE)
#>         gvar    gvar_ATT    gvar_SE   gvar_p_val gvar_jknife_SE
#> 1 1991-01-01  0.03824003 0.02557435 0.1394760603     0.02756434
#> 2 1993-01-01  0.03312283 0.02541522 0.1980131279     0.02691780
#> 3 1996-01-01  0.09702872 0.03208821 0.0048034212     0.03656550
#> 4 1997-01-01  0.11819478 0.02866265 0.0002715445     0.03064223
#> 5 1998-01-01 -0.05942719 0.05037900 0.2527181863     0.06848128
#>   gvar_jknife_p_val    agg_ATT agg_ATT_SE agg_ATT_p_val agg_ATT_jknife_SE
#> 1      0.1698802214 0.04543183 0.02768056     0.1760813        0.03094781
#> 2      0.2238366570         NA         NA            NA                NA
#> 3      0.0121558950         NA         NA            NA                NA
#> 4      0.0005644115         NA         NA            NA                NA
#> 5      0.3963391606         NA         NA            NA                NA
#>   agg_ATT_jknife_p_val agg_ATT_RI_p_val
#> 1            0.2384033            0.214
#> 2                   NA               NA
#> 3                   NA               NA
#> 4                   NA               NA
#> 5                   NA               NA