1

I tried to solve for a 2*1 matrix of GMM estimators with the following code:

x<-rnorm(50, mean = 3, sd = 2)
y<-rnorm(50, mean = 4, sd = 1)
z_1<-as.matrix(x)
z_2<-as.matrix(y)
e<-function(RGAAA,x,y)
          {m1<-exp(-x/RGAAA[1])-1
          m2<-exp(-y/RGAAA[2])-1
          f<-cbind(m1,m2)  
          return(f)}


summary(gmm(e,cbind(z_1,z_2),c(1,1),method="BFGS",control=1e-12)) 

However, they yield the error message:

Error in P$g(P$t0, x) : argument "y" is missing, with no default

Could anyone help me find out what went wrong? Thanks a lot!

1 Answers1

0

The Gmm function can have only one matrix for the variables and one vector for the parameters. There you go:

set.seed(123)#to replicate the results
x<-rnorm(50, mean = 3, sd = 2)
y<-rnorm(50, mean = 4, sd = 1)
z_1<-as.matrix(x)
z_2<-as.matrix(y)
z <- cbind(z_1,z_2) #make one matrix from both vectors
e<-function(RGAAA,x) #one input for the parameters and one input for the variables
          {m1<-exp(-x[,1]/RGAAA[1])-1
          m2<-exp(-x[,2]/RGAAA[2])-1
          f<-cbind(m1,m2)  
          return(f)}
summary(gmm(e,z,c(1,1),method="BFGS",control=1e-12))

And with my seed for pseudo-random numbers you get the following output:

Call:
gmm(g = e, x = z, t0 = c(1, 1), method = "BFGS", control = 1e-12)


Method:  twoStep 

Kernel:  Quadratic Spectral

Coefficients:
          Estimate     Std. Error   t value      Pr(>|t|)   
Theta[1]   4.5256e+02   3.8809e+01   1.1661e+01   2.0121e-31
Theta[2]   4.9367e+02   1.5265e+01   3.2341e+01  1.8683e-229

J-Test: degrees of freedom is 0 
                J-test               P-value            
Test E(g)=0:    0.00577448313404338  *******            

#############
Information related to the numerical optimization
Convergence code =  0 
Function eval. =  25 
Gradian eval. =  24 
Etienne
  • 108
  • 12