[R] randomisation
Jari Oksanen
jarioksa at sun3.oulu.fi
Wed Feb 9 15:00:31 CET 2005
On Wed, 2005-02-09 at 14:27 +0100, Yann Clough wrote:
> I am working on an ecological problem and dealing with a matrix where
> rows correspond to samples, and columns correspond to species.
>
> The values in the matrix are recorded abundances of the organisms.
>
> I want to create a series of randomised datasets where total
> abundances per sample (rowSums) and per species (colSums) are equal to
> those in the dataset of my observations.
>
> Simple example of the kind of thing I have:
>
> matrix(c(1,0,2,10,1,3,5,6,7,1,0,0),nrow=4, ncol=3,by=row) # observed
> data
>
> rowSums(tempmatrix) #individuals per location,
>
> colSums(tempmatrix) #individuals per species
>
> example of a matrix which complies with the two restrictions:
>
> tempmatrix2=matrix(c(1,0,2,11,0,3,5,6,7,0,1,0),nrow=4, ncol=3,by=row)
>
> rowSums(tempmatrix2)
>
> colSums(tempmatrix2)
>
> hope this is clear
>
As already explained, this may not be possible as a simple permutation.
You seem to have something else on your mind: moving individuals freely
between species instead of permuting data which means redistributing the
abundances among species instead of permutation.
For a traditional permutation, you may have a look at the labdsv package
(for ecological applications). This has function 'rndveg' which
"attempts to preserve either species occurrence distributions or plot-
level species richness." Preserving both may be impossible, but check
the function. The 'labdsv' source package is available at CRAN, and
Windows and MacOS X binaries through my web page
(http://cc.oulu.fi/~jarioksa/softhelp/softalist.html).
The Windows binary is not available at CRAN since the package fails R
CMD check in Windows (so you shouldn't check the package but just use
it). The Mac binary is not available at CRAN since the whole Mac binary
package system seems to be dysfunctional (there is nothing after Jan 19,
2005).
cheers, jari oksanen
More information about the R-help
mailing list