
Explore econometric and causal inference techniques, difference in differences, Google Causal Impact, Granger causality, and propensity score matching, through use cases, intuition tutorials, and hands-on coding in R or Python.
Access course resources, including Python and R templates, PDF slides, and papers on difference in differences, Granger causality, and Google's causal impact, plus practice tutorials.
learn to install R and RStudio on Windows or Mac OS by downloading RStudio Desktop and R from CRAN, then follow prompts to complete setup.
Install python from python.org and set up your coding environment with python 3.8.3. Install Spyder through the Anaconda distribution, or use Jupyter, which includes Pandas, Matplotlib, and TensorFlow.
Diogo introduces his background in management and analytics, illustrating how data drives business decisions, from large-scale sales planning to A/B tests.
Join me in shaping the future of this course by co-creating it with you, inviting suggestions, thoughts, and critiques to continually improve current and future offerings, with ratings throughout.
Explore difference-in-differences, a quasi-experimental method using a control group to measure treatment impact and address omitted variable bias across policy changes, weather effects, M&A, and geo marketing tests.
Apply the difference-in-differences framework to estimate the employment impact of a minimum wage change by comparing New Jersey and Pennsylvania before and after, using a baseline and delta.
Learn to model difference-in-differences by using dummy variables for New Jersey and Pennsylvania and for pre/post April 1992, and form their product to capture the wage increase impact.
Identify and test the difference-in-differences assumptions, including parallel trends and confounding policy change, and strengthen validity with more control groups, longer periods, and placebo tests.
Define treatment and post period, create the treatment-post interaction, and map New Jersey versus Pennsylvania for a difference-in-differences analysis. Run a regression with controls and conduct a placebo test.
Explore how linear regression uses years of experience to predict wage, explain the difference between regression and correlation, and interpret the slope as the measure of impact.
Explore how to interpret linear regression output, focusing on estimates, standard errors, confidence intervals, and p-values to assess statistical significance.
Learn how to avoid the dummy variable trap in regression by omitting one category, using the intercept as the baseline, and interpreting the Coca Cola vs Pepsi example.
Explore the RStudio environment, write scripts, and load data with read.csv; use summary to inspect and handle missing values while studying difference in differences.
Learn to handle missing data by replacing NA values in the FTE variable with the variable mean using an if-else workflow in R.
Learn to deal with NAs in R and Python by quickly replacing variables with copy-paste code, verifying datasets for no missing values, and using ready-made templates for faster future projects.
Create your first linear regression in R, defining NJ, post April 92nd, and the NJ_post_April_92nd interaction; interpret coefficients, p-values, and the adjusted R-squared to assess employment effects.
Build the second regression model by adding dummy variables for Burger King, KFC, Roy's, and Wendy's, and exclude one category as baseline to reduce omitted variable bias.
Develop a third regression model by adding a co-owned dummy, Central J, and South J to assess the impact of increasing the minimum wage on employment, while addressing omitted variable bias.
Apply multiple regression models in R and visualize results with stargazer, comparing models to reveal a consistent coefficient suggesting higher minimum wage may increase employment.
Set up a Python environment for differences in differences analysis in Google Colab. Mount Drive and load the minimum wage dataset with FTE as the dependent variable.
Learn data analysis and processing in Python, performing summary statistics with dataframe.describe, handling missing values with SimpleImputer, and exploring mean versus median to assess distribution tails.
Explore differences-in-differences using Google Sheets or Excel, create pivot tables, and compute counterfactuals to estimate treatment effects with Pennsylvania and New Jersey data.
Build linear regression in python with statsmodels, add a constant, and interpret the intercept and coefficients for New Jersey and after April 1992 regarding minimum wage and fast food employment.
Learn to visualize model output in Python by extracting coefficients and plotting pre/post FTE data for Pennsylvania, using Matplotlib and annotations.
Combine intercept, New Jersey, and post April 1992 coefficients to visualize actual and counterfactual outcomes. Illustrate the minimum wage impact with plots and legends.
Build the second regression model with control variables, add a constant, and show that the treatment coefficient remains about 2.68 across different controls, illustrating reproducibility and validity.
We build a third regression model with x3, run the analysis, and interpret a stable coefficient and meta-analysis insights, concluding that the treatment increases employment.
Fill out the feedback form in the next lecture to share what's firing you up and what's missing to improve econometrics and statistics for business in R and Python.
Explore a second difference-in-differences case study on the 1994 tax credit expansion for single women with children and its employment impact, using logistic regression for binary outcomes.
Explore logistic regression as a tool for binary outcomes, contrast it with linear regression, and interpret coefficients as probabilities using years of education as a predictor.
Learn the mechanics of a placebo test to validate parallel trends when evaluating the tax credit for single women with children, using a what if scenario and logistic regression.
Load and inspect a Stata data set in R for a difference-in-differences study using read_dta. Explore a 13,000-observation dataset of women, and begin creating pre-post and other variables for analysis.
Create dummy variables for post 1994 and for whether the single woman has children, and form their interaction to enable a difference in differences analysis.
Apply a first logistic regression in R with glm and binomial family to model work, specifying a formula and data source, and interpret coefficients as changes in likelihood.
Create a second logistic regression by adding education and non-white, run the model, and note that education is positive, non-white negative, and mom_post_93 is significant with a positive employment impact.
Visualize regression results with Stargazer in R, customizing covariate labels, digits, and formatting for two models to highlight the tax credit's effect on employment and reinforce causal interpretation.
Create a time variable for 1991–1993, generate placebo treatment indicators like post 92 and post 93, and subset the dataset to year 1993 for the placebo experiment.
Run a logistic regression on the placebo dataset to test parallel trends. Explore causality and refine models with additional control variables, preparing results for the q&a section.
Learn to set up Python for econometrics by mounting Google Drive, loading Stata data, and preparing a differences-in-differences analysis of tax credits on employment.
Process data to assess the tax credit impact on moms by creating dummy variables, isolating x and y, and preparing binary indicators for mom and post-1993 for logistic regression.
Develop a first logistic regression model in python using sm logit, add a constant to x, and convert log odds to probabilities with a logit-to-prob function.
Visualize the difference-in-differences results using Python, fetching coefficients, converting logit to probabilities, and plotting employment probabilities for moms and non-moms over time.
Explore visualizing model output in python by plotting employment probabilities for moms and non-moms, illustrating counterfactuals, markers, colors, and dashed lines to compare development over time.
Build a second logistic model by expanding x with mom post 93, education, age, and unearned cash, and examine coefficient significance to reinforce the conclusion across models.
Explore a placebo experiment by simulating a 1993 treatment, subsetting data to 1991-1993, creating post_92 variables, and running a logistic regression to assess significance, followed by visualization.
Visualize a placebo experiment in Python by updating the model to display the placebo counterfactual and compare mom and non-mom employment probabilities.
Explore Google's causal impact approach for inferring causal effects over time using Bayesian structural time series, focusing on weekly or daily data and comparisons to difference-in-differences.
Explore the value added by the causal impact approach, using multiple control groups to measure incremental uplift and the cumulative impact over time.
Follow a step-by-step guide to implement Google's causal impact, defining pre and post periods, gathering time series data, testing parallel trends, and applying the causal impact model.
Apply Google's causal impact to analyze Facebook's stock price around the Cambridge Analytica scandal, focusing on the post period from March to June 2018 and the related fine.
Load Facebook stock price by defining pre and post periods, setting a training and treatment window, and retrieving weekly close data with the ts series library in R.
Load additional stock prices by selecting four stocks—Walmart, Disney, BMW, Novartis—and using their tickers as instruments to avoid confounding, then plot the data for visual inspection.
Aggregate close prices for Facebook, Walmart, Disney, BMW, and Novartis into a series object, bind with cbind, and plot with ggplot2 autoplot in R; compare separate and single-graph views.
Choose control groups by evaluating correlations among stock data, selecting Goldman Sachs, McDonald's, Carlsberg, and Walmart to compare with Facebook, and lay groundwork for causal impact analysis.
Learn to prepare a dataset for causal impact by selecting control groups, creating a final series, and defining pre and post periods with proper date formatting.
Install and load the Google causal impact package, create an impact object, and run causal_impact with data, pre period, post period, and model options. Set n seasons to 52.
Updates:
November 2024: All Python tutorials have been remade and are up to date.
Econometrics has horrible fame. The complex theorems, combined with boring classes where it feels like you are learning Greek, give every student nightmares. This course stays away from that. It will focus on (1) giving you the intuition and tools to apply the techniques learned, (2) making sure everything that you learn is actionable in your career, and (3) offer you a tool kit of peer-reviewed econometric causal inference techniques that will make you stand out and give you the ability to answer the tough questions.
WHY ECONOMETRICS AND CAUSAL INFERENCE FOR BUSINESS IN R AND Python?
In each section, you will learn a new technique. The learning process is split into three parts. The first is an overview of Use Cases. Drawing from business literature and my own experience, I will show examples where each Econometric technique has been applied. The goal here is to show that Econometric methods are actionable. The second part is the Intuition tutorials. The aim is for you to understand why the technique makes sense. All intuition tutorials are based on business situations. The last part is the Practice tutorials, where we will code and solve a business or economic problem. There will be at least one practice tutorial per section.
Below are 4 points on why this course is not only relevant but also stands out from others.
1| THOROUGH COURSE STRUCTURE OF MOST IMPACTFUL ECONOMETRIC TECHNIQUES
The techniques in this course are the ones I believe will be most impactful in your career. Like HR, Marketing, Finance, or Operations, all company departments can use these causal techniques. Here is the list:
Difference-in-differences
Google's Causal Impact
Granger Causality
Propensity Score Matching
CHAID
2| BUSINESS EXAMPLES TO FOSTER INTUITION
Each section starts with an overview of business cases and studies where each econometric technique has been used. I will use examples that come from my own professional experience and business literature. The aim is to give you the intuition where to apply them in your current job. By the end of each intuition tutorial, you will be able to easily explain the concepts to your colleagues, manager, and stakeholders.
One of the benefits of giving actual business problems as examples is that you will find similar or even equal issues in your current company. In turn, this enables you to apply what you have learned immediately. Here are some examples:
Impact of M&A on companies.
Understanding how weather influences sales.
Measuring the impact of brand campaigns.
Whether Influencer or Social Media Marketing results in sales.
Investigating the drivers of customer satisfaction.
3| CHALLENGING AND INTERESTING PROBLEMS TO APPLY WHAT YOU LEARNED
For each section, we will have at least one real business or economic dataset. We will apply what we learned during the intuition tutorials.
Here are some examples of problems we will solve and code together:
Measuring the impact of the Cambridge Analytica Scandal on Facebook's stock price.
Assessing the results of giving training to employees.
Challenge the idea that increasing the minimum wage decreases employment.
Ranking the drivers on why people quit their jobs.
Solving the thousand-year-old riddle of who came first: "Chicken or the egg?".
4| HANDS-ON CODING
We will code together, in R and Python. In every single practice tutorial, we will start from scratch, building the code line by line. As also an online coding student, I feel this has been the easiest way to learn.
On top, the code will be built so that you download it and apply the causal inference techniques in your work and projects. Additionally, I will explain what you have to change to use in your dataset and solve the problem you have at hand.
Econometrics for Business in R and Python is a course that naturally extends into your career.
***SUMMARY
The course is packed with use cases, intuition tutorials, hands-on coding, and, most importantly, is actionable in your career.
Feel free to reach out if you have any questions, and I hope to see you inside!
Diogo