[R] How to run Hutcheson t-test on R?

Rui Barradas ru|pb@rr@d@@ @end|ng |rom @@po@pt
Tue Sep 8 16:55:14 CEST 2020


Hello,

No, it's not. That's the Shannon diversity index, the test the OP is 
looking for is a t-test for Shannon diversity index equality. The index 
itself is easy to code. A very simple example, based on ?vegan::diversity:


library(vegan)

data(BCI)
H <- diversity(BCI[1,])    # just first row

divers <- function(n){
   p <- n/sum(n)
   log_p <- numeric(length(n))
   log_p[n != 0] <- log(p[n != 0])
   -sum(p * log_p)
}
HRui <- divers(BCI[1,])

identical(H, HRui)
#[1] TRUE


The vegan function is more general, it applies this and other indices 
calculations to a matrix or array.

The t-test doesn't seem difficult to code.
The variance formula in the paper and in the OP's posted link [1] are 
not the same, the original has one more term, but the degrees of freedom 
formula are the same. It all seems straightforward coding.

Luigi: Maybe later today I will have time but I am not making promises.


[1] https://www.dataanalytics.org.uk/comparing-diversity/


Hope this helps,

Rui Barradas


Às 12:35 de 08/09/20, Karl Schilling escreveu:
> Could it be that the test you are looking for is implemented in the 
> vegan package (function diversity(... index = "shannon" ...), and/or the 
> BiodiversityR package, function "diversityresult (..., index = 
> "Shannon",...)
> 
> best,
> Karl Schilling
> 
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.



More information about the R-help mailing list