Skip to content
Prev 385596 / 398503 Next

How to run Hutcheson t-test on R?

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: