Power Calculation to determine the number of test periods with unknown test locations.
Source:R/pre_test_power.R
NumberLocations.RdDevelopment on NumberLocations() is complete.
We recommend switching to GeoLiftMarketSelection()
for new code, which is easier to use, more featureful,
and still under active development.#'
NumberLocations calculates power to determine the
number of test periods with unknown test locations.
Usage
NumberLocations(
data,
number_locations = c(),
treatment_periods,
n_sim = 50,
X = c(),
Y_id = "Y",
location_id = "location",
time_id = "time",
plot = TRUE,
power = 0.8,
alpha = 0.1,
type = "pValue",
normalize = FALSE,
model = "none",
fixed_effects = TRUE,
stat_func = NULL,
ProgressBar = FALSE,
parallel = TRUE,
parallel_setup = "sequential"
)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.
- number_locations
List of number of locations to test. If not specified, the number of locations will be computed by percentiles up to half of the total number of locations.
- treatment_periods
Number of treatment periods.
- n_sim
Number of simulations.
- X
List of covariate names.
- Y_id
Name of the outcome variable (String).
- location_id
Name of the location variable (String).
- time_id
Name of the time variable (String).
- plot
Plots results when TRUE.
- power
Power level. By default 0.8.
- alpha
Significance Level. By default 0.1.
- 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.
- stat_func
Function to compute test statistic. NULL 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.
Examples
# \donttest{
geo_pre <- GeoDataRead(GeoLift_PreTest, date_id = "date", location_id = "location",
Y_id = "Y", format = "yyyy-mm-dd")
set.seed(1)
NumberLocations(geo_pre, number_locations = c(2, 4), treatment_periods = 10,
n_sim = 5, plot = FALSE, parallel = FALSE)
#> locations pvalue n treatment_start
#> 1 detroit, orlando 0.624 2 81
#> 2 houston, philadelphia 0.530 2 81
#> 3 phoenix, dallas 0.295 2 81
#> 4 detroit, new york 0.286 2 81
#> 5 memphis, detroit 0.423 2 81
#> 6 austin, memphis, saint paul, minneapolis 0.666 4 81
#> 7 miami, new york, oklahoma city, boston 0.597 4 81
#> 8 phoenix, new orleans, cincinnati, new york 0.516 4 81
#> 9 milwaukee, oakland, detroit, salt lake city 0.101 4 81
#> 10 denver, baltimore, cincinnati, orlando 0.972 4 81
#> ScaledL2Imbalance
#> 1 0.2599079
#> 2 0.5911624
#> 3 0.5085435
#> 4 0.2443502
#> 5 0.4750140
#> 6 0.2664109
#> 7 0.5204893
#> 8 0.3701221
#> 9 0.2951861
#> 10 0.1892916
# }