Power calculations for unknown test market locations, number of test markets, and test duration.
Source:R/pre_test_power.R
GeoLiftPowerFinder.RdDevelopment on GeoLiftPowerFinder() is complete.
We recommend switching to GeoLiftMarketSelection()
for new code, which is easier to use, more featureful,
and still under active development.
GeoLiftPowerFinder provides power calculations for unknown
test markets, number of test locations, and test duration.
Usage
GeoLiftPowerFinder(
data,
treatment_periods,
N = 1,
X = c(),
Y_id = "Y",
location_id = "location",
time_id = "time",
effect_size = seq(0, 0.25, 0.05),
top_results = 5,
alpha = 0.1,
normalize = FALSE,
model = "none",
fixed_effects = TRUE,
dtw = 0,
ProgressBar = FALSE,
plot_best = FALSE,
run_stochastic_process = FALSE,
parallel = TRUE,
parallel_setup = "sequential",
side_of_test = "two_sided"
)Arguments
- 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.
- treatment_periods
List of treatment periods to calculate power for.
- N
List of number of test markets to calculate power for.
- X
List of names of covariates.
- Y_id
Name of the outcome variable (String).
- location_id
Name of the location variable (String).
- time_id
Name of the time variable (String).
- effect_size
A vector of effect sizes to test by default a sequence between 0 - 25 percent in 5 percent increments: seq(0,0.25,0.05). Make sure that the sequence includes zero.
- top_results
Number of results to display.
- alpha
Significance Level. By default 0.1.
- normalize
A logic flag indicating whether to scale the outcome which is useful to accelerate computing speed when the magnitude of the data is large. The default is FALSE.
- 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.
- fixed_effects
A logic flag indicating whether to include unit fixed effects in the model. Set to TRUE by default.
- dtw
Emphasis on Dynamic Time Warping (DTW), dtw = 1 focuses exclusively on this metric while dtw = 0 (default) relies on correlations only.
- ProgressBar
A logic flag indicating whether to display a progress bar to track progress. Set to FALSE by default.
- plot_best
A logic flag indicating whether to plot the best 4 tests for each treatment length. Set to FALSE by default.
- run_stochastic_process
A logic flag indicating whether to select test markets through random sampling of the the similarity matrix. Given that interpolation biases may be relevant if the synthetic control matches the characteristics of the test unit by averaging away large discrepancies between the characteristics of the test and the units in the synthetic controls, it is recommended to only use random sampling after making sure all units are similar. This parameter is set by default to FALSE.
- parallel
A logic flag indicating whether to use parallel computing to speed up calculations. Set to TRUE by default.
- parallel_setup
A string indicating parallel workers set-up. Set to "sequential" by default.
- side_of_test
A string indicating whether confidence will be determined using a one sided or a two sided test.
- "two_sided":
The test statistic is the sum of all treatment effects, i.e. sum(abs(x)). Defualt.
- "one_sided":
One-sided test against positive or negaative effects i.e. If the effect being applied is negative, then defaults to -sum(x). H0: ES >= 0; HA: ES < 0. If the effect being applied is positive, then defaults to sum(x). H0: ES <= 0; HA: ES > 0.
Examples
# \donttest{
geo_pre <- GeoDataRead(GeoLift_PreTest, date_id = "date", location_id = "location",
Y_id = "Y", format = "yyyy-mm-dd")
set.seed(1)
GeoLiftPowerFinder(geo_pre, treatment_periods = 10, N = 2,
effect_size = c(0, 0.1, 0.2), top_results = 3, parallel = FALSE)
#> Finding the best markets for your experiment.
#>
#> Deterministic setup with 2 locations in treatment.
#> location pvalue duration MinDetectableEffect Investment
#> 1 miami, phoenix 0.000 10 0.2 0
#> 2 nashville, san diego 0.002 10 0.1 0
#> 3 chicago, portland 0.000 10 0.1 0
#> 4 jacksonville, minneapolis 0.000 10 0.1 0
#> 5 las vegas, saint paul 0.003 10 0.1 0
#> 6 atlanta, reno 0.000 10 0.2 0
#> 7 baton rouge, portland 0.000 10 0.1 0
#> 8 dallas, washington 0.000 10 0.2 0
#> 9 columbus, phoenix 0.032 10 0.1 0
#> 10 honolulu, indianapolis 0.067 10 0.1 0
#> 11 jacksonville, milwaukee 0.000 10 0.1 0
#> 12 kansas city, milwaukee 0.000 10 0.1 0
#> 13 dallas, memphis 0.061 10 0.1 0
#> 14 orlando, saint paul 0.000 10 0.2 0
#> 15 atlanta, chicago 0.090 10 0.1 0
#> 16 dallas, denver 0.008 10 0.1 0
#> 17 baltimore, philadelphia 0.000 10 0.1 0
#> 18 boston, new orleans 0.001 10 0.2 0
#> 19 philadelphia, phoenix 0.000 10 0.1 0
#> 20 chicago, cincinnati 0.016 10 0.1 0
#> 21 cleveland, denver 0.069 10 0.1 0
#> 22 columbus, new york 0.061 10 0.1 0
#> 23 austin, oakland 0.001 10 0.1 0
#> 24 oakland, oklahoma city 0.000 10 0.1 0
#> 25 los angeles, san antonio 0.000 10 0.1 0
#> 26 detroit, new orleans 0.065 10 0.1 0
#> 27 indianapolis, tucson 0.058 10 0.1 0
#> 28 houston, nashville 0.028 10 0.1 0
#> cpic ScaledL2Imbalance att_estimator detected_lift ProportionTotal_Y
#> 1 0 0.6610263 935.6683 0.20241906 0.05337446
#> 2 0 0.3306865 338.3711 0.09928544 0.03891756
#> 3 0 0.1682310 300.9401 0.10378014 0.03306537
#> 4 0 0.2278603 318.3261 0.11761982 0.03032910
#> 5 0 0.7340928 437.2304 0.10903612 0.04571975
#> 6 0 0.4880339 679.0686 0.18088472 0.04347870
#> 7 0 0.2187082 352.7346 0.12192775 0.03289916
#> 8 0 0.3522027 452.0367 0.17888111 0.02813718
#> 9 0 0.6494903 570.2113 0.10996416 0.05961587
#> 10 0 0.3697915 293.7699 0.09714981 0.03307948
#> 11 0 0.3336309 461.5374 0.13162573 0.03967988
#> 12 0 0.4134998 583.3746 0.13233504 0.05000573
#> 13 0 0.4881166 277.0495 0.08327882 0.03775518
#> 14 0 0.3667455 557.0408 0.16807299 0.03739235
#> 15 0 0.4547538 337.6209 0.09157597 0.04195217
#> 16 0 0.2585073 203.7206 0.06908279 0.03307564
#> 17 0 0.7043788 1085.9700 0.14477110 0.08680713
#> 18 0 0.4539107 726.9494 0.15567199 0.05194208
#> 19 0 0.5353126 1349.7379 0.16218032 0.09829630
#> 20 0 0.1806790 204.5031 0.06642229 0.03418832
#> 21 0 0.3811979 274.6940 0.07981066 0.03952262
#> 22 0 0.3597952 295.0700 0.07244385 0.04525993
#> 23 0 0.3144527 1400.7043 0.18149138 0.09130958
#> 24 0 0.3098909 2499.0234 0.25775466 0.12293073
#> 25 0 0.7584850 1134.5526 0.32876937 0.03972353
#> 26 0 0.3420263 255.7407 0.06693856 0.04285185
#> 27 0 0.6775050 554.2208 0.13489388 0.04630831
#> 28 0 0.4839870 599.2169 0.16651374 0.04384393
#> abs_lift_in_zero rank
#> 1 0.002 1
#> 2 0.001 1
#> 3 0.004 3
#> 4 0.018 4
#> 5 0.009 4
#> 6 0.019 6
#> 7 0.022 7
#> 8 0.021 7
#> 9 0.010 9
#> 10 0.003 9
#> 11 0.032 11
#> 12 0.032 11
#> 13 0.017 13
#> 14 0.032 13
#> 15 0.008 15
#> 16 0.031 16
#> 17 0.045 17
#> 18 0.044 18
#> 19 0.062 18
#> 20 0.034 20
#> 21 0.020 20
#> 22 0.028 20
#> 23 0.081 23
#> 24 0.158 23
#> 25 0.229 25
#> 26 0.033 26
#> 27 0.035 26
#> 28 0.067 28
# }