“For every unit increase in the independent variable we observe an increase of y-units in the dependent variable”
library(broom)
library(gt)
set.seed(1) # Setting the seed
n <- 50 # Number of observations
c <- rnorm(n) # Simulating the counfounder
x <- c + rnorm(n) # The confounder "cause" x
y <- c + rnorm(n) # The confounder "cause" y
m <- lm(y ~ x) # The model
tidy(m) %>%
gt() %>%
fmt_auto()
term | estimate | std.error | statistic | p.value |
---|---|---|---|---|
(Intercept) | −0.147 | 0.162 | −0.908 | 0.368 |
x | 0.436 | 0.129 | 3.388 | 0.001 |
term | estimate | std.error | statistic | p.value |
---|---|---|---|---|
(Intercept) | −0.156 | 0.132 | −1.182 | 0.243 |
x | 0.004 | 0.136 | 0.031 | 0.975 |
c | 1.024 | 0.204 | 5.021 | 7.847 × 10−6 |
set.seed(1) # Setting the seed
n <- 50 # Number of observations
x <- rnorm(n) # Nothing else is causing x
y <- rnorm(n) # Nothing else is causing y
c <- x + y + rnorm(n) # The collider is caused by y and x
m1 <- lm(y ~ x) # The model without collider
m2 <- lm(y ~ x + c)
tidy(m1) %>%
gt() %>%
fmt_auto() %>%
tab_caption("Model estimates without collider")
term | estimate | std.error | statistic | p.value |
---|---|---|---|---|
(Intercept) | 0.122 | 0.139 | 0.875 | 0.386 |
x | −0.046 | 0.168 | −0.271 | 0.788 |
term | estimate | std.error | statistic | p.value |
---|---|---|---|---|
(Intercept) | 0.14 | 0.096 | 1.462 | 0.15 |
x | −0.573 | 0.136 | −4.227 | 1.081 × 10−4 |
c | 0.537 | 0.072 | 7.41 | 1.955 × 10−9 |
In this workshop we will try to simulate (with plausible estimates):