Re: [R] optimize() stuck in local plateau ?

2007-10-01 Thread Ravi Varadhan
-Original Message- From: Mike Lawrence [mailto:[EMAIL PROTECTED] Sent: Monday, October 01, 2007 10:27 AM To: Ravi Varadhan Cc: 'Rhelp' Subject: Re: [R] optimize() stuck in local plateau ? I may be misunderstanding, but my example seems to v

Re: [R] optimize() stuck in local plateau ?

2007-10-01 Thread Mike Lawrence
p://www.jhsph.edu/agingandhealth/People/Faculty/ > Varadhan.html > > > > ---------- > -- > > > > -Original Message- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] > project.org]

Re: [R] optimize() stuck in local plateau ?

2007-10-01 Thread Ravi Varadhan
alth/People/Faculty/Varadhan.html -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Mike Lawrence Sent: Monday, October 01, 2007 1:29 AM To: Rhelp Subject: [R] optimize() stuck in local plateau ? Hi all, Consider the

Re: [R] optimize() stuck in local plateau ?

2007-10-01 Thread Patrick Burns
Given a univariate problem where the maximum must be between -1 and 1, I would test with a grid of points, then refine that if necessary. Patrick Burns [EMAIL PROTECTED] +44 (0)20 8525 0696 http://www.burns-stat.com (home of S Poetry and "A Guide for the Unwilling S User") Mike Lawrence wrote: >

Re: [R] optimize() stuck in local plateau ?

2007-09-30 Thread Moshe Olshansky
Hi Mike, You function is discontinuous at -0.8, so you can expect everything :-}! But this is not the only problem. The algorithm for optimize never gets there. In general there exists no universal method to find the global maximum of a function (unless it satisfies certain conditions). You can al

[R] optimize() stuck in local plateau ?

2007-09-30 Thread Mike Lawrence
Hi all, Consider the following function: my.func = function(x){ y=ifelse(x>-.5,0,ifelse(x< -.8,abs(x)/2,abs(x))) print(c(x,y)) #print what was tested and what the result is return(y) } curve(my.func,from=-1,1) When I attempt to find the maximum of this function,