[R] nlm behaviour and error

Prof Brian Ripley ripley at stats.ox.ac.uk
Tue Jun 3 08:23:11 CEST 2008


It says the value is *missing* (NA), not that the length is wrong.

My quess is that term*bexp is NaN, but you have given us no context to go 
on.

On Tue, 3 Jun 2008, Redding, Matthew wrote:

> 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")
>       theta<-2000
>    }
>
>
>
> 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
> ********************************DISCLAIMER**************...{{dropped:15}}
>
> ______________________________________________
> 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.
>

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-help mailing list