I was thinking that in a very standard case such as a simple linear model with iid errors and no endogeneity, I would get the same results using the a simple least square estimate (such as provided by
lm() in R) and a simple GMM estimator with an identity matrix as the weighting matrix and the matrix of regressors as instruments.
I've just run the following simulation in R to compare the results of the
lm() function and of the
gmm() function :
> library("gmm") > set.seed(1234567) > N <- 1000 > dd <- data.frame(id = 1:N) > dd$u <- rnorm(N) > dd$x <- 1 + rnorm(N) > dd$y <- 1 + dd$x + dd$u > m1 <- lm(y ~ x, data = dd) > m2 <- gmm(y ~ x, x = ~ x, wmatrix = "ident", data = dd)
I've got the same coefficients but I don't have exactly the same standard errors :
> coefficients(m1) (Intercept) x 1.0273856 0.9690455 > coefficients(m2) (Intercept) x 1.0273856 0.9690455 > sqrt(diag(vcov(m1))) (Intercept) x 0.044285 0.031726 > sqrt(diag(vcov(m2))) (Intercept) x 0.04367438 0.03127408
I'm not sure to understand why the standard errors are different in this case. Is this due to statistical theory or to the
gmm() function ?
See my gist file if you want to run the example.