Power Calculation for GeoLift for known test locations.
Source:R/pre_test_power.R, R/plots.R
GeoLiftPower.RdThis function runs power calculations for input historical geo data for a pre-determined set of test locations.
Usage
GeoLiftPower(
data,
locations,
effect_size = seq(0, 1, 0.05),
treatment_periods,
lookback_window = 1,
cpic = 0,
X = c(),
Y_id = "Y",
location_id = "location",
time_id = "time",
alpha = 0.1,
type = "pValue",
normalize = FALSE,
model = "none",
fixed_effects = TRUE,
ProgressBar = FALSE,
parallel = TRUE,
parallel_setup = "sequential",
side_of_test = "two_sided",
conformal_type = "iid",
ns = 1000
)
# S3 method for class 'GeoLiftPower'
plot(
x,
actual_values = TRUE,
smoothed_values = TRUE,
show_mde = FALSE,
breaks_x_axis = 10,
notes = "",
...
)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.
- locations
A semi-colon separated list of test geo locations.
- effect_size
A vector of effect sizes to test by default a sequence between 0 - 100 percent in 5 percent increments: seq(0,1,0.05).
- treatment_periods
Expected length of the test. A vector of possible lengths can be entered for multiple options.
- lookback_window
A number indicating how far back in time the simulations for the power analysis should go. For instance, a value equal to 5 will simulate power for the last five possible tests. By default lookback_window = 1 which will only execute the most recent test based on the data.
- cpic
Cost Per Incremental Conversion for estimated test minimum budget. The default value is 0, in which case no investment estimation will be provided.
- X
List of names of covariates. No covariates are used by default.
- Y_id
Name of the outcome variable. "Y" by default.
- location_id
Name of the location variable. "Y" by default.
- time_id
Name of the time variable. "Y" by default.
- alpha
Significance level. Set to 0.1 by default.
- type
Method of inference used in the analysis. pValue=Provides conformal inference to provide the aggregate p-value for the null hypothesis of no effect from the intervention. The Default type is pValue. Imbalance=Uses the model's Scaled L2 Imbalance metric.
- 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.
- ProgressBar
A logic flag indicating whether to display a progress bar to track progress. Set to FALSE by default.
- 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.
- 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
GeoLiftPower()output.- actual_values
Logic flag indicating whether to include in the plot the actual values. TRUE by default.
- smoothed_values
Logic flag indicating whether to include in the plot the smoothed values. TRUE by default.
- show_mde
Logic flag indicating whether to include in the plot the positive and negative MDEs. FALSE by default.
- breaks_x_axis
Numeric value indicating the number of breaks in the x-axis of the power plot. You may get slightly more or fewer breaks that requested based on
breaks_pretty(). Set to 10 by default.- notes
String with additional notes to add as caption.
- ...
additional arguments
Value
GeoLiftPower object that contains:
- "location":
Test units of the simulation
- "pvalue":
P Value for each simulation
- "duration":
Duration of the simulation
- "effect_size":
Effect Size used for the simulation
- "treatment_start":
Treatment start time for the simulation
- "investment":
Estimated Investment
- "cpipc":
Cost Per Incremental Conversion
- "ScaledL2Imbalance":
Scaled L2 Imbalance metric
Examples
# \donttest{
geo_pre <- GeoDataRead(GeoLift_PreTest, date_id = "date", location_id = "location",
Y_id = "Y", format = "yyyy-mm-dd")
set.seed(1)
power <- GeoLiftPower(geo_pre, locations = c("chicago", "portland"),
effect_size = seq(0, 0.2, 0.05), treatment_periods = 10, cpic = 7.5,
side_of_test = "one_sided", parallel = FALSE, ns = 100)
#> Calculating Power for the following treatment group: chicago; portland.
plot(power, smoothed_values = FALSE)
# }