[R] nlm behaviour and error

From: Redding, Matthew <Matthew.Redding_at_dpi.qld.gov.au>
Date: Tue, 03 Jun 2008 16:01:51 +1000

Hi R-Gurus,

I've been cutting along quite nicely with nlm, until I threw in the following condition in the function that nlm is minimising:

    if (((term*bexp) < 0.0001)) {

       #warning(term*bexp, "=term*bexp",psi,"=psi")	


Now when I run this function anywhere else, there is no problem, whether or the if's condition is met.

When I use this in nlm:

nlm(f=ssewrap.dist, p=c(292397.7,-.14053,0.03,.0005), .5, 1, 295.15,C,theta)
Error in if (((term * bexp) < 1e-04)) { :   missing value where TRUE/FALSE needed

Now I know that the condition in the if should only be one logical value, but is not the condition above evaluated to a single value, and why does the error only occur when the function is used by nlm?

Any suggestions?

Kind regards,

Matt Redding


R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Tue 03 Jun 2008 - 06:04:44 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 03 Jun 2008 - 08:30:37 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive