Created
July 30, 2013 10:48
-
-
Save pachevalier/6111962 to your computer and use it in GitHub Desktop.
This gist compare the results of the gmm() and the lm() function in R using simulated data.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) | |
| coefficients(m1) | |
| coefficients(m2) | |
| sqrt(diag(vcov(m1))) | |
| sqrt(diag(vcov(m2))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment