Learn R Programming

undidR (version 3.0.0)

create_diff_df: Creates the empty_diff_df.csv

Description

Creates the empty_diff_df.csv which lists all of the differences that need to calculated at each silo in order to compute the aggregate ATT. The empty_diff_df.csv is then to be sent out to each silo to be filled out.

Usage

create_diff_df(
  init_filepath,
  date_format,
  freq,
  covariates = FALSE,
  freq_multiplier = FALSE,
  weights = "both",
  filename = "empty_diff_df.csv",
  filepath = tempdir()
)

Value

A data frame detailing the silo and time combinations for which differences must be calculated in order to compute the aggregate ATT. A CSV copy is saved to the specified directory which is then to be sent out to each silo.

Arguments

init_filepath

A character filepath to the init.csv.

date_format

A character specifying the date format used in the init.csv. Call undid_date_formats() to see a list of valid date formats.

freq

A character indicating the length of the time periods to be used when computing the differences in mean outcomes between periods at each silo. Options are: "yearly", "monthly", "weekly", or "daily".

covariates

A character vector specifying covariates to be considered at each silo. If FALSE (default) uses covariates from the init.csv.

freq_multiplier

A numeric value or FALSE (default). Specify if the frequency should be multiplied by a non-zero integer.

weights

A character indicating the weighting to use. The options are "none", "diff", "att", and "both". The options reflect the levels at which weights are applied. "diff" uses weights based off of the number of observations (treated and untreated) when calculating the subaggregate ATTs. "att" uses weights based off of the number of treated observations associated with each subaggregate ATT when calculating the aggregate ATT. "both" applies weighting at both levels, and "none" does not use weights at all. Defaults to "both".

filename

A character filename for the created CSV file. Defaults to "empty_diff_df.csv"

filepath

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

Details

Ensure that dates in the init.csv are entered consistently in the same date format. Call undid_date_formats() to see a list of valid date formats. Covariates specified when calling create_diff_df() will override any covariates specified in the init.csv.

Examples

Run this code
file_path <- system.file("extdata/staggered", "init.csv",
                         package = "undidR")
create_diff_df(
  init_filepath = file_path,
  date_format = "yyyy",
  freq = "yearly"
)
unlink(file.path(tempdir(), "empty_diff_df.csv"))

Run the code above in your browser using DataLab