1
$\begingroup$
  1. First question: Is the following example of computing the Hausman-test for endogeneity with two endogenous regressors adequate?
  2. Second question: Is it true that in case of heteroscedasticity, i.e. I'll get a significant result for the Breusch-Pragan-Test, I need to run a Durbin-Watson-Wu-Test for endogeneity with heteroscedastic robust standard errors? Is this not just the same thing if i instead run a regression with heteroscedastic robust standard errors, i.e. of HC4-type, and then perform the usual Wald or F-test? Or even choose a GLS-approach to control for the heteroskedasticity?

Consider this example (sorry for all the R-code but you can just run this "thing" and see for yourself)

To set things up I generate three variables with a desired correlation. To do this I use my CorrNorm2 function

CorrNorm2 <- function(n, rho1, rho2, rho3) { 
    u1          <- rnorm(n,0,1)
    u2          <- rnorm(n,0,1)
    u3          <- rnorm(n,0,1)
    x       <- cbind(u2,u3)
    u1      <- as.vector( ( diag(n) - x%*%solve(t(x)%*%x)%*%t(x) ) %*% u1 )
    u1      <- ( u1 - mean(u1) )/sd(u1)
    x       <- cbind(u1,u3)
    u2      <- as.vector( ( diag(n) - x%*%solve(t(x)%*%x)%*%t(x) ) %*% u2 )
    u2      <- ( u2 - mean(u2) )/sd(u2)
    x       <- cbind(u1,u2)
    u3      <- as.vector( ( diag(n) - x%*%solve(t(x)%*%x)%*%t(x) ) %*% u3 )
    u3      <- ( u3 - mean(u3) )/sd(u3)
    covmat  <- matrix(0,3,3)
    covmat[,1]  <- c(1, rho1, rho3)
    covmat[,2]  <- c(rho1, 1, rho2)
    covmat[,3]  <- c(rho3, rho2, 1)
    svd_covmat  <- svd(covmat)
    D       <- diag(3)*svd_covmat$d
    	D 		<- sqrt(D)
    	V 		<- svd_covmat$v
    L       <- V%*%D
    z1      <- L[1,1]*u1 + L[1,2]*u2 + L[1,3]*u3
    z2      <- L[2,1]*u1 + L[2,2]*u2 + L[2,3]*u3
    z3      <- L[3,1]*u1 + L[3,2]*u2 + L[3,3]*u3
    z       <- cbind(z1,z2,z3)
    return(z) 
} 

Now I set up my sample design

n   <- 100
rho1    <- 0.5 #rho1: cor between 1 and 2
rho2    <- 0     #rho2: cor between 2 and 3
rho3    <- 0.5 #rho3: cor between 1 and 3
b1  <- 1
b2  <- 2
b3  <- 3
var     <- CorrNorm2(n,rho1,rho2,rho3)
u1  <- var[,1]
u2  <- var[,2]
u3  <- var[,3]
x1  <- rnorm(n,0,1)
z1  <- rnorm(n,0,1)
z2  <- rnorm(n,0,1)

y3  <- z1 + u3
y2  <- z2 + u2
y1  <- b1*y2 + b2*y3 + b3*x1 + u1

The first step of the Hausman test for endogeneity is to calculate the reduced form errors for the endogenous regressors. In my case for the variables $y_2$ and $y_3$

# reduced form of y2
mod2    <- lm(y2 ~ z1 + z2)
res2    <- resid(mod2)

# reduced form of y3
mod3    <- lm(y3 ~ z1 + z2)
res3    <- resid(mod3)

Next I plug the estimated residuals of these reduced form errors, i.e. res2 and res3, into the structural form: $y_1$ i.e. into $y_1 = b_1y_2 + b_2y_3 + b_3x_1 + u_1$.

haus1 <- lm(y1 ~ y2 + y3 + x1 + res2 + res3)

Then I perform a F-test for the joint significance of res2 and res3. For this I need to derive the sum of squared residuals for the unrestricted ($SSR)$) and the restricted ($SSR_{H0}$) form. The unrestricted sum of squared residuals is just the the sum of squared residuals of the model which includes the reduced form residuals. The restricted model is the OLS-Regression without the reduced form residuals.

# sum of squared residuals for the unrestricted model
SSR <- sum(resid(haus1)^2)

# sum of squared residuals for the restricted model
restricted.mod <- lm(y1 ~ y2 + y3 + x1)
SSR_H0 <- sum(resid(restricted.mod)^2)

Now I perform the usual F-Test on a $\alpha=0.05$ level

F <- ((n - length(b) ) / 2 )*( (SSR_H0 - SSR)/SSR )
F
[1] 20.72482
F > qf(0.95, 2, n - length(b))
[1] TRUE

Hence I can reject the $H_0$ to $\alpha=0.05$. So at least one of the variables, i.e. $y_2$ or $y_3$ are indeed endogenous.

$\endgroup$

Your Answer

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

Browse other questions tagged or ask your own question.