Skip to contents

causewise measures the incremental effect (lift) of a marketing campaign with a geo-experiment: the campaign runs in some locations (the test group), and an Augmented Synthetic Control built from the other locations estimates what would have happened without it.

A geo-experiment has two stages:

  1. Design: choose test locations and a test length that give enough power to detect the effect you expect (GeoLiftMarketSelection()).
  2. Analysis: once the test has run, estimate the lift and its uncertainty (GeoLift()).

This vignette shows both with the example data that ships with causewise. The full walkthrough covers every option in detail.

causewise continues the GeoLift package. If you have GeoLift code, replace library(GeoLift) with library(causewise) and it will keep working.

library(causewise)
#> causewise 3.0.0: the continuation of GeoLift by its original author. Not affiliated with or endorsed by Meta.

Read the data

GeoDataRead() turns a data frame with one row per location and date into the panel format causewise uses: a location, a time index starting at 1, and the outcome Y.

data(GeoLift_Test)
geo_data <- GeoDataRead(
  data = GeoLift_Test,
  date_id = "date",
  location_id = "location",
  Y_id = "Y",
  format = "yyyy-mm-dd"
)
head(geo_data)
#>   location time    Y
#> 1  atlanta    1 3384
#> 2  atlanta    2 3904
#> 3  atlanta    3 5734
#> 4  atlanta    4 4311
#> 5  atlanta    5 3686
#> 6  atlanta    6 3374

In this example the campaign ran in Chicago and Portland from period 91 to period 105.

Design a test

Before a campaign, GeoLiftMarketSelection() simulates tests on historical data to rank candidate test groups by power, minimum detectable effect, and cost. It runs many simulations, so it is not evaluated here.

data(GeoLift_PreTest)
pre_test <- GeoDataRead(
  data = GeoLift_PreTest, date_id = "date", location_id = "location",
  Y_id = "Y", format = "yyyy-mm-dd"
)

set.seed(1)
markets <- GeoLiftMarketSelection(
  data = pre_test,
  treatment_periods = c(10, 15),
  N = c(2, 3, 4),
  effect_size = seq(0, 0.3, 0.05),
  include_markets = "chicago",
  cpic = 7.5,
  budget = 100000,
  alpha = 0.1,
  parallel = FALSE
)
markets
plot(markets, market_ID = 1)

Analyze a test

lift <- GeoLift(
  Y_id = "Y",
  data = geo_data,
  locations = c("chicago", "portland"),
  treatment_start_time = 91,
  treatment_end_time = 105
)
lift
#> 
#> GeoLift Output
#> 
#> Test results for 15 treatment periods, from time-stamp 91 to 105 for test markets:
#> 1 CHICAGO
#> 2 PORTLAND
#> ##################################
#> #####     Test Statistics    #####
#> ##################################
#> 
#> Percent Lift: 5.4%
#> 
#> Incremental Y: 4667
#> 
#> Average Estimated Treatment Effect (ATT): 155.556
#> 
#> The results are significant at a 95% level. (TWO-SIDED LIFT TEST)
#> 
#> There is a 1.4% chance of observing an effect this large or larger assuming treatment effect is zero.

summary() adds balance statistics and the weights of the synthetic control.

summary(lift)
#> 
#> GeoLift Results Summary
#> ##################################
#> #####     Test Statistics    #####
#> ##################################
#> 
#> * Average ATT: 155.556
#> * Percent Lift: 5.4%
#> * Incremental Y: 4667
#> * P-value: 0.01
#> 
#> ##################################
#> #####   Balance Statistics   #####
#> ##################################
#> 
#> * L2 Imbalance: 909.489
#> * Scaled L2 Imbalance: 0.1636
#> * Percent improvement from naive model: 83.64%
#> * Average Estimated Bias: NA
#> 
#> ##################################
#> #####     Model Weights      #####
#> ##################################
#> 
#> * Prognostic Function: NONE
#> 
#> * Model Weights:
#>  * cincinnati: 0.2272
#>  * miami: 0.2028
#>  * baton rouge: 0.1335
#>  * minneapolis: 0.09
#>  * dallas: 0.0739
#>  * nashville: 0.0685
#>  * honolulu: 0.0673
#>  * austin: 0.0465
#>  * san diego: 0.0451
#>  * reno: 0.0306
#>  * san antonio: 0.0054
#>  * new york: 0.0046
#>  * houston: 0.0046

The lift plot compares the test locations with their synthetic control.

plot(lift, type = "Lift")
#> You can include dates in your chart if you supply the end date of the treatment. Just specify the treatment_end_date parameter.