Counterfactual Inference Using Time Series Data

Raw Text

Member-only story

Shelby Temple · Follow

20 min read · Jun 11

--

4

Share

In this article, we’ll explore a powerful causal inference technique that I believe every data scientist should have in their toolbox.

This article has six sections:

1) Introduction

2) Quick Causal Inference Primer

3) Brief Description of Causal Impact Algorithm

4) Applications of Counterfactual Inference with Time Series Data

5) Demo in Python, Using tfcausaimpact Package

6) Conclusion

The full project and all code can be seen in my github repository.

ThatShelbs / CausalInferenceTimeSeries

1) Introduction

Are you ever curious about the true impact of a new marketing campaign, product launch, new government policy, or some other event? Wouldn’t it be nice if you could compare the results of the event occurring versus never occurring at all? Well, with counterfactual inference using time series data, you can do just that! And the best part? You don’t need to be an actual time-traveling wizard — just a few lines of Python code from the tfcausalimpact package will suffice.

In this article, we’re going to take a deep dive into counterfactual inference using time series data. We’ll start with a quick primer on causal inference, followed by some real-world applications of counterfactual inference with time series data. And finally, we’ll wrap things up with a demo in Python, using the tfcausalimpact package.

By the end, you’ll have a solid understanding of this powerful technique and the tools you need to start using it in your own data science projects. So grab a cup of coffee and let’s get started!

2) Quick Causal Inference Primer

Before we dive in to CausalImpact analysis, let’s make sure we’re all on the same page. Here are five must-know things about causal inference to kickstart our journey.

1. What is causal inference?

Causal inference is the process of determining cause and effect between variables.

It is a much more powerful insight than just doing a feature importance analysis or…

Single Line Text

Member-only story. Shelby Temple · Follow. 20 min read · Jun 11. -- 4. Share. In this article, we’ll explore a powerful causal inference technique that I believe every data scientist should have in their toolbox. This article has six sections: 1) Introduction. 2) Quick Causal Inference Primer. 3) Brief Description of Causal Impact Algorithm. 4) Applications of Counterfactual Inference with Time Series Data. 5) Demo in Python, Using tfcausaimpact Package. 6) Conclusion. The full project and all code can be seen in my github repository. ThatShelbs / CausalInferenceTimeSeries. 1) Introduction. Are you ever curious about the true impact of a new marketing campaign, product launch, new government policy, or some other event? Wouldn’t it be nice if you could compare the results of the event occurring versus never occurring at all? Well, with counterfactual inference using time series data, you can do just that! And the best part? You don’t need to be an actual time-traveling wizard — just a few lines of Python code from the tfcausalimpact package will suffice. In this article, we’re going to take a deep dive into counterfactual inference using time series data. We’ll start with a quick primer on causal inference, followed by some real-world applications of counterfactual inference with time series data. And finally, we’ll wrap things up with a demo in Python, using the tfcausalimpact package. By the end, you’ll have a solid understanding of this powerful technique and the tools you need to start using it in your own data science projects. So grab a cup of coffee and let’s get started! 2) Quick Causal Inference Primer. Before we dive in to CausalImpact analysis, let’s make sure we’re all on the same page. Here are five must-know things about causal inference to kickstart our journey. 1. What is causal inference? Causal inference is the process of determining cause and effect between variables. It is a much more powerful insight than just doing a feature importance analysis or…