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
TRUE
orFALSE
## for each observation, does the value of race equal "black"?
$race == "black" resume
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)\)
<- mean(resume$call[resume$race == "black"]) -
ate mean(resume$call[resume$race == "white"])
ate
## [1] -0.03203285
How can we interpret this? Do white applicants have an advantage?