Hi all,

Does anybody have the experience of using optim to estimate variables with integral forms?

here the code:


trun.mean<- function(x)      # t is the threshold
{

mu=x[1];

sigma=x[2];

t=x[3];

f <- function(x) (1/(sigma*sqrt(2*pi)))*exp(-(x-mu)^2/(2*sigma^2));

pdf.fun <- function(x) x*f(x);

integrate(f,thre,upper=Inf)$value/integrate(pdf.fun,thre,upper=Inf)$value ;  
}

when I run :  

> optim(c(200,100,113),trun.mean)

Error in optim(c(2, 3, 3), trun.mean) : function cannot be evaluated at initial parameters



I need your help, thanks!

Jen.

	[[alternative HTML version deleted]]

