Jump to content

R Programming/Method of Moments

From Wikibooks, open books for an open world
  • Package gmm implements the generalized method of moment and the generalized empirical likelihood.

First, it is possible to estimate a simple linear model or a simple linear model with instrumental variables using the gmm() function. The GMM method is often used to estimate heteroskedastic instrumental variable models.

> # Simple linear model > N <- 1000 > u <- rnorm(N) > x <- 1 + rnorm(N) > y <- 1 + x + u > res <- gmm(y ~ x, x) > # Simple linear model with instrumental variables. > library(gmm) > N <- 1000 > u <- rnorm(N) > z <- rnorm(N) > x <- 1 + z + u + rnorm(N) > y <- 1 + x + u > res <- gmm(y ~ x, z) > summary(res)