GeoLiftMarketSelection: GeoLift Market Selection algorithm based on a Power Analysis.

View source: R/pre_test_power.R

GeoLiftMarketSelectionR Documentation

GeoLift Market Selection algorithm based on a Power Analysis.

Description

[Stable]

GeoLiftMarketSelection provides a ranking of test markets for a GeoLift test based on a power analysis.

Usage

GeoLiftMarketSelection(
  data,
  treatment_periods,
  N = c(),
  X = c(),
  Y_id = "Y",
  location_id = "location",
  time_id = "time",
  effect_size = seq(-0.2, 0.2, 0.05),
  lookback_window = 1,
  include_markets = c(),
  exclude_markets = c(),
  holdout = c(),
  cpic = 1,
  budget = NULL,
  alpha = 0.1,
  normalize = FALSE,
  model = "none",
  fixed_effects = TRUE,
  dtw = 0,
  Correlations = FALSE,
  ProgressBar = FALSE,
  print = TRUE,
  run_stochastic_process = FALSE,
  parallel = TRUE,
  parallel_setup = "sequential",
  side_of_test = "two_sided",
  conformal_type = "iid",
  ns = 1000,
  import_augsynth_from = "library(augsynth)",
  import_tidyr_from = "library(tidyr)"
)

## S3 method for class 'GeoLiftMarketSelection'
print(x, ...)

## S3 method for class 'GeoLiftMarketSelection'
plot(
  x,
  market_ID = 0,
  print_summary = TRUE,
  actual_values = TRUE,
  smoothed_values = TRUE,
  show_mde = FALSE,
  breaks_x_axis = 10,
  ...
)

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. If left empty (default) and if no locations are included through include_locations, it will populate the list of markets with the deciles of the total number of locations. If left empty and a set of markets is provided by include_locations only the deciles larger or equal than length(include_locations) will be used.

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.

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.

include_markets

A list of markets or locations that should be part of the test group. Make sure to specify an N as large or larger than the number of provided markets or locations. Empty list by default.

exclude_markets

A list of markets or locations that won't be considered for the test market selection, but will remain in the pool of controls. Empty list by default.

holdout

A vector with two values: the first one the smallest desirable holdout and the second the largest desirable holdout. If left empty (default) all market selections will be provided regardless of their size.

cpic

Number indicating the Cost Per Incremental Conversion.

budget

Number indicating the maximum budget available for a GeoLift test.

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.

Correlations

A logic flag indicating whether an additional column with the correlations between the test regions and total control markets will be included in the final output. Set to FALSE by default.

ProgressBar

A logic flag indicating whether to display a progress bar to track progress. Set to FALSE by default.

print

A logic flag indicating whether to print the top results. Set to TRUE 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.

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.

import_augsynth_from

Points to where the augsynth package should be imported from to send to the nodes.

import_tidyr_from

Points to where the tidyr package should be imported from to send to the nodes.

x

GeoLiftMarketSelection()

...

additional arguments

market_ID

Numeric value indicating the market to be plotted. This value should reflect a valid ID from the BestMarkets data frame of the GeoLiftMarketSelection output.

print_summary

Logic flag indicating whether to print model metrics from the latest possible test. Set to TRUE by default.

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.

Value

A list with three Data Frames.

  • "BestMarkets":Data Frame with a ranking of the best markets based on power, Scaled L2 Imbalance, Minimum Detectable Effect, and proportion of total KPI in the test markets.

  • "PowerCurves":Data Frame with the resulting power curves for each recommended market.

  • "parameters;"List of parameters to plot the results. Includes the data set, model, fixed-effects, and CPIC parameters.


facebookincubator/GeoLift documentation built on May 31, 2024, 10:09 a.m.