I'm trying to run a GMM estimation which includes the integration of the normal CDF, for which parameters exist in both the function and the integration interval. The gist of the codes as follows:
g1 <- function(b,x){
e <- b[1] +b[2]*x$x1
r <- e + b[3]*x$x2
n <- b[4]+b[5]*x$x3
ncdf <- function(z){
return((pnorm((log(z)-b[6]*log(e))/(b[7]/x$x4)))^n)
}
m1 <- x$y-integrate(ncdf,-Inf,r)/ncdf(r)
f <- cbind(m1)
return(f)
}
init = rep(0,7)
res<-gmm(g1,bids,init)
For slight variations, I'm either getting
Error in integrate(ncdf, -Inf, r) : 'bound' must be of length one
or
Error in integrate(ncdf, -Inf, r) : a limit is NA or NaN
Help would be appreciated. Thanks in advance.