Read Causal design patterns for data analysts, (Riederer 2021)
Overview of different approaches for making causal claims from observational data.
Read BNT162b2 mRNA Covid-19 Vaccine in a Nationwide Mass Vaccination Setting, (Dagan et al. 2021)
Compares causal conclusions drawn from observational data with those of a randomized trial.
Read The Effect: An Introduction to Research Design and Causality, Chapters 18 “Difference-in-Differences”, 19 “Instrumental Variables”, and 20 “Regression Discontinuity”, (Huntington-Klein 2021)
Overview of three key approaches for making causal claims from observational data.
Read Understanding regression discontinuity designs as observational studies, (Sekhon and Titiunik 2017)
Discusses some concerns with the use of regression discontinuity.
Key concepts and skills
Running an experiment is not always possible, but we can use various approaches to nonetheless be able to speak to causality to some extent. The first step is to be clear about the relationships that we expect by building a DAG.
We need to be careful of common paradoxes including Simpson’s paradox and Berkson’s paradox, and be aware of pitfalls from matching.
We can use difference in differences when we have data on both treated and untreated units at both time periods. Regression discontinuity is useful when a group is either treated or not, but the two groups are very similar apart from the treatment. And instrumental variables is an approach used to estimate causality indirectly through another variable.
In general, these approaches need to be used with humility and concern for weaknesses and assumptions, both those that we can test and those that we cannot.
Life is grand when we can conduct experiments to be able to speak to causality. But there are circumstances in which we cannot run an experiment, yet nonetheless want to be able to make causal claims. And data from outside experiments have value that experiments do not have. In this chapter we discuss the circumstances and methods that allow us to speak to causality using observational data. We use relatively simple methods, in sophisticated ways, drawing from statistics, but also a variety of social sciences, including economics, and political science, as well as epidemiology.
For instance, Dagan et al. (2021) use observational data to confirm the effectiveness of the Pfizer-BioNTech vaccine. They discuss how one concern with using observational data in this way is confounding, which is where we are concerned that there is some variable that affects both the explanatory and dependent variables and can lead to spurious relationships. Dagan et al. (2021) adjust for this by first making a list of potential confounders, such as age, sex, geographic location, healthcare usage and then adjusting for each of them, by matching, one-to-one between people that were vaccinated and those that were not. The experimental data guided the use of observational data, and the larger size of the latter enabled a focus on specific age-groups and extent of disease.
This chapter is about using observational data in sophisticated ways. How we can nonetheless be comfortable making causal statements, even when we cannot run A/B tests or RCTs. Indeed, in what circumstances may we prefer to not run those or to run observational-based approaches in addition to them. We cover three of the major methods: difference in differences; regression discontinuity; and instrumental variables.
14.2 Directed acyclic graphs
When we are discussing causality, it can help to be specific about what we mean. It is easy to get caught up in observational data and trick ourselves. It is important to think hard, and to use all the tools available to us. For instance, in that earlier example, Dagan et al. (2021) were able to use experimental data as a guide. Most of the time, we will not be so lucky as to have both experimental data and observational data available to us. One framework that can help with thinking hard about our data is the use of directed acyclic graphs (DAG). DAGs are a fancy name for a flow diagram and involves drawing arrows and lines between the variables to indicate the relationship between them.
To construct them we use Graphviz, which is an open-source package for package graph visualization and is built into Quarto. The code needs to be wrapped in a “dot” chunk rather than “R”, and the chunk options are set with “//|” instead of “#|”. Alternatives that do not require this include the use of DiagrammeR(Iannone 2022) and ggdag(Barrett 2021). We provide the whole chunk for the first DAG, but then, only provide the code for the others.
```{dot}//| label: fig-dot-firstdag-quarto//| fig-cap: "We expect a causal relationship between x and y, where x influences y"//| fig-width: 4digraph D { node [shape=plaintext, fontname = "helvetica"]; {rank=same x y}; x -> y;}```
Figure 14.1: We expect a causal relationship between x and y, where x influences y
In Figure 14.1, we are saying that we think x causes y.
We could build another DAG where the situation is less clear. To make the examples a little easier to follow, we will switch to thinking about a hypothetical relationship between income and happiness, with consideration of variables that could affect that relationship. In this first one we consider the relationship between income and happiness, along with education (Figure 14.2).
Figure 14.2: Education is a confounder that affects the relationship between income and happiness
In Figure 14.2, we think income causes happiness. But we also think that education causes happiness, and that education also causes income. That relationship is a “backdoor path”, and failing to adjust for education in a regression could overstate the extent of the relationship, or even create a spurious relationship, between income and happiness in our analysis. That is, we may think that changes in income are causing changes in happiness, but it could be that education is changing them both. That variable, in this case, education, is called a “confounder”.
Hernán and Robins (2020, 83) discuss an interesting case where a researcher was interested in whether one person looking up at the sky makes others look up at the sky also. There was a clear relationship between the responses of both people. But it was also the case that there was noise in the sky. It was unclear whether the second person looked up because the first person looked up, or they both looked up because of the noise. When using experimental data, randomization allows us to avoid this concern, but with observational data we cannot rely on that. It is also not the case that bigger data necessarily get around this problem for us. Instead, it is important to think carefully about the situation, and DAGs can help with that.
If there are confounders, but we are still interested in causal effects, then we need to adjust for them. One way is to include them in the regression. But the validity of this requires several assumptions. In particular, Gelman and Hill (2007, 169) warn that our estimate will only correspond to the average causal effect in the sample if we include all of the confounders and have the right model. Putting the second requirement to one side, and focusing only on the first, if we do not think about and observe a confounder, then it can be difficult to adjust for it. And this is an area where both domain expertise and theory can bring a lot to an analysis.
In Figure 14.3 we again consider that income causes happiness. But, if income also causes children, and children also cause happiness, then we have a situation where it would be tricky to understand the effect of income on happiness.
Figure 14.3: Children as a mediator between income and happiness
In Figure 14.3, children is called a “mediator” and we would not adjust for it if we were interested in the effect of income on happiness. If we were to adjust for it, then some of what we are attributing to income, would be due to children.
Finally, in Figure 14.4 we have yet another similar situation, where we think that income causes happiness. But this time both income and happiness also cause exercise. For instance, if you have more money then it may be easier to exercise, but also it may be easier to exercise if you are happier.
Figure 14.4: Exercise as a collider affecting the relationship between income and happiness
In this case, exercise is called a “collider” and if we were to condition on it, then we would create a misleading relationship. Income influences exercise, but a person’s happiness also affects this. Exercise is a collider because both the independent and dependent variable of interest influence it.
It is important to be clear about this: we must create the DAG ourselves, in the same way that we must put together the model ourselves. There is nothing that will create it for us. This means that we need to think carefully about the situation. Because it is one thing to see something in the DAG and then do something about it, but it is another to not even know that it is there. McElreath (2020, 180) describes these as haunted DAGs. DAGs are helpful, but they are just a tool to help us think deeply about our situation.
When we are building models, it can be tempting to include as many independent variables as possible. DAGs show clearly why we need to be more thoughtful. For instance, if a variable is a confounder, then we would want to adjust for it, whereas if a variable was a collider then we would not. We can never know the truth, and we are informed by aspects such as theory, what we are interested in, research design, limitations of the data, or our own limitations as researchers, to name a few. Knowing the limits is as important as reporting the model. Data and models with flaws are still useful, if you acknowledge those flaws. The work of thinking about a situation is never done, and relies on others, which is why we need to make all our work as reproducible as possible.
14.3 Two common paradoxes
There are two situations where data can trick us that are so common that we will explicitly go through them. These are: 1) Simpson’s paradox, and 2) Berkson’s paradox. It is important to keep these situations in mind, and the use of DAGs can help identify them.
14.3.1 Simpson’s paradox
Simpson’s paradox occurs when we estimate some relationship for subsets of our data, but a different relationship when we consider the entire dataset (Simpson 1951). It is a particular case of the ecological fallacy, which is when we try to make claims about individuals, based on their group. For instance, it may be that there is a positive relationship between undergraduate grades and performance in graduate school in two departments when considering each department individually. But if undergraduate grades tended to be higher in one department than another while graduate school performance tended to be opposite, we may find a negative relationship between undergraduate grades and performance in graduate school. We can simulate some data to show this more clearly (Figure 14.5).
Figure 14.5: Illustration of simulated data that shows Simpson’s paradox
Simpson’s paradox is often illustrated using real-world data from University of California, Berkeley, on graduate admissions (Bickel, Hammel, and O’Connell 1975). This paper was mentioned in Chapter 4 as having one of the greatest sub-titles ever published. Hernán, Clayton, and Keiding (2011) create DAGs that further illuminate the relationship and the cause of the paradox.
More recently, as mentioned in its documentation, the “penguins” dataset from palmerpenguins(Horst, Presmanes Hill, and Gorman 2020) provides an example of Simpson’s paradox, using real-world data on the relationship between body mass and bill depth in different species of penguins (Figure 14.6). The overall negative trend occurs because Gentoo penguins tend to be heavier but with shorter bills compared to Adelie and Chinstrap penguins.
Figure 14.6: Illustration of Simpson’s paradox in a dataset of penguin bill depth compared with their body mass
14.3.2 Berkson’s paradox
Berkson’s paradox occurs when we estimate some relationship based on the dataset that we have, but because the dataset is so selected the relationship is different in a more general dataset (Berkson 1946). For instance, if we have a dataset of professional cyclists then we might find there is no relationship between their VO2 max and their chance of winning a bike race (Coyle et al. 1988; Podlogar, Leo, and Spragg 2022). But if we had a dataset of the general population then we might find a relationship between these two variables. The professional dataset has just been so selected that the relationship disappears; one cannot become a professional cyclist unless one has a good-enough VO2 max, but among professional cyclists everyone has a good-enough VO2 max. Again, we can simulate some data to show this more clearly (Figure 14.7).
set.seed(853)number_of_pros <-100number_of_public <-1000professionals <-tibble(VO2 =runif(n = number_of_pros, min =0.7, max =0.9),chance_of_winning =runif(n = number_of_pros, min =0.7, max =0.9),type ="Professionals" )general_public <-tibble(VO2 =runif(n = number_of_public, min =0.6, max =0.8),noise =rnorm(n = number_of_public, 0, sd =0.03),chance_of_winning = VO2 + noise +0.1,type ="Public" ) |>select(-noise)professionals_and_public <-rbind(professionals, general_public)professionals_and_public
professionals_and_public |>ggplot(aes(x = VO2, y = chance_of_winning)) +geom_point(aes(color = type), alpha =0.1) +geom_smooth(aes(color = type), method ="lm", formula ="y ~ x") +geom_smooth(method ="lm", formula ="y ~ x", color ="black") +labs(x ="VO2 max",y ="Chance of winning a bike race",color ="Type" ) +theme_minimal() +scale_color_brewer(palette ="Set1") +theme(legend.position ="bottom")
Figure 14.7: Illustration of simulated data that shows Berkson’s paradox
14.4 Difference in differences
The ideal situation of being able to conduct an experiment is rarely possible. Can we reasonably expect that Netflix would allow us to change prices? And even if they did once, would they let us do it again, and again, and again? Further, rarely can we explicitly create treatment and control groups. Finally, experiments can be expensive or unethical. Instead, we need to make do with what we have. Rather than our counterfactual coming to us through randomization, and hence us knowing that the two are the same but for the treatment, we try to identify groups that were similar but for the treatment, and hence any differences can be attributed to the treatment.
With observational data, sometimes there are differences between our two groups before we treat. Provided those pre-treatment differences satisfy assumptions that essentially amount to the differences being both consistent, and that we expect that consistency to continue in the absence of the treatment—the “parallel trends” assumption—then we can look to any difference in the differences as the effect of the treatment. One of the aspects of difference in differences analysis is that we can do it using relatively straight-forward methods, for instance Tang (2015). Linear regression with a binary variable is enough to get started and do a convincing job.
Consider wanting to know the effect of a new tennis racket on serve speed. One way to test this would be to measure the difference between, say, Roger Federer’s serve speed without the tennis racket and the serve speed of an enthusiastic amateur, let us call them Ville, with the tennis racket. Yes, we would find a difference, but would we know how much to attribute to the tennis racket? Another way would be to consider the difference between Ville’s serve speed without the new tennis racket and Ville’s serve speed with the new tennis racket. But what if serves were just getting faster naturally over time? Instead, we combine the two approaches to look at the difference in the differences.
We begin by measuring Federer’s serve speed and compare it to Ville’s serve speed, both without the new racket. We then measure Federer’s serve speed again, and measure Ville’s serve speed with the new racket. That difference in the differences would then be the estimate of the effect of the new racket. There are a few key questions we must ask to see if this analysis is appropriate:
Is there something else that may have affected only Ville, and not Federer that could affect Ville’s serve speed?
Is it likely that Federer and Ville have the same trajectory of serve speed improvement? This is the “parallel trends” assumption, and it dominates many discussions of difference in differences analysis.
Finally, is it likely that the variance of our serve speeds of Federer and Ville are the same?
Despite these requirements, difference in differences is a powerful approach because we do not need the treatment and control group to be the same before the treatment. We just need to have a good idea of how they differed.
14.4.1 Simulated example
To be more specific about the situation, we simulate data. We will simulate a situation in which there is initially a difference of one between the serve speeds of the different people, and then after a new tennis racket, there is a difference of six. We can use a graph to illustrate the situation (Figure 14.8).
set.seed(853)simulated_diff_in_diff <-tibble(person =rep(c(1:1000), times =2),time =c(rep(0, times =1000), rep(1, times =1000)),treatment_group =rep(sample(x =0:1,size =1000,replace =TRUE ),times =2 ) ) |>mutate(treatment_group =as.factor(treatment_group),time =as.factor(time) )simulated_diff_in_diff <- simulated_diff_in_diff |>rowwise() |>mutate(serve_speed =case_when( time ==0& treatment_group ==0~rnorm(n =1, mean =5, sd =1), time ==1& treatment_group ==0~rnorm(n =1, mean =6, sd =1), time ==0& treatment_group ==1~rnorm(n =1, mean =8, sd =1), time ==1& treatment_group ==1~rnorm(n =1, mean =14, sd =1) ) )simulated_diff_in_diff
Figure 14.8: Illustration of simulated data that shows a difference before and after getting a new tennis racket
As it is a straight-forward example, we can obtain our estimate manually, by looking at the average difference of the differences. When we do that, we find that we estimate the effect of the new tennis racket to be 5.06, which is similar to what we simulated.
average_differences <- simulated_diff_in_diff |>pivot_wider(names_from = time,values_from = serve_speed,names_prefix ="time_" ) |>mutate(difference = time_1 - time_0) |>group_by(treatment_group) |># Average difference between old racket and new racket serve speed,# within groups (pro and amateur)summarize(average_difference =mean(difference))# Difference between the average differences of each groupaverage_differences$average_difference[2] - average_differences$average_difference[1]
[1] 5.058414
And we can use linear regression to get the same result. The equation that we are interested in is: \[Y_{i,t} = \beta_0 + \beta_1\mbox{Treatment}_i + \beta_2\mbox{Time}_t + \beta_3(\mbox{Treatment} \times\mbox{Time})_{i,t} + \epsilon_{i,t}\]
While we should include the separate aspects as well, it is the estimate of the interaction that we are interested in. In this case it is \(\beta_3\). And we find that our estimated effect is 5.06 (Table 14.1).
Table 14.1: Illustration of simulated data that shows a difference before and after getting a new tennis racket
(1)
(Intercept)
4.971
[4.887, 5.054]
treatment_group1
3.035
[2.910, 3.157]
time1
1.006
[0.889, 1.125]
treatment_group1 × time1
5.057
[4.885, 5.232]
Num.Obs.
2000
R2
0.927
R2 Adj.
0.927
Log.Lik.
−2802.166
ELPD
−2806.3
ELPD s.e.
32.1
LOOIC
5612.5
LOOIC s.e.
64.2
WAIC
5612.5
RMSE
0.98
14.4.2 Assumptions
If we want to use difference in differences, then we need to satisfy the assumptions. There were three that were touched on earlier, but here we will focus on one: the “parallel trends” assumption. The parallel trends assumption haunts everything to do with difference in differences analysis because we can never prove it; we can just be convinced of it, and try to convince others.
To see why we can never prove it, consider an example in which we want to know the effect of a new stadium on a professional sports team’s wins/loses. To do this we consider two teams: the Golden State Warriors and the Toronto Raptors. The Warriors changed stadiums at the start of the 2019-20 season, while the Raptors did not, so we will consider four time periods: the 2016-17 season, 2017-18 season, 2018-19 season, and finally we will compare the performance with the one after they moved, so the 2019-20 season. The Raptors here act as our counterfactual. This means that we assume the relationship between the Warriors and the Raptors, in the absence of a new stadium, would have continued to change in a consistent way. But the fundamental problem of causal inference means that we can never know that for certain. We must present sufficient evidence to assuage any concerns that a reader may have.
There are four main threats to validity when we use difference in differences, and we need to address all of them (Cunningham 2021, 272–77):
Non-parallel trends. The treatment and control groups may be based on differences. As such it can be difficult to convincingly argue for parallel trends. In this case, maybe try to find another factor to consider in your model that may adjust for some of that. This may require difference in difference in differences (in the earlier example, we could perhaps add the San Francisco 49ers as they are in the same broad geographic area as the Warriors). Or maybe re-think the analysis to see if we can make a different control group. Adding additional earlier time periods may help but may introduce more issues, which we touch on in the third point.
Compositional differences. This is a concern when working with repeated cross-sections. What if the composition of those cross-sections change? For instance, if we are working at an app that is rapidly growing, and we want to look at the effect of some change. In our initial cross-section, we may have mostly young people, but in a subsequent cross-section, we may have more older people as the demographics of the app usage change. Hence our results may just be an age-effect, not an effect of the change that we are interested in.
Long-term effects compared with reliability. As we discussed in Chapter 8, there is a trade-off between the length of the analysis that we run. As we run the analysis for longer there is more opportunity for other factors to affect the results. There is also increased chance for someone who was not treated to be treated. But, on the other hand, it can be difficult to convincingly argue that short-term results will continue in the long-term.
Functional form dependence. This is less of an issue when the outcomes are similar, but if they are different then functional form may be responsible for some aspects of the results.
14.4.3 French newspaper prices between 1960 and 1974
In this case study we introduce Angelucci and Cagé (2019), and replicate one of the main findings.
The business model of newspapers has been challenged by the internet and many local newspapers have closed. And this issue is not new. When television was introduced, there were similar concerns. Angelucci and Cagé (2019) use the introduction of television advertising in France, announced in 1967, to examine the effect of decreased advertising revenue on newspapers. They create a dataset of French newspapers from 1960 to 1974 and then use difference in differences to examine the effect of the reduction in advertising revenues on newspapers’ content and prices. The change that they focus on is the introduction of television advertising, which they argue affected national newspapers more than local newspapers. They find that this change results in both less journalism-content in the newspapers and lower newspaper prices. Focusing on this change, and analyzing it using difference in differences, is important because it allows us to disentangle a few competing effects. For instance, did newspapers become redundant because they could no longer charge high prices for their advertisements, or because consumers preferred to get their news from the television?
We can get free access to the data that underpins Angelucci and Cagé (2019) after registration. The dataset is in the Stata data format, “.dta”, which we can read with read_dta() from haven(Wickham, Miller, and Smith 2022). The file that we are interested in is “Angelucci_Cage_AEJMicro_dataset.dta”, which is the “dta” folder.
There are 1,196 observations in the dataset and 52 variables. Angelucci and Cagé (2019) are interested in the 1960-1974 time-period which has around 100 newspapers. There are 14 national newspapers at the beginning of the period and 12 at the end. The key period is 1967, when the French government announced it would allow advertising on television. Angelucci and Cagé (2019) argue that national newspapers were affected by this chance, but local newspapers were not. The national newspapers are the treatment group and the local newspapers are the control group.
We focus just on the headline difference in differences result and construct summary statistics.
We are interested in what happened from 1967 onward, especially in terms of advertising revenue, and whether that was different for national, compared with local newspapers (Figure 14.9). We use scales to adjust the y axis (Wickham and Seidel 2022).
Figure 14.9: Revenue of French newspapers (1960-1974), by whether they were local or national
The model that we are interested in estimating is: \[\mbox{ln}(y_{n,t}) = \beta_0 + \beta_1(\mbox{National binary}\times\mbox{1967 onward binary}) + \lambda_n + \gamma_y + \epsilon.\] It is the \(\beta_1\) coefficient that we are especially interested in. We use \(\lambda_n\) as fixed effect for each newspaper, and the \(\gamma_y\) as a fixed effect for each year. We estimate the models using stan_glm().
Looking at the advertising-side variables (first two columns of Table 14.2) we find consistently negative coefficients. And looking at the advertising-side variables (Table 14.2) we again, find a negative coefficient for unit price, and a positive coefficient for subscription price.
Table 14.2: Effect of changed television advertising laws on revenue of French newspapers (1960-1974)
Ad revenue
Ad revenue over circulation
Subscription price
Year
0.05
0.04
0.05
[0.04, 0.05]
[0.04, 0.04]
[0.04, 0.05]
After change
−0.23
−0.15
−0.04
[−0.29, −0.17]
[−0.21, −0.10]
[−0.08, 0.00]
Num.Obs.
1052
1048
1044
R2
0.984
0.896
0.868
R2 Adj.
0.983
0.886
0.852
Log.Lik.
336.539
441.471
875.559
ELPD
257.4
362.3
793.5
ELPD s.e.
34.4
45.6
24.3
LOOIC
−514.8
−724.6
−1586.9
LOOIC s.e.
68.9
91.2
48.6
WAIC
−515.9
−725.5
−1588.9
RMSE
0.17
0.16
0.10
In general, we can replicate the main results of Angelucci and Cagé (2019) and find that in many cases there appears to be a difference from 1967 onward. Angelucci and Cagé (2019, 353–58) also includes an excellent example of the discussion of interpretation, external validity, and robustness that is required for difference in differences models.
14.5 Propensity score matching
Difference in differences is a powerful analysis framework. But it can be tough to identify appropriate treatment and control groups. Alexander and Ward (2018) compare migrant brothers, where one brother had most of their education in a different country, and the other brother had most of their education in the US. Given the data that are available, this match provides a reasonable treatment and control group. But other matches could have given different results, for instance friends or cousins.
We can only match based on observable variables. For instance, age-group or education. At two different times we compare smoking rates in 18-year-olds in one city with smoking rates in 18-year-olds in another city. This would be a coarse match because we know that there are many differences between 18-year-olds, even in terms of the variables that we commonly observe, say gender and education. One way to deal with this would be to create sub-groups: 18-year-old males with a high school education, etc. But then the sample sizes quickly become small. We also have the issue of how to deal with continuous variables. And is a 18-year-old really that different to a 19-year-old? Why not also compare with them?
One way to proceed is to consider a nearest neighbor approach, but there can be limited concern for uncertainty with this approach. There can also be an issue with having many variables because we end up with a high-dimension graph. This leads to propensity score matching. Here we will explain the process of propensity score matching, how it is not something that should be widely used (King and Nielsen 2019), and why that is the case.
Propensity score matching involves assigning some probability to each observation. We construct that probability based on the observation’s values for the independent variables, before treatment. That probability is our best guess at the probability of the observation being treated, regardless of whether it was treated or not. For instance, if 18-year-old males were treated but 19-year-old males were not, then, as there is not much difference between 18-year-old males and 19-year-old males in general, our assigned probability would be similar. We can then compare the outcomes of observations with similar propensity scores.
One advantage of propensity score matching is that is allows us to easily consider many independent variables at once, and it can be constructed using logistic regression. To be more specific we can simulate some data. We will pretend that we work for a large online retailer. We are going to treat some individuals with free shipping to see what happens to their average purchase.
# A tibble: 10,000 × 5
unique_person_id age city gender income
<int> <dbl> <chr> <chr> <dbl>
1 1 47.5 Calgary Female 1.72
2 2 27.8 Montreal Male 1.54
3 3 57.7 Toronto Female 3.16
4 4 43.9 Toronto Male 0.636
5 5 21.1 Toronto Female 1.43
6 6 51.1 Calgary Male 1.18
7 7 28.7 Toronto Female 1.49
8 8 37.9 Toronto Female 0.414
9 9 31.0 Calgary Male 0.384
10 10 33.5 Montreal Female 1.11
# … with 9,990 more rows
Then we need to add some probability of being treated with free shipping. We will say that it depends on our variables and that younger, higher-income, male and Toronto-based individuals make this treatment slightly more likely.
purchase_data <- purchase_data |>mutate(age_num =case_when( age <30~3, age <50~2, age <70~1,TRUE~0 ),city_num =case_when( city =="Toronto"~3, city =="Montreal"~2, city =="Calgary"~1,TRUE~0 ),gender_num =case_when( gender =="Male"~3, gender =="Female"~2, gender =="Other/decline"~1,TRUE~0 ),income_num =case_when( income >3~3, income >2~2, income >1~1,TRUE~0 ) ) |>rowwise() |>mutate(sum_num =sum(age_num, city_num, gender_num, income_num),softmax_prob =exp(sum_num) /exp(12),free_shipping =sample(x =c(0:1),size =1,replace =TRUE,prob =c(1- softmax_prob, softmax_prob) ) ) |>ungroup()purchase_data <- purchase_data |>select(-age_num,-city_num,-gender_num,-income_num,-sum_num,-softmax_prob )
Finally, we need to have some measure of a person’s average spend. We want those with free shipping to be slightly higher than those without.
# A tibble: 10,000 × 7
unique_person_id age city gender income free_shipping average_spend
<int> <dbl> <fct> <fct> <dbl> <fct> <dbl>
1 1 47.5 Calgary Female 1.72 0 41.1
2 2 27.8 Montreal Male 1.54 0 55.7
3 3 57.7 Toronto Female 3.16 0 56.5
4 4 43.9 Toronto Male 0.636 0 50.5
5 5 21.1 Toronto Female 1.43 0 44.7
6 6 51.1 Calgary Male 1.18 0 48.8
7 7 28.7 Toronto Female 1.49 0 52.8
8 8 37.9 Toronto Female 0.414 0 52.4
9 9 31.0 Calgary Male 0.384 0 47.6
10 10 33.5 Montreal Female 1.11 0 49.2
# … with 9,990 more rows
We use matchit() from MatchIt(Ho et al. 2011) to implement logistic regression and create matched groups. We then use match.data() to get the data of matches containing both all 371 people who were actually treated with free shipping and the untreated person who is considered as similar to them, based on propensity score, as possible. The result is a dataset of 742 observations.
library(MatchIt)matched_groups <-matchit( free_shipping ~ age + city + gender + income,data = purchase_data,method ="nearest",distance ="glm")matched_groups
A matchit object
- method: 1:1 nearest neighbor matching without replacement
- distance: Propensity score
- estimated with logistic regression
- number of obs.: 10000 (original), 742 (matched)
- target estimand: ATT
- covariates: age, city, gender, income
Finally, we can estimate the effect of being treated on average spend using linear regression. We are particularly interested in the coefficient associated with the treatment variable, in this case free shipping.
propensity_score_regression <-lm( average_spend ~ age + city + gender + income + free_shipping,data = matched_dataset)modelsummary(propensity_score_regression)
(1)
(Intercept)
49.567
(0.817)
age
0.007
(0.011)
cityMontreal
0.128
(0.736)
cityToronto
0.586
(0.627)
genderMale
−1.100
(0.425)
genderOther/decline
−1.999
(2.635)
income
0.019
(0.027)
free_shipping1
10.606
(0.383)
Num.Obs.
742
R2
0.517
R2 Adj.
0.513
AIC
4560.7
BIC
4602.1
Log.Lik.
−2271.326
F
112.455
RMSE
5.17
We cover propensity score matching because it is widely used. But there are many issues with propensity score matching that mean that humility is needed (King and Nielsen 2019). These include:
Unobservables. Propensity score matching cannot match on unobserved variables. This may be fine in a classroom setting, but in more realistic settings it will likely cause issues. It is very difficult to understand why individuals that appear to be so similar, would have received different treatments, unless there is something unobserved that causes the difference. As propensity score matching cannot account for these, it is difficult to know which features are actually being brought together.
Modelling. The results of propensity score matching tend to be specific to the model that is used. As there is considerable flexibility as to which model is used, this enables researchers to pick through matches to find one that suits. Additionally, because the two regression steps (the matching and the analysis) are conducted separately, there is no propagation of uncertainty.
The fundamental problem of unobservables can never be shown to be inconsequential because that would require the unobserved data. Those who want to use propensity score matching, and other matching methods, need to be able to argue convincingly that it is appropriate. McKenzie (2021) presents a few cases where this is possible, for instance, when there are capacity limits. As is the common theme of this book, such cases will require focusing, with extreme zeal, on the data and a deep understanding of the situation that produced it.
14.6 Regression discontinuity design
Regression discontinuity design (RDD) was established by Thistlethwaite and Campbell (1960) and is a popular way to get causality when there is a continuous variable with cut-offs that determine treatment. Is there a difference between a student who gets 79 per cent and a student who gets 80 per cent? Probably not much, but one may get an A-, while the other may get a B+, and seeing that on a transcript could affect who gets a job which could affect income. In this case the percentage is a “forcing variable” or “forcing variable” and the cut-off for an A- is a “threshold”. As the treatment is determined by the forcing variable we need to control for that variable. And these seemingly arbitrary cut-offs can be seen all the time. Hence, there has been a great deal of work using RDD.
There is sometimes slightly different terminology used when it comes to RDD. For instance, Cunningham (2021) refers to the forcing function as a running variable. The exact terminology that is used does not matter provided we use it consistently.
14.6.1 Simulated example
To be more specific about the situation, we simulate data. We will consider the relationship between income and grades, and simulate there to be a change if a student gets at least 80 (Figure 14.10).
library(tidyverse)set.seed(853)number_of_observation <-1000rdd_example_data <-tibble(person =c(1:number_of_observation),mark =runif(number_of_observation, min =78, max =82),income =rnorm(number_of_observation, 10, 1))## Make income more likely to be higher if they have a mark at least 80rdd_example_data <- rdd_example_data |>mutate(noise =rnorm(n = number_of_observation, mean =2, sd =1),income =if_else(mark >=80, income + noise, income) )rdd_example_data
Figure 14.10: Illustration of simulated data that shows an effect on income from getting a mark that is 80, compared with 79
We can use a binary variable with linear regression to estimate the effect of getting a mark over 80 on income. We expect the coefficient to be around two, which is what we simulated, and what we find (Table 14.3).
Table 14.3: Example of regression discontinuity with simulated data
(1)
(Intercept)
5.22
[−5.32, 15.65]
mark
0.06
[−0.07, 0.19]
mark_80_and_over
1.89
[1.58, 2.19]
Num.Obs.
1000
R2
0.417
R2 Adj.
0.415
Log.Lik.
−1591.847
ELPD
−1595.1
ELPD s.e.
25.4
LOOIC
3190.3
LOOIC s.e.
50.9
WAIC
3190.3
RMSE
1.19
There are various caveats to this estimate that we will discuss, but the essentials of RDD are here. Given an appropriate set-up, and model, an RDD can compare favorably to randomized trials (Bloom, Bell, and Reiman 2020).
We could also implement RDD using rdrobust(Calonico et al. 2021). The advantage of this approach is that many common extensions are easily available.
The first assumption is largely about being unable to manipulate the cut-off, and ensures that the cut-off has meaning. The second assumption enables us to be confident that people on either side of the threshold are similar, apart from just happening to just fall on either side of the threshold.
When we discussed randomized control trials and A/B testing in Chapter 8 the randomized assignment of the treatment meant that the control and treatment groups were the same, but for the treatment. Then we moved to difference in differences, and we assumed that there was a common trend between the treated and control groups. We allowed that the groups could be different, but that we could “difference out” their differences. Finally, we considered matching, and we said that even if the control and treatment groups seemed quite different, we were able to match, to some extent, those who were treated with a group that were like them in all ways, apart from the fact that they were not treated.
In regression discontinuity we consider a slightly different setting. The two groups are completely different in terms of the forcing variable. They are on either side of the threshold. There is no overlap at all. But we know the threshold and believe that those on either side are essentially matched. Let us consider the 2019 NBA Eastern Conference Semifinals - Toronto and Philadelphia. Game 1: Raptors win 108-95; Game 2: 76ers win 94-89; Game 3: 76ers win 116-95; Game 4: Raptors win 101-96; Game 5: Raptors win 125-89; Game 6: 76ers win 112-101; and finally, Game 7: Raptors win 92-90, because of a ball that win in after bouncing on the rim four times. Was there really that much difference between the teams?
The continuity assumption is important, but we cannot test this as it is based on a counterfactual. Instead, we need to convince people of it. Ways to do this include:
Using a test/train set-up.
Trying different specifications. We are especially concerned if results do not broadly persist with just linear or quadratic functions.
Considering different subsets of the data.
Considering different windows.
Be clear about uncertainty intervals, especially in graphs.
Discussing and assuage concerns about the possibility of omitted variables.
The threshold is also important. For instance, is there an actual shift or is there a non-linear relationship?
There are a variety of weaknesses of RDD, including:
External validity may be difficult. For instance, when we think about the A-/B+ example, it is hard to see those generalizing to also B-/C+ students.
The important responses are those that are close to the cut-off. This means that even if we have many A and B students, they do not help much. Hence, we need a lot of data or we may have concerns about our ability to support our claims (Green et al. 2009).
As the researcher, we have a lot of freedom to implement different options. This means that open science best practice becomes vital.
To this point we have considered “sharp” RDD. That is, the threshold is strict. But, in reality, often the boundary is a little less strict. For instance, consider the drinking age. There is a legal drinking age, say 18. If we looked at the number of people who had drunk, then it is likely to increase in the few years leading up to that age.
In a sharp RDD setting, if we know the value of the forcing function then we know the outcome. For instance, if a student gets a mark of 80 then we know that they got an A-, but if they got a mark of 79 then we know that they got a B+. But with fuzzy RDD it is only known with some probability. We can say that a Canadian 19-year-old is more likely to have drunk alcohol than a Canadian 18-year-old, but the number of Canadian 18-year-olds who have drunk alcohol is not zero.
It may be possible to deal with fuzzy RDD settings with appropriate choice of model or data. It may also be possible to deal with them using instrumental variables.
We want as “sharp” an effect as possible, but if the thresholds are known, then they will be gamed. For instance, there is a lot of evidence that people run for certain marathon times, and we know that people aim for certain grades. Similarly, from the other side, it is a lot easier for an instructor to just give out As than it is to have to justify Bs. One way to look at this is to consider how “balanced” the sample is on either side of the threshold. We can do this using histograms with appropriate bins. For instance, think of the age-heaping that we found in the cleaned Kenyan census data in Chapter 7.
Another key factor for RDD is the possible effect of the decision around the choice of model. For instance, Figure 14.11 illustrates the difference between linear (Figure 14.11 (a)) and polynomial (Figure 14.11 (b)).
some_data <-tibble(outcome =rnorm(n =100, mean =1, sd =1),running_variable =c(1:100),location ="before" )some_more_data <-tibble(outcome =rnorm(n =100, mean =2, sd =1),running_variable =c(101:200),location ="after" )both <-rbind(some_data, some_more_data)both |>ggplot(aes(x = running_variable, y = outcome, color = location)) +geom_point(alpha =0.5) +geom_smooth(formula = y ~ x, method ="lm") +theme_minimal() +theme(legend.position ="bottom")both |>ggplot(aes(x = running_variable, y = outcome, color = location)) +geom_point(alpha =0.5) +geom_smooth(formula = y ~poly(x, 3), method ="lm") +theme_minimal() +theme(legend.position ="bottom")
(a) Linear
(b) Polynomial
Figure 14.11: Comparing the result of considering the same situation with different functions
The result is that our estimate of the difference in outcome is dependent on the choice of model. We see this issue occur often in RDD (Gelman 2019) and it is especially recommended that higher order polynomials not be used, and instead the choice of models be either linear, quadratic, or some other smooth function (Gelman and Imbens 2019).
RDD is a popular approach, but meta-analysis suggests that standard errors are often inappropriately small and this could result in spurious results (Stommes, Aronow, and Sävje 2021). If you use RDD it is critical that you discuss the possibility of much wider standard errors than are reported by software packages, and what effect this would have on your conclusions.
14.6.3 Alcohol and crime in California
There are many opportunities to use regression discontinuity design. For instance, we often see it used in elections where one candidate barely wins. In US House elections between 1942 and 2008 Caughey and Sekhon (2011) showed that there is actually considerable difference between bare winners and bare losers, and highlight that one of the advantages of regression discontinuity is the fact that the assumptions can be tested. Another common use is when there is a somewhat arbitrary cut-off. For instance, in much of the USA the legal drinking age is 21. Carpenter and Dobkin (2015) consider the possible effect of alcohol on crime by comparing arrests and other records of those who are either side of 21 in California. They find those who are slightly over 21 are slightly more likely to be arrested than those slightly under 21. We will revisit Carpenter and Dobkin (2015) in the context of crime in California.
We can obtain their replication data (Carpenter and Dobkin 2014) from here. Carpenter and Dobkin (2015) consider a large number of variables and construct a rate, and average this rate over a fortnight, but for simplicity, we will just consider numbers for a few variables: assault, aggravated assault, DUI, and traffic violations (Figure 14.12).
library(haven)library(tidyverse)carpenter_dobkin <-read_dta("P01 Age Profile of Arrest Rates 1979-2006.dta" )
Sharp RD estimates using local polynomial regression.
Number of Obs. 1459
BW type Manual
Kernel Triangular
VCE method NN
Number of Obs. 729 730
Eff. Number of Obs. 729 730
Order est. (p) 1 1
Order bias (q) 2 2
BW est. (h) 2.000 2.000
BW bias (b) 2.000 2.000
rho (h/b) 1.000 1.000
Unique Obs. 729 730
=============================================================================
Method Coef. Std. Err. z P>|z| [ 95% C.I. ]
=============================================================================
Conventional 14.126 1.918 7.364 0.000 [10.366 , 17.886]
Bias-Corrected 16.708 1.918 8.709 0.000 [12.948 , 20.468]
Robust 16.708 2.879 5.804 0.000 [11.066 , 22.350]
=============================================================================
14.7 Instrumental variables
Instrumental variables (IV) is an approach that can be handy when we have some type of treatment and control going on, but we have a lot of correlation with other variables and we possibly do not have a variable that actually measures what we are interested in. Adjusting for observables will not be enough to create a good estimate. Instead we find some variable—the eponymous instrumental variable—that is:
correlated with the treatment variable, but
not correlated with the outcome.
This solves our problem because the only way the instrumental variable can have an effect is through the treatment variable, and so we can adjust our understanding of the effect of the treatment variable appropriately. The trade-off is that instrumental variables must satisfy a bunch of different assumptions, and that, frankly, they are difficult to identify ex ante. Nonetheless, when we are able to use them, they are a powerful tool for speaking about causality.
The canonical instrumental variables example is smoking. These days we know that smoking causes cancer. But because smoking is correlated with a lot of other variables, for instance, education, it could be that it was actually education that causes cancer. RCTs may be possible, but they are likely to be troublesome in terms of speed and ethics, and so instead we look for some other variable that is correlated with smoking, but not, in and of itself, with lung cancer. In this case, we look to tax rates, and other policy responses, on cigarettes. As the tax rates on cigarettes are correlated with the number of cigarettes that are smoked, but not correlated with lung cancer, other than through their impact on cigarette smoking, through them we can assess the effect of cigarettes smoked on lung cancer.
To implement instrumental variables we first regress tax rates on cigarette smoking to get some coefficient on the instrumental variable, and then (in a separate regression) regress tax rates on lung cancer to again, get some coefficient on the instrumental variable. Our estimate is then the ratio of these coefficients, which is described as a “Wald estimate” (Gelman and Hill 2007, 219).
Sometimes instrumental variables are used in the context of random allocation of treatment, such as the Oregon Health Insurance Experiment introduced in Chapter 8. Recall the issue was that a lottery was used to select individuals who were allocated to apply for health insurance, but there was nothing forcing them to do this. Our approach would then be to consider the relationship between being selected and taking up health insurance, and then between various health outcomes and taking up insurance. Our instrumental variable estimate, which would be the ratio, would estimate only those that took up health insurance because they were selected.
Following the language of (Gelman and Hill 2007, 216) when we use instrumental variables we make a variety of assumptions including:
Ignorability of the instrument.
Correlation between the instrumental variable and the treatment variable.
Monotonicity.
Exclusion restriction.
As an aside, the history of instrumental variables is intriguing, and Stock and Trebbi (2003), via Cunningham (2021), provide a brief overview. The method was first published in Wright (1928). This is a book about the effect of tariffs on animal and vegetable oil. Why might instrumental variables be important in a book about tariffs on animal and vegetable oil? The fundamental problem is that the effect of tariffs depends on both supply and demand. But we only know prices and quantities, so we do not know what is driving the effect. We can use instrumental variables to pin down causality. The intriguing aspect is that the instrumental variables discussion is only in “Appendix B” of that book. It would seem odd to relegate a major statistical break-through to an appendix. Further, Philip G. Wright, the book’s author, had a son Sewall Wright, who had considerable expertise in statistics and the specific method used in “Appendix B”. Hence the mystery of “Appendix B”: did Philip or Sewall write it? Cunningham (2021), Stock and Trebbi (2003), and Angrist and Krueger (2001), all go into more detail, but on balance feel that it is likely that Philip authored the work.
14.7.1 Simulated example
Let us generate some data. We will explore a simulation related to the canonical example of health status, smoking, and tax rates. We are looking to explain how healthy someone is based on the amount they smoke, via the tax rate on smoking. We are going to generate different tax rates by provinces. My understanding is that the tax rate on cigarettes is now pretty much the same in each of the provinces, but that this is fairly recent. We will pretend that Alberta had a low tax, and Nova Scotia had a high tax.
As a reminder, we are simulating data for illustrative purposes, so we need to impose the answer that we want. When you actually use instrumental variables you will be reversing the process.
Now we need to relate the number of cigarettes that someone smoked to their health. We will model health status as a draw from the normal distribution, with either a high or low mean depending on whether the person smokes.
iv_example_data <- iv_example_data |>mutate(health =if_else( smoker ==0,rnorm(n =n(), mean =1, sd =1),rnorm(n =n(), mean =0, sd =1) ))## Health to be one SD higher for people who do not or barely smoke.
Now we need a relationship between cigarettes and the province (because in this illustration, the provinces have different tax rates).
# A tibble: 3 × 2
coefficient value
<chr> <dbl>
1 health ~ tax 1.10
2 smoker ~ tax -1.29
3 ratio -0.855
By understanding the effect of tax rates on both smoking and health, we find that if you smoke then your health is likely to be worse than if you do not smoke.
Equivalently, we can think of instrumental variables in a two-stage regression context.
first_stage <-lm(smoker ~ tax, data = iv_example_data)health_hat <- first_stage$fitted.valuessecond_stage <-lm(health ~ health_hat, data = iv_example_data)modelsummary(second_stage)
(1)
(Intercept)
0.916
(0.045)
health_hat
−0.855
(0.089)
Num.Obs.
10000
R2
0.009
R2 Adj.
0.009
AIC
30498.4
BIC
30520.1
Log.Lik.
−15246.211
F
92.159
RMSE
1.11
We can use iv_robust() from estimatr(Blair et al. 2021) to estimate IV. One nice reason for doing this is that it can help to keep everything organized and adjust the standard errors.
library(estimatr)iv_robust(health ~ smoker | tax, data = iv_example_data) |>modelsummary()
(1)
(Intercept)
0.916
(0.041)
smoker
−0.855
(0.080)
Num.Obs.
10000
R2
0.197
R2 Adj.
0.197
AIC
28395.1
BIC
28416.7
RMSE
1.00
14.7.2 Assumptions
The set-up of instrumental variables is described in (Figure 14.13), which shows education as a confounder between income and happiness. A tax rebate likely only affects income, not education, and could be used as an instrumental variable.
Figure 14.13: Education as a confounder for the relationship between income and happiness with tax rebate as an instrumental variable
As discussed earlier, there are a variety of assumptions that are made when using instrumental variables. The two most important are:
Exclusion Restriction. This assumption is that the instrumental variable only affects the dependent variable through the independent variable of interest.
Relevance. There must actually be a relationship between the instrumental variable and the independent variable.
There is typically a trade-off between these two. There are plenty of variables that satisfy one, precisely because they do not satisfy the other. Cunningham (2021, 211) describes how one test of a good instrument is if people are initially confused before you explain it to them, only to think it obvious in hindsight.
Relevance can be tested using regression and other tests for correlation. The exclusion restriction cannot be tested. We need to present evidence and convincing arguments. The difficult aspect is that the instrument needs to seem irrelevant because that is the implication of the exclusion restriction (Cunningham 2021, 225).
Instrumental variables is a useful approach because one can obtain causal estimates even without explicit randomization. Finding instrumental variables used to be a bit of a white whale, especially in academia. But there has been increased use of IV approaches downstream of A/B tests (Taddy 2019, 162).
For a long time, the canonical instrumental variable was rainfall, or more generally, the weather. However, the issue is that if the instrumental variable is correlated with other, potentially unobserved, variables, then they could be correlated with the variable of interest. This is a similar criticism to that above of propensity score matching. Mellon (2022) found a large number of variables have been linked to weather in instrumental variable papers. It would seem that the likelihood of incorrectly estimated effects in some of them is quite high.
When considering an instrumental variable approach, it is important to spend considerable amounts of time on both of these assumptions. Mellon (2022) shows that we are especially concerned that this particular tax rebate only affects income and no other variable, which could itself be linked with our variables of interest. Approaches based on instrumental variables provide extensive freedom for the researcher, and Brodeur, Cook, and Heyes (2020) find they are more associated with p-hacking and selection reporting compared with RCTs and RDD. As with multiple-imputation, and propensity score matching, we recommend caution when using IV, and that it is never blindly turned to. Indeed, Betz, Cook, and Hollenbach (2018) go further and say that spatial instruments are rarely valid.
14.8 Exercises
Scales
(Plan) Consider the following scenario: Two children will both look when an ambulance passes, but only the older one will look if a street car passes, and only the younger one will look when a bike passes. Please sketch out what that dataset could look like and then sketch a graph that you could build to show all observations.
(Simulate) Please further consider the scenario described and simulate the situation. Please include at least ten tests based on the simulated data.
(Acquire) Please describe a possible source of such a dataset.
(Explore) Please use ggplot2 to build the graph that you sketched.
(Communicate) Please write two paragraphs about what you did.
Questions
For three months Sharla Gelfand shared two functions each day: one that was new to them and another that they already knew and loved. Please go the “Two Functions Most Days” GitHub repo, and find a package that they mention that you have never used. Find the relevant website for the package, and then in a paragraph or two, describe what the package does and a context in which it could be useful to you.
Please again, go to Sharla’s “Two Functions Most Days” GitHub repo, and find a function that they mention that you have never used. Please look at the help file for that function, and then detail the arguments of the function, and a context in which it could be useful to you.
What is propensity score matching? If you were matching people, then what are some of the features that you would like to match on? What sort of ethical questions does collecting and storing such information raise for you?
Putting the ethical issues to one side, following King and Nielsen (2019), in at least two paragraphs, please describe some of the statistical concerns with propensity score matching.
What is the key assumption when using difference in differences?
Please read the fascinating article in The Markup about car insurance algorithms: https://themarkup.org/allstates-algorithm/2020/02/25/car-insurance-suckers-list. Please read the article and tell me what you think. You may wish to focus on ethical, legal, social, statistical, or other, aspects.
Please go to the GitHub page related to the fascinating article in The Markup about car insurance algorithms: https://github.com/the-markup/investigation-allstates-algorithm. What is great about their work? What could be improved?
What are the fundamental features of regression discontinuity design?
What are the conditions that are needed in order for regression discontinuity design to be able to be used?
Can you think of a situation in your own life where regression discontinuity design may be useful?
What are some threats to the validity of regression discontinuity design estimates?
What is an instrumental variable?
What are some circumstances in which instrumental variables might be useful?
What conditions must instrumental variables satisfy?
Who were some of the early instrumental variable authors?
Can you please think of and explain an application of instrumental variables in your own life?
What is the key assumption in difference in differences
Parallel trends.
Heteroscedasticity.
If you are using regression discontinuity, whare are some aspects to be aware of and think hard about (select all that apply)?
Is the cut-off free of manipulation?
Is the forcing function continuous?
To what extent is the functional form driving the estimate?
Would different fitted lines affect the results?
What is the main reason that Oostrom (2022) finds that the outcome of an RCT can depend on who is funding it (pick one)?
Publication bias
Explicit manipulation
Specialization
Larger number of arms
What is the key coefficient of interest in Angelucci and Cagé (2019) (pick one)?
\(\beta_0\)
\(\beta_1\)
\(\lambda\)
\(\gamma\)
The instrumental variable is (please pick all that apply):
Correlated with the treatment variable.
Not correlated with the outcome.
Heteroskedastic.
Who are the two candidates to have invented instrumental variables?
Sewall Wright
Philip G. Wright
Sewall Cunningham
Philip G. Cunningham
What are the two main assumptions of instrumental variables?
Exclusion Restriction.
Relevance.
Ignorability.
Randomization.
According to Meng (2021) “Data science can persuade via…” (pick all that apply):
the careful establishment of evidence from fair-minded and high-quality data collection
processing and analysis
the honest interpretation and communication of findings
large sample sizes
According to Riederer (2021) if I have “disjoint treated and untreated groups partitioned by a sharp cut-off” then which method should I use to measure the local treatment effect at the juncture between groups (pick one)?
regression discontinuity
matching
difference in differences
event study methods
According to Riederer (2021) (pick all that apply):
data management
domain knowledge
probabilistic reasoning
data science
Consider an Australian 30-39 year old male living in Toronto with two children and a PhD. Which of the following do you think they would match most closely with and why (please explain in a paragraph or two)?
An Australian 30-39 year old male living in Toronto with one child and a bachelors degree
A Canadian 30-39 year old male living in Toronto with one child and a PhD
An Australian 30-39 year old male living in Ottawa with one child and a PhD
A Canadian 18-29 year old male living in Toronto with one child and a PhD
What is a DAG (in your own words please)?
What is a confounder (please select one answer)?
A variable, z, that causes both x and y, where x also causes y.
A variable, z, that is caused by both x and y, where x also causes y.
A variable, z, that causes y and is caused by x, where x also causes y.
What is a mediator (please select one answer)?
A variable, z, that causes y and is caused by x, where x also causes y.
A variable, z, that causes both x and y, where x also causes y.
A variable, z, that is caused by both x and y, where x also causes y.
What is a collider (please select one answer)?
A variable, z, that causes both x and y, where x also causes y.
A variable, z, that causes y and is caused by x, where x also causes y.
A variable, z, that is caused by both x and y, where x also causes y.
Please talk through a brief example of when you may want to be very careful about checking for Simpson’s paradox.
Please talk through a brief example of when you may want to be very careful about checking for Berkson’s paradox.
Kahneman, Sibony, and Sunstein (2021) say ‘… while correlation does not imply causation, causation does imply correlation. Where there is a causal link, we should find a correlation’. With reference to Cunningham (2021, chap. 1), are they right or wrong, and why?
Please redo the French newspaper example, but for two variables on the advertising side: “ads_p4_cst”, and “ads_s”, and for two variables on the consumer side: “qtotal” and “qs_s”.
Tutorial
You are interested in the characteristics of people’s friendship groups and how those characteristics relate to individual-level outcomes, particularly economic measures.
You have access to individual-level data from a social media website, which contains information about social interactions (comments on posts, tags, etc) on the website, as well as a wide variety of individual-level characteristics.
While the social media website is very popular, not everyone in the population you are interested in has an account, and not everyone that has an account is active on the website. Given you are interested in economic measures, what are some possible issues with using these data to make inferences about the broader population?
The data do not contain information on individual-level income. But for around 20 per cent of the sample you have information on the “census block” of the individual. By way of background, a census block contains no more than 3,000 individuals. The median income of each census block is known. As such, you decide to estimate individual level income as follows:
Regress the median income of each census block on a series of individual level characteristics (such as age, education, marital status, gender, …).
Use these estimates to predict the income of individuals that do not have location information. Briefly discuss the advantages and disadvantages of this approach, particularly in how it could affect the study of income characteristics of friendship groups. Ensure that you address the ecological fallacy.
Understandably, the social media website will not allow the unfettered distribution of individual-level data. What are some ways in which you might nonetheless enhance the reproducibility of your work?
This should take at least two pages.
Alexander, Rohan, and Zachary Ward. 2018. “Age at Arrival and Assimilation During the Age of Mass Migration.”The Journal of Economic History 78 (3): 904–37. https://doi.org/10.1017/S0022050718000335.
Angelucci, Charles, and Julia Cagé. 2019. “Newspapers in Times of Low Advertising Revenues.”American Economic Journal: Microeconomics 11 (3): 319–64. https://doi.org/10.1257/mic.20170306.
Angrist, Joshua, and Alan Krueger. 2001. “Instrumental Variables and the Search for Identification: From Supply and Demand to Natural Experiments.”Journal of Economic Perspectives 15 (4): 69–85. https://doi.org/10.1257/jep.15.4.69.
Arel-Bundock, Vincent. 2021. modelsummary: Summary Tables and Plots for Statistical Models and Data: Beautiful, Customizable, and Publication-Ready. https://CRAN.R-project.org/package=modelsummary.
Berkson, Joseph. 1946. “Limitations of the Application of Fourfold Table Analysis to Hospital Data.”Biometrics Bulletin 2 (3): 47–53. https://doi.org/10.2307/3002000.
Betz, Timm, Scott Cook, and Florian Hollenbach. 2018. “On the Use and Abuse of Spatial Instruments.”Political Analysis 26 (4): 474–79. https://doi.org/10.1017/pan.2018.10.
Bickel, Peter, Eugene Hammel, and William O’Connell. 1975. “Sex Bias in Graduate Admissions: Data from Berkeley: Measuring Bias Is Harder Than Is Usually Assumed, and the Evidence Is Sometimes Contrary to Expectation.”Science 187 (4175): 398–404. https://doi.org/10.1126/science.187.4175.398.
Blair, Graeme, Jasper Cooper, Alexander Coppock, Macartan Humphreys, and Luke Sonnet. 2021. estimatr: Fast Estimators for Design-Based Inference. https://CRAN.R-project.org/package=estimatr.
Bloom, Howard, Andrew Bell, and Kayla Reiman. 2020. “Using Data from Randomized Trials to Assess the Likely Generalizability of Educational Treatment-Effect Estimates from Regression Discontinuity Designs.”Journal of Research on Educational Effectiveness 13 (3): 488–517. https://doi.org/10.1080/19345747.2019.1634169.
Brodeur, Abel, Nikolai Cook, and Anthony Heyes. 2020. “Methods Matter: p-Hacking and Publication Bias in Causal Analysis in Economics.”American Economic Review 110 (11): 3634–60. https://doi.org/10.1257/aer.20190687.
Calonico, Sebastian, Matias Cattaneo, Max Farrell, and Rocio Titiunik. 2021. rdrobust: Robust Data-Driven Statistical Inference in Regression-Discontinuity Designs. https://CRAN.R-project.org/package=rdrobust.
Carpenter, Christopher, and Carlos Dobkin. 2014. “Replication data for: The Minimum Legal Drinking Age and Crime.”https://doi.org/10.7910/DVN/27070.
———. 2015. “The Minimum Legal Drinking Age and Crime.”The Review of Economics and Statistics 97 (2): 521–24. https://doi.org/10.1162/REST_a_00489.
Caughey, Devin, and Jasjeet Sekhon. 2011. “Elections and the Regression Discontinuity Design: Lessons from Close U.S. House Races, 1942–2008.”Political Analysis 19 (4): 385–408. https://doi.org/10.1093/pan/mpr032.
Coyle, Edward, Andrew Coggan, Mari Hopper, and Thomas Walters. 1988. “Determinants of endurance in well-trained cyclists.”Journal of Applied Physiology 64 (6): 2622–30. https://doi.org/10.1152/jappl.1988.64.6.2622.
Dagan, Noa, Noam Barda, Eldad Kepten, Oren Miron, Shay Perchik, Mark Katz, Miguel Hernán, Marc Lipsitch, Ben Reis, and Ran Balicer. 2021. “BNT162b2 mRNA Covid-19 Vaccine in a Nationwide Mass Vaccination Setting.”New England Journal of Medicine 384 (15): 1412–23. https://doi.org/10.1056/NEJMoa2101765.
Gelman, Andrew, and Jennifer Hill. 2007. Data Analysis Using Regression and Multilevel/Hierarchical Models. Cambridge University Press.
Gelman, Andrew, and Guido Imbens. 2019. “Why High-Order Polynomials Should Not Be Used in Regression Discontinuity Designs.”Journal of Business & Economic Statistics 37 (3): 447–56. https://doi.org/10.1080/07350015.2017.1366909.
Green, Donald, Terence Leong, Holger Kern, Alan Gerber, and Christopher Larimer. 2009. “Testing the Accuracy of Regression Discontinuity Analysis Using Experimental Benchmarks.”Political Analysis 17 (4): 400–417. https://doi.org/10.1093/pan/mpp018.
Hernán, Miguel, David Clayton, and Niels Keiding. 2011. “The Simpson’s Paradox Unraveled.”International Journal of Epidemiology 40 (3): 780–85. https://doi.org/10.1093/ije/dyr041.
Ho, Daniel, Kosuke Imai, Gary King, and Elizabeth Stuart. 2011. “MatchIt: Nonparametric Preprocessing for Parametric Causal Inference.”Journal of Statistical Software 42 (8): 1–28. https://doi.org/10.18637/jss.v042.i08.
Horst, Allison Marie, Alison Presmanes Hill, and Kristen Gorman. 2020. palmerpenguins: Palmer Archipelago (Antarctica) penguin data. https://doi.org/10.5281/zenodo.3960218.
Huntington-Klein, Nick. 2021. The Effect: An Introduction to Research Design and Causality. 1st ed. Chapman & Hall. https://theeffectbook.net.
Kahneman, Daniel, Olivier Sibony, and Cass Sunstein. 2021. Noise: A Flaw in Human Judgment. William Collins.
King, Gary, and Richard Nielsen. 2019. “Why Propensity Scores Should Not Be Used for Matching.”Political Analysis 27 (4): 435–54. https://doi.org/10.1017/pan.2019.11.
McElreath, Richard. 2020. Statistical Rethinking: A Bayesian Course with Examples in R and Stan. 2nd ed. Chapman; Hall/CRC.
Mellon, Jonathan. 2022. “Rain, Rain, Go Away: 192 Potential Exclusion-Restriction Violations for Studies Using Weather as an Instrumental Variable.” SocArXiv. https://doi.org/10.31235/osf.io/9qj4f.
Podlogar, Tim, Peter Leo, and James Spragg. 2022. “Using VO2max as a marker of training status in athletes—Can we do better?”Journal of Applied Physiology 133 (6): 144–47. https://doi.org/10.1152/japplphysiol.00723.2021.
R Core Team. 2022. R: A Language and Environment for Statistical Computing. Vienna, Austria: R Foundation for Statistical Computing. https://www.R-project.org/.
Sekhon, Jasjeet, and Rocío Titiunik. 2017. “Understanding Regression Discontinuity Designs as Observational Studies.”Observational Studies 3 (2): 174–82. https://doi.org/10.1353/obs.2017.0005.
Simpson, Edward. 1951. “The Interpretation of Interaction in Contingency Tables.”Journal of the Royal Statistical Society: Series B (Methodological) 13 (2): 238–41. https://doi.org/10.1111/j.2517-6161.1951.tb00088.x.
Stock, James, and Francesco Trebbi. 2003. “Retrospectives: Who Invented Instrumental Variable Regression?”Journal of Economic Perspectives 17 (3): 177–94. https://doi.org/10.1257/089533003769204416.
Stommes, Drew, P. M. Aronow, and Fredrik Sävje. 2021. “On the Reliability of Published Findings Using the Regression Discontinuity Design in Political Science.” arXiv. https://doi.org/10.48550/ARXIV.2109.14526.
Taddy, Matt. 2019. Business Data Science. McGraw Hill.
Tang, John. 2015. “Pollution Havens and the Trade in Toxic Chemicals: Evidence from u.s. Trade Flows.”Ecological Economics 112 (April): 150–60. https://doi.org/10.1016/j.ecolecon.2015.02.022.
Thistlethwaite, Donald, and Donald Campbell. 1960. “Regression-Discontinuity Analysis: An Alternative to the Ex Post Facto Experiment.”Journal of Educational Psychology 51 (6): 309–17. https://doi.org/10.1037/h0044319.