Multiple regression is no oracle, but only a golem. It is logical, but the relationships it describes are conditional associations, not causal influences. Therefore additional information, from outside the model, is needed to make sense of it. This chapter presented introductory examples of some common frustrations: multicollinearity, post-treatment bias, and collider bias. Solutions to these frustrations can be organized under a coherent framework in which hypothetical causal relations among variables are analyzed to cope with confounding. In all cases, causal models exist outside the statistical model and can be difficult to test. However, it is possible to reach valid causal inferences in the absence of experiments. This is good news, because we often cannot perform experiments, both for practical and ethical reasons.
Place each answer inside the code chunk (grey box). The code chunks should contain a text response or a code that completes/answers the question or activity requested. Make sure to include plots if the question requests them. Problems are labeled Easy (E), Medium (M), and Hard(H).
Finally, upon completion, name your final output .html file as: YourName_ANLY505-Year-Semester.html and publish the assignment to your R Pubs account and submit the link to Canvas. Each question is worth 5 points.
6E1. List three mechanisms by which multiple regression can produce false inferences about causal effects.
# Multicollinearity, Post-treatment bias, and Collider Bias
6E2. For one of the mechanisms in the previous problem, provide an example of your choice, perhaps from your own research.
# Multicollinearity
# Suppose we found that in our samples age and weight is highly correlated, then when we try to create a model to explain height, we should only put one of them in the model rather than both of them.
6E3. List the four elemental confounds. Can you explain the conditional dependencies of each?
# 1. The fork
# X <-- Z --> Y, where X ⊥ Y | Z
# 2. The Pipe,
# X --> Z --> Y, where X ⊥ Y | Z
# 3. The Collider,
# X --> Z <-- Y, where X /⊥ Y|Z
# 4. The Descendant,
# X --> Z <-- Y
# |
# v
# D
# conditioning on a D is like conditioning on Z, but weaker.
6E4. How is a biased sample like conditioning on a collider? Think of the example at the open of the chapter.
# The collider means the two variables have relationship only when the third variable is added in. The example at the open of the chapter is the relationship between trustworthiness and and newsworthiness.At first, there is no relationship between them when the populations is all the articles, but if we only look at the published article then you can find the negative relationships.
6M1. Modify the DAG on page 186 to include the variable V, an unobserved cause of C and Y: C ← V → Y. Reanalyze the DAG. Draw the DAG. How many paths connect X to Y? Which must be closed? Which variables should you condition on now?
# There are 4 paths to connect X to Y,
# 1. X <-- U <-- A --> C --> Y
# 2. X <-- U <-- A --> C <-- V --> Y
# 3. X <-- U --> B <-- C --> Y
# 4. X <-- U --> B <-- C <-- V --> Y
#
# Since B is a collider, path 3. and 4. must be closed.
# We need to condition on A now, since after including V, C is a collider. If we condition on C, then the path through V will be opened.
6M2. Sometimes, in order to avoid multicollinearity, people inspect pairwise correlations among predictors before including them in a model. This is a bad procedure, because what matters is the conditional association, not the association before the variables are included in the model. To highlight this, consider the DAG X → Z → Y. Simulate data from this DAG so that the correlation between X and Z is very large. Then include both in a model prediction Y. Do you observe any multicollinearity? Why or why not? What is different from the legs example in the chapter?
library(dplyr)
set.seed(1234)
n = 100
x = rnorm(n)
z = rnorm(n, mean = x, sd = 0.4)
y = rnorm(n, mean = z)
cor(x, z)
## [1] 0.923536
library(rethinking)
df <- data.frame(x, y, z)
pairs(df)
set.seed(123)
m1 <-quap(
alist(
y ~ dnorm(mu, sigma),
mu<- a + bx*x + bz*z,
a ~ dnorm(0, 10),
bx ~ dnorm(0,20),
bz ~ dnorm(0, 30),
sigma ~ dexp(1)
), data=df)
precis(m1)
## mean sd 5.5% 94.5%
## a 0.1635695 0.09554705 0.01086683 0.3162721
## bx -0.1402002 0.24611190 -0.53353451 0.2531342
## bz 1.2207136 0.22969142 0.85362230 1.5878048
## sigma 0.9433693 0.06623866 0.83750715 1.0492315
# From the output, we can see that the contribution of x is hidden (since the confidence interval of bx include zero) which makes sense because z is a mediator. The difference between this case and the legs example is in legs example, left and right legs are not causing each other and they both are the independent variables but in this case X causes Z.