Skip to contents

[Stable]

fn_treatment generates the treatment variable D, where D = 1 for test locations in the test period and D = 0 otherwise.

Usage

fn_treatment(df, locations, treatment_start_time, treatment_end_time)

Arguments

df

A data.frame containing the historical conversions by geographic unit. It requires a "locations" column with the geo name, a "Y" column with the outcome data (units), a time column with the indicator of the time period (starting at 1), and covariates.

locations

List of names of the test locations (String).

treatment_start_time

Time index of the start of the treatment.

treatment_end_time

Time index of the end of the treatment.

Value

Data frame with the additional treatment variable (D).

Examples

geo_pre <- GeoDataRead(GeoLift_PreTest, date_id = "date", location_id = "location",
  Y_id = "Y", format = "yyyy-mm-dd")
tail(fn_treatment(geo_pre, locations = "chicago", treatment_start_time = 81,
  treatment_end_time = 90))
#>        location time    Y D
#> 3595 washington   85 2258 0
#> 3596 washington   86 3037 0
#> 3597 washington   87 4453 0
#> 3598 washington   88 3923 0
#> 3599 washington   89 2144 0
#> 3600 washington   90 1996 0