Re: [R] Matrix calculations in R--erroneous?

From: Peter Muhlberger <>
Date: Sun 09 Oct 2005 - 01:17:03 EST

Hi Spencer: Thanks! This gives me a number of other ways of thinking about this problem. My one concern is that these approaches would also run into some difficulties with how long it takes to calculate. I'm interested not in a single value but a matrix of over 300k values that has to be recomputed more than a million times. If I had to apply ifelse or floor to each of these, it might take too long. I'll have to see.


On 10/7/05 5:55 PM, "Spencer Graves" <> wrote:

> Rather than adding 1e-15 to all numbers, I suggest you simply make
> that the floor. (Or use .Machine$double.eps or 2*.Machine$double.eps in
> place of 1e-15.)
> Another alternative that may or may not apply in your case is to
> develop an asymptotic expansion for the log(likelihood) for the small
> numbers. I've had good success with this kind of method. For example,
> consider the Box-Cox transformation:
> bc(y, b) = (y^b-1)/b
> What do we do with b = 0? We can test for b = 0 and replace those
> cases by the limit log(y). However, it is numerically more stable to
> use the following:
> bc(y, b) = ifelse(abs(b*log(y))>.Machine$double.eps,
> (expm1(b*log(y))/b, log(y)).
> I don't have time to study your example to see if I could see
> anything like this that could be done, but I think there should be a
> good chance of finding something like this. Of course, if there are
> only very few 0's, then it hardly matters. However, if there are quite
> a few, then you need something like this.
> hope this helps.
> spencer graves mailing list PLEASE do read the posting guide! Received on Sun Oct 09 01:33:24 2005

This archive was generated by hypermail 2.1.8 : Sun 23 Oct 2005 - 18:32:23 EST