[R] Quicker way to apply values to a function

casperyc casperyc at hotmail.co.uk
Fri Mar 23 20:48:47 CET 2012


Hi Petr,

Thanks for confirming that the integral is bounded. I was thinking about the
same thing.

However, this requires that 'sigma' is positive.

The actual problem occurred in my optimization routine, where i have set the
parameter 

sigma=exp(para), where para is the logit of a uniform random variable.

To avoid sigma being too small, i also used

if ( round(sigma,3)==0 ) { sigma=0.5 }

However, I still have the following error: during optimization using 'optim'

Error in integrate(function(x) dnorm(x, mu, sigma)/(1 + exp(-x)), -Inf,  : 
  the integral is probably divergent

I think, it's still caused by 'small' sigma, but is there a way to fix it?

Or should I use another  way to randomly generate sigma>0?

Thanks.

casper

-----
###################################################
PhD candidate in Statistics
School of Mathematics, Statistics and Actuarial Science, University of Kent
###################################################

--
View this message in context: http://r.789695.n4.nabble.com/Quicker-way-to-apply-values-to-a-function-tp4497293p4500014.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list