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 are mechanisms that can result in infuelcing the inference of a multiple regression.
6E2. For one of the mechanisms in the previous problem, provide an example of your choice, perhaps from your own research.
# Example of Multicollinearity:
# In a study that aims to determine what could predict weight loss, we select calories intake, amount of exercise, and average daily stress level as predictors. While running a multiple regression model for this study, there are high chances that Multicollinearity stands in the way of producing accurate prediction results, because we have included multiple measures and it will be difficult to determine which one is more important regarding their high correlation.
6E3. List the four elemental confounds. Can you explain the conditional dependencies of each?
# The Fork: Z is a commom cause of X and Y, where X and Y are independent and conditioned on Z (X <- Z -> Y )
# The Pipe: X causes Z and Z causes Y. X and Y are independent and conditioned on Z ( X -> Z -> Y)
# The Collider: X causes Z and Y also causes Z. Conditioning on Z creates makes X and Y dependent of each other (X -> Z <- Y)
# The Descendant: X causes Z and Z is a commom cause of Y and A. Conditioning on A is similar to conditioning on Z. ( X -> Z -> Y, Z -> A)
6E4. How is a biased sample like conditioning on a collider? Think of the example at the open of the chapter.
# Both conditioning on a collider and biased sampling allow us to predict the outcome based on controlling input variables. Taking the example of electricity -> Light <- switch from the chapter, if we know/determine the values of 2 variables we can predict the third one with high accuracy, as in for example is the switch is on and the light is on, we know that the electricity is on.
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 have the following paths connecting X to Y:
# X <- U <- A -> C -> Y
# X <- U -> B <- C -> Y
# After introducing the unobserved variable V:
# X <- U <- A -> C <- V -> Y
# X <- U -> B <- C <- V -> Y
# As B is a collider, so considering the option of not conditioning on it, it acts as a closed backdoor for the path between X and Y.
# V eliminates the dependencies around it if not conditioned on it, regarding its fork nature.
# As A is a fork, conditioning on it will close the path between X and Y.
# => we should condition on A and close the path involving it.
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
x <- rnorm(N)
z <- rnorm(N, x*.99)
y <- rnorm(N, z*.85)
df <- data.frame(x, y, z)
pairs(df)
cor(df)
## x y z
## x 1.0000000 0.549519 0.6808577
## y 0.5495190 1.000000 0.7521230
## z 0.6808577 0.752123 1.0000000
# In this simulation, the correlation table shows X and Z having the highest positive correlation, as well as a similarly high correlation between Y and Z, but the correlation between Z and Y is clearly weaker. for this reason, no multicolliniearity could be observed, as the predictors don't have similarly high correlation to the construct.
# This simulation is different from the legs example in the chapter regarding the difference between their confounds nature, where the legs example is a fork meanwhile this simulation is a pipe.