Learn R Programming

rich (version 0.2)

c2m: Compares 2 mean values using a randomization test

Description

Mean values of 2 populations are compared using a randomization procedure. Overlapping populations are allowed.

Usage

c2m(pop1, pop2,pop3=NULL,nrandom,pr1=0.025,pr2=0.975,verbose=TRUE)

Arguments

pop1
A vector with the observed values for population 1.
pop2
A vector with the observed values for population 2.
pop3
A vector with the observed values that are common to population 1 and 2.
nrandom
Number of randomizations to perform. Default fixed to 99.
pr1
Lower probability level for quantile computations. Default fixed to 0.025.
pr2
Higher probability level for quantile computations. Default fixed to 0.975.
verbose
If verbose is TRUE c2m returns a vector that contains the observed and randomized differences between mean richnesses.

Value

  • resA data frame showing the outputs of the randomization test: mv1 Observed mean values over samples forming population 1. mv2 Observed mean values over samples forming population 2. mv1-mv2 Difference between observed mean values of population 1 and population 2. p Probability of encountering such a value for mv1-mv2 (see details above). quantile for pr1 Quantile value for probability level pr1. quantile for pr2 Quantile value for probability level pr2. randomized mv1-mv2 Mean values of randomized and the observed values. nrandom Number of randomizations used in the test.
  • randA vector of nrandom+1 values corresponding to the observed difference of mv1-mv2 and the randomized values. rand is available if verbose == TRUE.

Details

This randomization test compares the average value of a quantitative variable sampled in 2 populations. Details are available in Manly (1997). In some cases, populations share some observed values: for example if we compare the mean annual temperature of sites where either species A or B is present and if A and B are sympatric in some localities (see example below). Those shared values are passed to c2m by the argument pop3. If the mean value for population 1 $\ge$ mean value for population 2, p is the number of randomizations for which the mean value for population 1 $\ge$ mean value for population 2 divided by the number of randomizations + 1. If the mean value for population 1 $\le$ mean value for population 2, p is the number of randomizations for which the mean value for population 1 $\le$ mean value for population 2 divided by the number of randomizations + 1. If $mv1 = mv2$ p in not computed (p=NC).

References

Manly, B.F.J. (1997). Randomization and Monte Carlo methods in biology. Chapman & Hall.

See Also

c2cv, c2rcv, rich

Examples

Run this code
# The example of mandible length of male and female 
# golden jackals from Manly (1997), p.4.
males<-c(120, 107, 110, 116, 114, 111, 113, 117, 114, 112)
females<-c(110, 111, 107, 108, 110, 105, 107, 106, 111, 111)
c2m(pop1=males,pop2=females,nrandom=99)

# Maximum temperature in a set of sites where the beetle Tomicus destruens
# or T. piniperda are present. Both species are present at 4 sites.
data(Tomicus)
c2m(pop1=Tomicus$destruens,pop2=Tomicus$piniperda, 
pop3=Tomicus$both, nrandom=99)

# using c2m with outputs of rich
a<-matrix(data=rpois(100,2), ncol=10, nrow=10)
b<-matrix(data=rpois(100,0.5), ncol=10, nrow=10)
x<-rich(matrix(data=rpois(30,2), ncol=5, nrow=6), 
nrandom=50,verbose=TRUE)
y<-rich(matrix(data=rpois(30,0.5), ncol=5, nrow=6), 
nrandom=50,verbose=TRUE)
c2m(pop1=x$sumrow,pop2=y$sumrow,
nrandom=100,verbose=FALSE)

Run the code above in your browser using DataLab