0

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) 
Novic
  • 351
  • 1
  • 11
  • This is the error I got (I'm using the gmm library): ```Error in object$g(object$t0, object$x) : unused argument (object$x)```. It seems like you're missing the t0 argument – Jack Hanson Mar 26 '20 at 18:57
  • The error is there even with the t0 argument. The problem is that I don't know how to use a lag variable as an instrument. It's super simple in Stata. – Novic Mar 26 '20 at 20:52
  • Could you include the updated code/what you used for t0? And here's the definition of the t0 function for the gmm library: ```A k × 1 vector of starting values. It is required only when "g" is a function because only then a numerical algorithm is used to minimize the objective function. If the dimension of θ is one, see the argument "optfct".``` - since your g is a function, you do need to use the t0 argument. Here's a link to the docs, hopefully this willl help - https://cran.r-project.org/web/packages/gmm/gmm.pdf – Jack Hanson Mar 27 '20 at 21:29

0 Answers0