3.6 Relational Operators in R
Goal: Compare callback rates for white sounding names to black sounding names, so we need to be able to filter by race.
Good news: We have several relational operators in R that evaluate logical statements:
==, <, >, <=, >=, !=- We have a statement and R evaluates it as
TRUEorFALSE
## for each observation, does the value of race equal "black"?
resume$race == "black"By putting this logical statement within [ ], we are asking R to take the mean() of the variable resume$call for the subset of observations for which this logical statement is TRUE.
mean(resume$call[resume$race == "black"])## [1] 0.06447639
Ultimately, each of these paths has led us to a place where we can estimate the average treatment effect by calculation the difference in means: the difference in callback rates for black and white applicants.
We said the ATE = \(\bar{Y}(treatment) - \bar{Y}(control)\)
ate <- mean(resume$call[resume$race == "black"]) -
mean(resume$call[resume$race == "white"])
ate## [1] -0.03203285
How can we interpret this? Do white applicants have an advantage?