Solving for 2 variables under GMM -
i tried solve 2*1 matrix of gmm estimators 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, yield error message:
error in p$g(p$t0, x) : argument "y" missing, no default
could me find out went wrong? lot!
the gmm function can have 1 matrix variables , 1 vector parameters. there go:
set.seed(123)#to replicate 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 1 matrix both vectors e<-function(rgaaa,x) #one input parameters , 1 input 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 seed pseudo-random numbers 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 0 j-test p-value test e(g)=0: 0.00577448313404338 ******* ############# information related numerical optimization convergence code = 0 function eval. = 25 gradian eval. = 24
Comments
Post a Comment