[R] Why is the program too slow?

Dimitris Rizopoulos dimitris.rizopoulos at med.kuleuven.be
Mon Dec 3 15:02:30 CET 2007


try

RSiteSearch("Fisher's alpha")

which indicates that there is the fishers.alpha() function in package 
'untb' that does the same thing, e.g.,

fishers.alpha(1000, 70)

fishers.alpha(1580, 30)
fishers.alpha(1000, 7)


I hope it helps.

Best,
Dimitris

----
Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven

Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/(0)16/336899
Fax: +32/(0)16/337015
Web: http://med.kuleuven.be/biostat/
     http://www.student.kuleuven.be/~m0390867/dimitris.htm


----- Original Message ----- 
From: "Jian Zhang" <jzhang1982 at gmail.com>
To: "R-help" <r-help at stat.math.ethz.ch>
Sent: Monday, December 03, 2007 2:12 PM
Subject: [R] Why is the program too slow?


> Hi,everyone.
> I use the following program calculates Fisher's alpha from counts of 
> individuals and species. The program is wrote by Prof. Kyle Harm.
> However, when I run the program, it can work very quickly sometimes, 
> but it can not work very well sometimes. It depends on the counts of 
> individuals and species.
> For example,
>
>> calc.alpha(1000,70)
> [1] 17.14375
>> calc.alpha(10000,70)
> [1] 10.15460
>> calc.alpha(100,7)
> [1] 1.714375
>
> But,
>> calc.alpha(1580,30)
>> calc.alpha(1000,7)
>
> It is very slow.
>
> So, what is the problem?
> Thanks very much.
>                                                      Jian Zhang
>
>
> # The following function calculates Fisher's alpha from counts of 
> individuals and species.
> # Note that this program assumes that the true value of alpha lies 
> within the range 0.001¨C10000
> # (a likely assumption for local assemblages of organisms).
> # The function returns "-1" if there is a problem.
>
> calc.alpha=function(n.orig, s.orig)
> {
>  a=numeric()
>
>  len.n=length(n.orig)
>  len.s=length(s.orig)
>
>  if(len.n != len.s)
>    { return(-1)  }
>
>  for(i in 1:len.n)
>   {
>     if(n.orig[i]<=0 | s.orig[i]<=0 | n.orig[i]<=s.orig[i])
> { a[i]=(-1) }
>
>     else
>      {
>       low.a=0.001
>       high.a=10000
>       low.s = low.a*log(1+(n.orig[i]/low.a))
>       high.s = high.a*log(1+(n.orig[i]/high.a))
>
>       if((s.orig[i]<=low.s) | (s.orig[i]>=high.s))
>        { a[i]=(-1) }
>
>       else
>        {
>         use.s=s.orig[i]+1
>         while(s.orig[i] != use.s)
>          {
>           use.a=(low.a+high.a)/2
>           use.s=use.a*log(1+(n.orig[i]/use.a))
>
>           if(s.orig[i]<use.s)
>  { high.a=use.a }
>
>           if(s.orig[i]>use.s)
>  { low.a=use.a }
>          }
>         a[i]=use.a
>        }
>      }
>   }
>
>   return(a)
> }
>
> [[alternative HTML version deleted]]
>
>


--------------------------------------------------------------------------------


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


Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm



More information about the R-help mailing list