[R] how to keep very small or large number?

Cunningham Kerry kerryrekky at yahoo.com
Fri Sep 23 03:07:28 CEST 2005


Suppose I have n=1000 cases. For each case, the
probability can go like 1e-10, then I have to multiply
these probabilities together to get joint probability.

I tried to do the following:

p=1

x1=runif(n,0,1)
x2=runif(n,0,1)
y=ifelse(runif(m) < plogis(-6+6*x1+6*x2), 1, 0);

pta0=-6
pta1=6
pta2=6

for(i in 1:n)
{
  p <-
p*exp((y[i]*log(plogis(pta0+pta1*x1[i]+pta2*x2[i]))+(1-y[i])*log(1-plogis(pta0+pta1*x1[i]+pta2*x2[i]))))
}

but the result is shown to be zero.

--- Cunningham Kerry <kerryrekky at yahoo.com> wrote:

> When I was computing some joint probabilities, I
> found
> that R reported most of the results to to -Inf and
> thus didn't record the value. I guess it is b/c the
> joint log(probability) can be extremely small. Is
> there a way in R to keep the values even if they are
> small?
> 
> 
> 
> 		
> __________________________________ 

> http://mail.yahoo.com
>




More information about the R-help mailing list