Skip to contents

[Experimental]

MultiCellPower performs a Power-Analysis for a given set of Market Selections obtained from MultiCellMarketSelection.

Usage

MultiCellPower(
  x,
  test_markets = list(),
  effect_size = seq(-0.25, 0.25, 0.05),
  lookback_window = NULL,
  side_of_test = NULL,
  conformal_type = "iid",
  ns = 1000
)

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

# S3 method for class 'MultiCellPower'
plot(
  x,
  actual_values = TRUE,
  smoothed_values = FALSE,
  show_mde = TRUE,
  breaks_x_axis = 10,
  stacked = TRUE,
  ...
)

Arguments

x

MultiCellMarketSelection()

test_markets

List of market IDs per cell. The list must contain exactly k numeric values corresponding to the power analysis. The list's layout must be: list(cell_1 = 1, cell2 = 1, cell3 = 1,...).

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.

side_of_test

A string indicating whether confidence will be determined using a one sided or a two sided test. If set to NULL (default), the side_of_test will be populated by the value specified in MultiCellMarketSelection.

"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.

...

additional arguments

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.

stacked

Logic flag indicating whether to stack all the Multi-Cell plots together vertically or to output each one of them separately. Set to TRUE by default.

Value

A 'MultiCellPower' object with three objects:

"PowerCurves":

List containing the Power Curves for each cell.

"data":

The input data.

"test_details":

The test details.

MultiCellPower output message

Examples

# \donttest{
geo_pre <- GeoDataRead(GeoLift_PreTest, date_id = "date", location_id = "location",
  Y_id = "Y", format = "yyyy-mm-dd")
set.seed(1)
markets <- MultiCellMarketSelection(data = geo_pre, k = 2, top_choices = 3, N = 2,
  effect_size = c(0, 0.1, 0.2), treatment_periods = 10, cpic = c(7, 7.5),
  alpha = 0.1, side_of_test = "one_sided", parallel = FALSE, ns = 100)
markets
#>   cell ID               location duration EffectSize AvgScaledL2Imbalance
#> 1    1  1 honolulu, indianapolis       10        0.1            0.3083715
#> 2    2  1  detroit, jacksonville       10        0.1            0.3240558
#> 3    1  2        denver, memphis       10        0.1            0.6659785
#> 4    2  2   nashville, san diego       10        0.1            0.4341552
#> 5    1  3    memphis, washington       10        0.1            0.4849799
#> 6    2  3  las vegas, saint paul       10        0.1            0.7694359
#>   abs_lift_in_zero Investment ProportionTotal_Y   Holdout rank
#> 1            0.001   42224.70        0.03307948 0.9669205    1
#> 2            0.002   40002.00        0.02940561 0.9705944    1
#> 3            0.002   53951.10        0.04433701 0.9556630    2
#> 4            0.003   51087.75        0.03891756 0.9610824    2
#> 5            0.005   48582.10        0.03939854 0.9606015    3
#> 6            0.007   60643.50        0.04571975 0.9542802    3
power <- MultiCellPower(markets, test_markets = list(cell_1 = 1, cell_2 = 1),
  effect_size = c(0, 0.1, 0.2), ns = 100)
power
#> $cell_1
#>                 location pvalue duration EffectSize treatment_start Investment
#> 1 honolulu, indianapolis   0.47       10        0.0              81        0.0
#> 2 honolulu, indianapolis   0.00       10        0.1              81    42224.7
#> 3 honolulu, indianapolis   0.00       10        0.2              81    84449.4
#>   cpic ScaledL2Imbalance att_estimator detected_lift power
#> 1    7         0.3551662     -7.722972  -0.002554085     0
#> 2    7         0.3551662    293.882028   0.097190507     1
#> 3    7         0.3551662    595.487028   0.196935098     1
#> 
#> $cell_2
#>                location pvalue duration EffectSize treatment_start Investment
#> 1 detroit, jacksonville   0.73       10        0.0              81          0
#> 2 detroit, jacksonville   0.00       10        0.1              81      40002
#> 3 detroit, jacksonville   0.00       10        0.2              81      80004
#>   cpic ScaledL2Imbalance att_estimator detected_lift power
#> 1  7.5         0.2359467      46.15156    0.01761074     0
#> 2  7.5         0.2359467     312.83156    0.11937181     1
#> 3  7.5         0.2359467     579.51156    0.22113289     1
#> 
# }