[R-es] what´s wrong with this code?

José Manuel Gavilán Ruiz gavi en us.es
Vie Oct 29 11:20:24 CEST 2010


Hello,  I  want  to  maximize  a  likelihood  function expressed as an
integral  that  can not be symbolically evaluated. I expose my problem
in a reduced form.

g<- function(x){
integrand<-function(y) {exp(-x^2)*y}
g<-integrate(integrand,0,1)
}                         
h<-function(x) log((g(x)))

g  is an object of the class function, but g(2) is a integrate object,
I can print(g(2)) an get a result, but
if I try h(2) R says is a nonnumeric argument for a mathematical
function. My goal is to maximize h.
what´s wrong?

thanks



Más información sobre la lista de distribución R-help-es