Description Details Author(s) References Examples
A null model randomizing semi-quantitative multi-classes (or ordinal) data by swapping sub-matrices while both the row and the column marginal sums are held constant.
Package: | swapClass |
Type: | Package |
Version: | 1.0.1 |
Date: | 2017-06-22 |
License: | GPL-3 |
Benjamin Borgy (benjamin.borgy@gmail.com), Remi Perronne, Xavier Reboud
Borgy B. - Dynamic and assembly of weed communities: Approach by statistical modeling (2011). Ph.D. Thesis. INRA Agroicologie & Universiti de Bourgogne. DOI: 10.13140/RG.2.1.1738.1601
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | MAT=matrix(sample(0:3,50*20,replace=TRUE,prob=c(.7,.1,.1,.1)),ncol=20)
#Calculation of the nbPerm index
nbPerm(MAT)
#Generation of null communities
NULL_MATS=nullModel(MAT)
#First null community
NULL_MATS$sim[[1]]
#Number of times that each cell has been swapped for the first null community
NULL_MATS$perms[[1]]
#nbPerm index over the observed community and the 100 null communities
plot(c(nbPerm(MAT),unlist(lapply(NULL_MATS$sim,nbPerm))),type='l',ylab="nbPerm index")
#the number of each classes per row are equal
#between observed community and the first null community
f_table = function(x) table(factor(x,levels=0:3))
all(apply(MAT,1,f_table)==apply(NULL_MATS$sim[[1]],1,f_table))
#the number of each classes per column are equal
#between observed community and the first null community
all(apply(MAT,2,f_table)==apply(NULL_MATS$sim[[1]],2,f_table))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.