An embedded and charset-unspecified text was scrubbed... Name: not available Url: https://stat.ethz.ch/pipermail/r-help/attachments/20071203/b268facd/attachment.pl
Why is the program too slow?
3 messages · Jian Zhang, Ben Bolker, Dimitris Rizopoulos
zhang jian wrote:
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
Don't know, but I would try out the alternatives fisherfit [vegan package]
and fisher [untb package] and see if either behaves better (it was faster
for me to look these up than to dig through the code and see what's
going on for these examples).
You could also try contacting Prof. Harms [sic] and asking him ...
cheers
Ben Bolker
View this message in context: http://www.nabble.com/Why-is-the-program-too-slow--tf4936535.html#a14130312 Sent from the R help mailing list archive at Nabble.com.
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