Difference between revisions of "Diversity index"

From Testiwiki
Jump to: navigation, search
(explanations added)
(Answer)
Line 15: Line 15:
  
 
true <- function(pi, q){
 
true <- function(pi, q){
qD <- (sum(pi^q))^(1 / (1 - q))
+
if(q != 1){qD <- (sum(pi^q))^(1 / (1 - q))} else
 +
{qD <- exp(-sum(pi * log(pi)))}
 
return(qD)
 
return(qD)
 
}
 
}
Line 24: Line 25:
 
}
 
}
  
out <- data.frame(Name = c("Richness", "Shannon index", "Simpson index", "Inverse Simpson index",  
+
out <- data.frame(Name = c("Richness", "True diversity with q=1", "True diversity with q=2", "True diversity with q=∞", "Shannon index", "Simpson index", "Inverse Simpson index",  
 
     "Gini-Simpson index", "Berger-Parker index"),  
 
     "Gini-Simpson index", "Berger-Parker index"),  
     Symbol = c("S or 0D", "H' or log(1D)", "λ or 1/(2D)", "1/λ or 2D", "1-λ or 1-1/(2D)", "∞D"),
+
     Symbol = c("S or 0D", "1D", "2D", "∞D", "H' or log(1D)", "λ or 1/(2D)", "1/λ or 2D", "1-λ or 1-1/(2D)", "1/(∞D)"),
     Value = c(true(pi,0), log(true(pi,1)), 1/true(pi,2), true(pi,2), 1-1/true(pi,2), max(pi)))
+
     Value = c(true(pi,0), true(pi,1), true(pi,2), 1/max(pi), log(true(pi,1)), 1/true(pi,2), true(pi,2), 1-1/true(pi,2), max(pi)))
 
return(out)
 
return(out)
 
}
 
}

Revision as of 21:16, 5 January 2012



Question

How to calculate diversity indices?

Answer

Upload your data to Opasnet Base. Use the function diversity to calculate the most common indices.

Actual function diversity

+ Show code

# : With the example data, H' shows 0 which is not plausible. What's wrong? --Jouni 01:10, 5 January 2012 (EET)

Example to use function

Give your data in R format or leave empty for example data:

Is your data individual data or group abundancies?:

+ Show code

The data should be given in R format as a list of values in parenthesis, beginning with c:

c(3,5,3,5,2,1,3,3,4,2) or equivalently c(0.1,0.2,0.4,0.1,0.2)

where the values are either

  • identifiers of the species 1,2,3... in which the individuals belong (one entry per individual), or
  • abundancies of species, i.e. proportions of individuals belonging to each species among the whole population (one entry per species).

Rationale

Diversity indices are thoroughly described in Wikipedia.

See also

References


Related files

<mfanonymousfilelist></mfanonymousfilelist>