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.
#Three mechanisms by which multiple regression can produce false inferences about causal effects are collider bias, post-treatment bias, and multicollinearity.
6E2. For one of the mechanisms in the previous problem, provide an example of your choice, perhaps from your own research.
#Let's consider a an individual's anxiety. We could consider data of age, gender, salary, education, marital status. There is a possibility of multicollinearity being a concern
6E3. List the four elemental confounds. Can you explain the conditional dependencies of each?
# Showing 4 elemental compounds
# Fork: X<-Z->Y. X and Y are independent, conditional on Z.
# Pipe: X->Z->Y. X and Y are independent, conditional on Z.
# Collider: X->Z<-Y. we see no association between X and Y unless condition on Z. Conditioning on Z, information flows between X and Y.
# Descendent: Condition on a descendent of Z in the pipe.
6E4. How is a biased sample like conditioning on a collider? Think of the example at the open of the chapter.
#Let's take the case of scientific papers. A collider confound would exist if the basis of evidence is news examples. But the statistical association is not exactly the cause of them.
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?
# We can consider four paths from X to Y:
# X ← U ← A → C → Y
# X ← U ← A → C → V → Y
# X ← U → B ← C → Y
# X ← U → B ← C → V → Y
# We can only use one path: X ← U → B ← C → V → Y since we need to close the path
# Therefore, first condition on A to close path:X ← U ← A → C → Y
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<- 500
b_xz<- 0.9
b_zy<- 0.7
x<- rnorm(n)
z<- rnorm(n,x*b_xz)
y<- rnorm(n,z*b_zy)
d <- data.frame(x,y,z)
cor(d)
## x y z
## x 1.0000000 0.4758963 0.6872909
## y 0.4758963 1.0000000 0.6492000
## z 0.6872909 0.6492000 1.0000000
mm<- quap( alist(y ~ dnorm( mu , sigma ),
mu <- a + b_xz*x + b_zy*z,
a ~ dnorm( 0 , 100 ),
c(b_xz,b_zy) ~ dnorm( 0 , 100 ),
sigma ~ dexp( 1 ) ),
data=d )
precis(mm)
## mean sd 5.5% 94.5%
## a -0.04226966 0.04563155 -0.11519769 0.03065837
## b_xz 0.07677345 0.06369812 -0.02502844 0.17857535
## b_zy 0.62647721 0.04793609 0.54986609 0.70308834
## sigma 1.01943507 0.03218808 0.96799230 1.07087785
# We notice that there is, in fact, multicolinearity.