# [R] optimx: Cannot evaluate function at initial parameters

Olufemi Bolarinwa dafemlions at yahoo.co.uk
Tue Apr 28 22:51:14 CEST 2015

```Hello,I am estimating a system of nonlinear GMM. the following are my objective function, the gradient function and the optimx code for the optimization.  I actually worked out the gradient and hessian by hand before inputing the code into r. However, I did get the following error message in my optimx routine
objective functionobj = function(initial.values,z) {  e1 = y1-(a1*x1 + a2*x2 +a3*x3 + a4*x4 + a5*x5 + a22*(exp(a6*x6 + a7*x7 + a8*x9 + a9*x10 + a10*x11 + a11*x12 + a14*x16)/(1+exp(a6*x6 + a7*x7 + a8*x9 + a9*x10 + a10*x11 + a11*x12 + a14*x16))))   e2 = y2-(b1*x1 + b2*x2 +b3*x3 + b4*x4 + b5*x5 + b22*(exp(b6*x6 + b7*x7 + b8*x9 + b9*x10 + b10*x11 + b11*x12 + b14*x16)/(1+exp(b6*x6 + b7*x7 + b8*x9 + b9*x10 + b10*x11 + b11*x12 + b14*x16))))  e3 = y3-(exp(c1*x1 + c2*x18 + c3*x19 + c4*x20 + c5*x21 + c6*x14 + c7*x8)/(1 + exp(c1*x1 + c2*x18 + c3*x19 + c4*x20 + c5*x21 + c6*x14 + c7*x8)))  e = rbind(e1,e2,e3)  q = t(e)%x%z%x%w%x%t(z)%x%e  return(q)}