Usage
GeoLift(
Y_id = "Y",
time_id = "time",
location_id = "location",
X = c(),
data,
locations,
treatment_start_time,
treatment_end_time,
alpha = 0.1,
model = "none",
fixed_effects = TRUE,
ConfidenceIntervals = FALSE,
method = "conformal",
grid_size = 250,
stat_test = "Total",
conformal_type = "iid",
ns = 1000
)
# S3 method for class 'GeoLift'
print(x, ...)
# S3 method for class 'GeoLift'
summary(object, ...)
# S3 method for class 'summary.GeoLift'
print(x, ...)
# S3 method for class 'GeoLift'
plot(
x,
type = "Lift",
treatment_end_date = NULL,
frequency = "daily",
plot_start_date = NULL,
title = "",
subtitle = "",
notes = "",
post_treatment_periods = 0,
...
)Arguments
- Y_id
Name of the outcome variable (String).
- time_id
Name of the time variable (String).
- location_id
Name of the location variable (String).
- X
List of names of covariates.
- data
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 test locations.
- treatment_start_time
Time index of the start of the treatment.
- treatment_end_time
Time index of the end of the treatment.
- alpha
Significance level. Set to 0.1 by default.
- model
A string indicating the outcome model used to augment the Augmented Synthetic Control Method. Augmentation through a prognostic function can improve fit and reduce L2 imbalance metrics.
- "None":
ASCM is not augmented by a prognostic function. Defualt.
- "Ridge":
Augments with a Ridge regression. Recommended to improve fit for smaller panels (less than 40 locations and 100 time-stamps.))
- "GSYN":
Augments with a Generalized Synthetic Control Method. Recommended to improve fit for larger panels (more than 40 locations and 100 time-stamps.
- "best":
Fits "none", "ridge" and (with more than one treatment location) "GSYN", and keeps the one with the lowest Scaled L2 Imbalance. Ties go to the simpler model.
- fixed_effects
A logic flag indicating whether to include unit fixed effects in the model. Set to TRUE by default.
- ConfidenceIntervals
A logic flag indicating whether to estimate confidence intervals. Set to FALSE by default.
- method
A string indicating the method used to calculate the aggregate ATT Confidence Intervals.
- "conformal":
Conformal Inference. Defualt.
- "jackknife+":
Jackknife+ (exclusively for stat_test = "Total").
- grid_size
Number of grid points to use when inverting the hypothesis test for Conformal Inference. Set to 250 by default.
- stat_test
A string indicating the test statistic.
- "Total":
The test statistic is the sum of all treatment effects, i.e. sum(abs(x)). Default.
- "Negative":
One-sided test against positive effects i.e. -sum(x). Recommended for Negative Lift tests.
- "Positive":
One-sided test against negative effects i.e. sum(x). Recommended for Positive Lift tests.
- conformal_type
Type of conformal inference used. Can be either "iid" for Independent and identically distributed or "block" for moving block permutations. Set to "iid" by default.
- ns
Number of resamples for "iid" permutations if
conformal_type = "iid. Set to 1000 by default.- x
GeoLift().- ...
additional arguments
- object
GeoLift()- type
Type of plot. By default "Lift" which plots the incrementality on the outcome variable. If type is set to "ATT", the average ATT is plotted. If type is set to "Incrementality", daily incremental values are plotted.
- treatment_end_date
Character that represents a date in year-month=day format.
- frequency
Character that represents periodicity of time stamps. Can be either weekly or daily. Defaults to daily.
- plot_start_date
Character that represents initial date of plot in year-month-day format.
- title
String for the title of the plot. Empty by default.
- subtitle
String for the subtitle of the plot. Empty by default.
- notes
String to add notes to the plot. Empty by default.
- post_treatment_periods
Number of post-treatment periods. Zero by default.
Value
GeoLift object that contains:
- "results":
Generalized Augmented Sunthetic Controls results.
- "inference":
Data frame with inference statistics (ATT, Lift, p-value, and Confidence Interval.)
- "data":
Input data.
- "y_obs":
Observed outcome metric.
- "y_hat":
Counterfactual outcome metric.
- "ATT":
ATT estimate.
- "ATT_se":
Standrd Error of the ATT estimate.
- "TreatmentStart":
Time id of treatment start.
- "TreatmentEnd":
Time id of treatment end.
- "test_id":
List of names of the test locations.
- "incremental":
Incremental outcome units (Obersved - Counterfactual).
- "Y_id":
Name of the outcome variable.
- "summary":
Model's Summary.
- "ConfidenceIntervals":
Flag indicating whether CI will be included.
- "lower_bound":
Lower confidence interval.
- "upper_bound":
Upper confidence interval.
GeoLift summary object that contains:
- "ATT":
ATT estimate.
- "PercLift":
Lift estimate
- "pvalue":
Experiment p-value.
- "LowerCI":
Lower Confidence Interval.
- "UpperCI":
Upper Confidence Interval.
- "GlobalL2Imbalance":
Global L2 Imbalance.
- "GlobalL2ImbalanceScaled":
Scaled Global L2 Imbalance.
- "IndL2Imbalance":
Individual L2 Imbalance.
- "IndL2ImbalanceScaled":
Scaled Individual L2 Imbalance.
- "ATT":
ATT.
- "start":
Treatment start.
- "end":
Treatment end.
- "type":
Single or Multiple test locations.
- "Y_id":
Name of the outcome variable.
- "incremental":
Incremental outcome units.
- "bias":
Estimated corrected bias.
- "weights":
Synthetic Control Weights.
- "CI":
Flag indicating whether to include Confidence Intervals.
- "alpha":
Significance level.
- "lower":
Lower Bound Confidence Interval.
- "upper":
Upper Bound Confidence Interval.
Examples
geo_test <- GeoDataRead(GeoLift_Test, date_id = "date", location_id = "location",
Y_id = "Y", format = "yyyy-mm-dd")
lift <- GeoLift(Y_id = "Y", data = geo_test, locations = c("chicago", "portland"),
treatment_start_time = 91, treatment_end_time = 105, ns = 100)
lift
#>
#> GeoLift Output
#>
#> Test results for 15 treatment periods, from time-stamp 91 to 105 for test markets:
#> 1 CHICAGO
#> 2 PORTLAND
#> ##################################
#> ##### Test Statistics #####
#> ##################################
#>
#> Percent Lift: 5.4%
#>
#> Incremental Y: 4667
#>
#> Average Estimated Treatment Effect (ATT): 155.556
#>
#> The results are significant at a 95% level. (TWO-SIDED LIFT TEST)
#>
#> There is a 1% chance of observing an effect this large or larger assuming treatment effect is zero.
summary(lift)
#>
#> GeoLift Results Summary
#> ##################################
#> ##### Test Statistics #####
#> ##################################
#>
#> * Average ATT: 155.556
#> * Percent Lift: 5.4%
#> * Incremental Y: 4667
#> * P-value: 0.01
#>
#> ##################################
#> ##### Balance Statistics #####
#> ##################################
#>
#> * L2 Imbalance: 909.489
#> * Scaled L2 Imbalance: 0.1636
#> * Percent improvement from naive model: 83.64%
#> * Average Estimated Bias: NA
#>
#> ##################################
#> ##### Model Weights #####
#> ##################################
#>
#> * Prognostic Function: NONE
#>
#> * Model Weights:
#> * cincinnati: 0.2272
#> * miami: 0.2028
#> * baton rouge: 0.1335
#> * minneapolis: 0.09
#> * dallas: 0.0739
#> * nashville: 0.0685
#> * honolulu: 0.0673
#> * austin: 0.0465
#> * san diego: 0.0451
#> * reno: 0.0306
#> * san antonio: 0.0054
#> * new york: 0.0046
#> * houston: 0.0046
# \donttest{
geo_test <- GeoDataRead(GeoLift_Test, date_id = "date", location_id = "location",
Y_id = "Y", format = "yyyy-mm-dd")
lift <- GeoLift(Y_id = "Y", data = geo_test, locations = c("chicago", "portland"),
treatment_start_time = 91, treatment_end_time = 105)
plot(lift, type = "Lift")
#> You can include dates in your chart if you supply the end date of the treatment. Just specify the treatment_end_date parameter.
plot(lift, type = "ATT")
#> You can include dates in your chart if you supply the end date of the treatment. Just specify the treatment_end_date parameter.
# }