1
$\begingroup$

I am currently trying to figure out the problem of endogenity, which occurs when an explantory variable is correlated with the error term. There are apparently different causes for endogenity, but one of the most frequent one seems to be omitted variable bias.

I created a short R-code in order to understand the dynamics of an omitted variable bias and how it would cause the error term to be correlated with the explanatory variable:

set.seed(111)

x1 <- sample(1:20, 100, replace = T)

x2 <- 3 * rnorm(n = 100, mean = x1, sd = 10)

a <- 2; b = 1.5; c = - 3

y <- a + b * rnorm(100, x1, 5) + c * rnorm(100, x2, 5)

my_model <- lm(y ~ x1)

eps <- resid(my_model)

cor(x1, eps)
[1] -1.088585e-16

So apperently the explanatory vaariable $x_1$ is not correlated with the error term at all, despite an important explanatory variable being omitted.

What am I doing/getting wrong?

$\endgroup$

1 Answer 1

1
$\begingroup$

You should not look for the signs of endogenity in the correlation between OLS residuals and the explanatory variables. Because you will never see any correlation and that is because by design OLS residuals and explanatory variables are independent. The idea of OMV is that if you have an important missing variable, it could (will) lead to biased estimators for the remaining explanatory variables. As you can see in your own example, the coefficient of x1 is very far away from its expected value (-6.3 compared to 1.5). on the other hand if you include the omitted variable to the model the estimation would be much closer to their actual values.

 set.seed(111)    
 x1 <- sample(1:20, 100, replace = T)
 x2 <- 3 * rnorm(n = 100, mean = x1, sd = 10)
 a <- 2; b = 1.5; c = - 3
 y <- a + b * rnorm(100, x1, 5) + c * rnorm(100, x2, 5)

 my_model <- lm(y ~ x1)
 true_model <- lm(y ~ x1 + x2)

 coef1 <- coefficients(my_model)
 coef1

 coef2 <- coefficients(true_model)
 coef2

Hope it helps

$\endgroup$
1
  • $\begingroup$ Hi Masood, Thanks a lot for your answer. It helped me to understand the problem of my thinking. To answer my own question a little bit more precisely, I would put it the following way: My problem was that I confounded the estimated/emprical residuals with the theoretical/real residuals. While the estimated residuals will never be correlated with the models explanatory variables, since they are, as you said, designed that way, the real/theoretical residuals would be in case of OBV. So I mixed up empirical and theoretical residuals $\endgroup$ Feb 23, 2018 at 15:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.