Log in from a computer to take this course

You'll need to log in from a computer to start Learn the Basics of Causal Inference with R. But you can practice or keep up your coding streak with the Codecademy Go app. Download the app to get started.

apple storegoogle store
Learn

Because we can never know both potential outcomes for an individual, we need to use a different method to estimate causal effects. The most accurate way to do this is to use randomization.

Randomization is a method of treatment group assignment that is essentially a coin flip to determine whether an individual receives the treatment or the control. This ensures that, for a large enough sample size, the treatment groups will be similar on average with respect to all factors EXCEPT for the treatment condition. While we still won’t know the counterfactual outcome for any individual, we can be reasonably confident that similar individuals received each treatment. This allows us to estimate the potential outcomes we weren’t able to observe.

When randomization is possible, we can estimate the ATE by taking the difference of the average observed outcome values in the treatment and control groups. In the example in the learning environment, the estimated ATE equals -5.4, which is very close to the true ATE of -5.8 that was calculated in the previous exercise.

Instructions

Here are some ATE calculation practice questions!

True ATE Calculation

Calculate the true ATE using the following data.

Z Y1 Y0 Y1 - Y0
1 15 8 7
1 23 19 4
0 26 21 5
0 31 22 9
1 20 21 -1
0 23 17 6
Expand for Solution
Average of Y1 - Average of Y0

Average of Y1: (15 + 23 + 26 + 31 + 20 + 23) / 6 = 23

Average of Y0: (8 + 19 + 21 + 22 + 21 + 17) / 6 = 18

True ATE: 23 - 18 = 5

Alternatively, we can use the average of the column Y1 - Y0.

True ATE: (7 + 4 + 5 + 9 - 1 + 6) / 6 = 5

Estimated ATE Calculation

Now calculate the estimated ATE when treatment assignment is randomized.

Z Y1 Y0 Y
1 23 ? 23
1 31 ? 31
0 ? 33 33
0 ? 22 22
1 30 ? 30
0 ? 17 17
Expand for Solution
Average Y where Z = 1: (23 + 31 + 30) / 3 = 28
Average Y where Z = 0: (33 + 22 + 17) / 3 = 24
Estimated ATE: 28 - 24 = 4

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?