One way we can estimate the ATT is by comparing the differences in average wages over both time and treatment groups.

Let’s view the mean wages for both states for 2016 and 2017 only.

# import library library(dplyr) # filter data wages %>% filter(year > 2015) #only 2016 and 2017

The output looks like the following:

state year avg_wage 1 California 2016 13.311279 2 California 2017 16.000000 3 Washington 2016 9.728146 4 Washington 2017 10.000000

First, let’s use the means in our output to take the difference in average wages before and after the law for each state.


mean2017 - mean2016 = $16.00 - $13.31 = $2.69


mean2017 - mean2016 = $10.00 - $9.73 = $0.27

Hypothetically, if the law had no effect on wages, we would expect the difference between the post-treatment mean and the pre-treatment mean for the treatment group would be similar to the difference for the control group. However, these findings match what we saw in our plots before: California experienced a MUCH LARGER change in average wages from 2016 to 2017 than Washington did.

But how much of that California change was due to factors other than the new law? We answer this question by taking the difference of the differences we just found — which is where this method gets its name!

ATT = differenceCalifornia - differenceWashington

ATT = $2.69 - $0.27

ATT = $2.42

According to our basic 2x2 DID that uses mean differences alone, we estimate the average treatment effect on the treated to be $2.42. But there’s still another DID method we might want to try!



The tickets dataset has been filtered to just the years 2018 and 2019 and saved for you as tickets2 in notebook.Rmd. Print tickets2 and inspect the average ticket sales for each city.


Using the tickets2 output and either R or a calculator, compute the change in average tickets sales from 2018 to 2019 for each city. Save Toronto’s difference as Tdiff and Sydney’s difference as Sdiff.


Compute the DID estimate for the impact of the new tax by subtracting Toronto’s difference from Sydney’s difference. Save this value as did_means.


Print did_means and consider its value. What does this tell you about the impact of the new tax on average ticket sales in Sydney?

Take this course for free

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?