mcarlo {analogue}R Documentation

Monte Carlo simulation of dissimilarities

Description

Perumtations and Monte Carlo simulations to define critical values for dissimilarity coefficients for use in MAT reconstructions.

Usage

mcarlo(object, ...)

## Default S3 method:
mcarlo(object, nsamp = 10000,
       type = c("paired", "complete", "bootstrap", "permuted"),
       replace = FALSE, 
       method = c("euclidean", "SQeuclidean", "chord", "SQchord",
                  "bray", "chi.square", "SQchi.square",
                  "information", "chi.distance", "manhattan",
                  "kendall", "gower", "alt.gower", "mixed"),
       is.dcmat = FALSE, diag = FALSE, ...)

## S3 method for class 'mat':
mcarlo(object, nsamp = 10000,
       type = c("paired", "complete", "bootstrap", "permuted"),
       replace = FALSE, diag = FALSE, ...)

Arguments

object an R object. Currently only object's of class "mat" or species data sets allowed.
nsamp numeric; number of permutations or simulations to draw.
type character; the type of permutation or simulation to perform. See Details, below.
replace logical; should sampling be done with replacement?
method character; for raw species matrices, the dissimilarity coefficient to use. This is predefined when fitting a MAT model with mat and is ignored in the "mcarlo" method for class "mat".
is.dcmat logical; is "object" a dissimilarity matrix. Not meant for general use; used internally by "mat" method to instruct the "default" method that "object" is already a dissimilarity matrix, so there is no need to recalculate.
diag logical; should the dissimilarities include the diagonal (zero) values of the dissimilarity matrix. See Details.
... arguments passed to or from other methods.

Details

Only "type" "paired" and "bootstrap" are currently implemented.

distance and mat produce square, symmetric dissimilarity matrices for training sets. The upper triangle of these matrices is a duplicate of the lower triangle, and as such is redundant. mcarlo works on the lower triangle of these dissimilarity matrices, representing all pairwise dissimilarity values for training set samples. The default is not to include the diagonal (zero) values of the dissimilarity matrix. If you feel that these diagonal (zero) values are part of the population of dissimilarities then use "diag = TRUE" to include them in the permutations.

Value

A vector of simulated dissimilarities of length "nsamp". The "method" used is stored in attribute "method".

Note

The performance of these permutation and simulation techniques still needs to be studied. This function is provided for pedagogic reasons. Although recommended by Sawada et al (2004), sampling with replacement ("replace = TRUE") and including diagonal (zero) values ("diag = TRUE") simulates too many zero distances. This is because the same training set sample can, on occaision be drawn twice leading to a zero distance. It is impossible to find in nature two samples that will be perfectly similar, and as such sampling with replacement and "diag = TRUE" seems undesirable at best.

Author(s)

Gavin L. Simpson

References

Sawada, M., Viau, A.E., Vettoretti, G., Peltier, W.R. and Gajewski, K. (2004) Comparison of North-American pollen-based temperature and global lake-status with CCCma AGCM2 output at 6 ka. Quaternary Science Reviews 23, 87–108.

See Also

mat for fitting MAT models. roc as an alternative method for determining critical values for dissimilarity measures when one has grouped data.

plot.mcarlo provides a plotting method to visualise the distribution of simulated dissimilarities.

Examples

## continue from example(join)
example(join)

## perform the modified method of Sawada (2004) - paired sampling,
## with replacement
swap.mcarlo <- mcarlo(swapdiat, method = "SQchord", nsamp = 10000,
                      type = "paired", replace = FALSE)
swap.mcarlo

## plot the simulated distribution
par(mfrow = c(2,1))
plot(swap.mcarlo)
par(mfrow = c(1,1))

[Package analogue version 0.3-3 Index]