{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Estimating the Effect of a Member Rewards Program\n", "An example on how DoWhy can be used to estimate the effect of a subscription or a rewards program for customers. \n", "\n", "Suppose that a website has a membership rewards program where customers receive additional benefits if they sign up. How do we know if the program is effective? Here the relevant causal question is:\n", "> What is the impact of offering the membership rewards program on total sales?\n", "\n", "And the equivalent counterfactual question is, \n", "> If the current members had not signed up for the program, how much less would they have spent on the website?\n", "\n", "In formal language, we are interested in the Average Treatment Effect on the Treated (ATT). " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## I. Formulating the causal model\n", "Suppose that the rewards program was introduced in January 2019. The outcome variable is the total spends at the end of the year. \n", "We have data on all monthly transactions of every user and on the time of signup for those who chose to signup for the rewards program. Here's what the data looks like." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | user_id | \n", "signup_month | \n", "month | \n", "spend | \n", "treatment | \n", "
---|---|---|---|---|---|
0 | \n", "0 | \n", "1 | \n", "1 | \n", "449 | \n", "True | \n", "
1 | \n", "0 | \n", "1 | \n", "2 | \n", "583 | \n", "True | \n", "
2 | \n", "0 | \n", "1 | \n", "3 | \n", "519 | \n", "True | \n", "
3 | \n", "0 | \n", "1 | \n", "4 | \n", "581 | \n", "True | \n", "
4 | \n", "0 | \n", "1 | \n", "5 | \n", "549 | \n", "True | \n", "
... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
119995 | \n", "9999 | \n", "0 | \n", "8 | \n", "410 | \n", "False | \n", "
119996 | \n", "9999 | \n", "0 | \n", "9 | \n", "409 | \n", "False | \n", "
119997 | \n", "9999 | \n", "0 | \n", "10 | \n", "398 | \n", "False | \n", "
119998 | \n", "9999 | \n", "0 | \n", "11 | \n", "401 | \n", "False | \n", "
119999 | \n", "9999 | \n", "0 | \n", "12 | \n", "394 | \n", "False | \n", "
120000 rows × 5 columns
\n", "