I get weird results when trying to analyze omitted variable bias in R.
If I try to analyze the bias for coefficient $\beta_j$ of variable $x_j$ in case of one omitted variable from set of two correlated variables, the limit bias should be given by:
$$ BIAS_{j,(lim)} = \beta_k \frac{COV \left[ x_j, x_k \right]}{VAR \left[ x_j \right]} $$
This is something I can see in R, considering I have the following setup:
$corr(x_2, x_3) \neq 0$ for $y_{(true)} = \beta_1 x_1 + \beta_2 x_2 + \beta_3 x_3 + \epsilon$ and $y_{(est)} = \gamma_1 x_1 + \gamma_2 x_2 + u$.
Then:
$$\gamma_2 = \beta_2 + \beta_3 \frac{COV \left[ x_2, x_3 \right]}{VAR \left[ x_2 \right]}$$
BUT when I do the scenario such that:
$corr(x_2, x_3) \neq 0 \land corr(x_2, x_4) \neq 0 \land corr(x_3, x_4) \neq 0$, while omitting only $x_4$, then I do not get the results above for $x_2$ and $x_3$. Why?
The code is below:
set.seed(100)
n=1000
corr12 = 0.7
corr23 = 0.5
corr13 = 0.2
sd1 = 20
sd2 = 5
sd3 = 7
covmat = matrix(c(sd1^2, corr12*sd1*sd2, corr13*sd1*sd3,
corr12*sd1*sd2, sd2^2, corr23*sd2*sd3,
corr13*sd1*sd3, corr23*sd2*sd3, sd3^2), ncol = 3, byrow = T)
ostat = mvrnorm(n, c(100,80, 120), Sigma = covmat)
z = rnorm(n,100, 30)
x1 = rnorm(n,100,20)
x2 = ostat[,1]
x3 = ostat[,2]
x4 = ostat[,3]
y = 20 + 2*x1 + 4*x2 + 2*x3 + 5*x4 + rnorm(n,0,1)
cor(cbind(x1,x2,x3,x4,y))
olsT = lm(y~x1 + x2 + x3 + x4)
summary(olsT)
ols1 = lm(y ~x1 + x2 + x3)
summary(ols1)
5*(cov(x2,x4)/var(x2)) ## this does not provide the right bias
5*(cov(x3,x4)/var(x3)) ## this does not provide the right bias