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.
# collider bias
# Multicollinearity
# Post-Treatment bias
6E2. For one of the mechanisms in the previous problem, provide an example of your choice, perhaps from your own research.
# Multicollinearity
# For example, a research wants to build a model to estimate individual's happiness, using data related to their education.If both income and education are put into this model, there will be Multicollinearty problem. Since generally higher education will result in higher income.
6E3. List the four elemental confounds. Can you explain the conditional dependencies of each?
# The Descendant: X → Z ← Y, Z → D. A descendant D is a variable that is influenced by another variable Z. Controlling for D will also control Z to a lesser extent.
# The Collider: X → Z ← Y. There is no association between X and Y unless you have Z. Conditioning on Z, the collider variable, will open the path. If the route has been unlocked, the knowledge flows between X and Y.
# The pipe: X → Z → Y. Treatment X causes fungus Z, which impacts development Y. When we're conditioning on Z today, we 're still blocking the route from X to Y.
# The fork: X ← Z → Y. Z is a common trigger of X and Y in a fork, creating a connection between them. If we have Z, so knowing X doesn't tell us much about Y. X and Y are separate, relative to Z.
6E4. How is a biased sample like conditioning on a collider? Think of the example at the open of the chapter.
# For Example, the consumption of pizzas and the consumption of burgers will both allow one rise in weight, so there is no connection between the intake of pizzas and burgers, as weight gain is added here, there must be a relationship between the intake of pizzas and burgers. Then gain weight will be a collider.
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?
library(dagitty)
dag <- dagitty( "dag {
U [unobserved]
V [unobserved]
X -> Y
X <- U <- A -> C -> Y
U -> B <- C
C <- V -> Y
}")
adjustmentSets( dag , exposure="X" , outcome="Y" )
## { A }
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?
N <- 100
set.seed(909)
# correlation coefficient
rho1 <- 0.90
rho2 <- 0.4
x <- rnorm(N,10,2)
z <- rho1 * x + sqrt(1 - rho1^2) * rnorm( N , 0 , 1)
y <- rho2 * z + sqrt(1 - rho2^2) * rnorm( N , 0 , 1)
d <- data.frame(x, y, z)
cor(d)
## x y z
## x 1.0000000 0.6738149 0.9834520
## y 0.6738149 1.0000000 0.6897307
## z 0.9834520 0.6897307 1.0000000
library(rethinking)
m <- quap( alist(
y ~ dnorm( mu , sigma ) ,
mu <- a + bl*x + br*z ,
a ~ dnorm( 1, 30 ) ,
bl ~ dnorm( 2 , 10 ) ,
br ~ dnorm( 2 , 10 ) ,
sigma ~ dexp( 1 )
), data=d)
precis(m)
## mean sd 5.5% 94.5%
## a 0.02991548 0.41262515 -0.6295392 0.6893702
## bl -0.07439705 0.21621261 -0.4199466 0.2711525
## br 0.46822583 0.22584748 0.1072779 0.8291737
## sigma 0.82626366 0.05806665 0.7334619 0.9190654