I have a simple example of GMM model I need to estimate. I'd appreciate if ssomeone can haelp cause I don't get my answer from GMM R document. assume I have a function g(teta,a,b)=0
and I need to estimate teta. g = (a-b)/2 - teta^2 * a + b^2 * teta + 2
. The Instrument variable I intend to use is the lag of variable b. This seems simple but I end up with an error and I don't know what's the problem.
a <- c(1 , 2 , 3 , 4 , 5 , 6 , 7)
b <- c(1 , 0 , 2 , 4 , 1 , 4 , 2)
moment <- as.matrix( lag(b , n=1) )
g <- function(teta) (a-b)/2 - teta^2 * a + b^2 * teta
gmm(g, x = moment)