[R] dlogis for large negative numbers

Prof Brian Ripley ripley at stats.ox.ac.uk
Wed Oct 6 17:45:35 CEST 2004


On Wed, 6 Oct 2004, Dimitris Rizopoulos wrote:

> Hi to all,
> 
> > dlogis(-2000)
> [1] NaN
> Warning message: 
> NaNs produced in: dlogis(x, location, scale, log) 
> > dnorm(-2000)
> [1] 0
> 
> 
> Is this an expected behaviour of `dlogis()'?

No, it's a poor algorithm.  See dlogis.c

    x = (x - location) / scale;
    e = exp(-x);
    f = 1.0 + e;
    return give_log ? -(x + log(scale * f * f)) : e / (scale * f * f);

That needs to be 

    x = fabs((x - location) / scale);

-- 
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