Learn R Programming

simba (version 0.3-2)

pcol: Permuted Correlation (on strata)

Description

The function is a wrapper for several functions related to the permuted correlation between matrices or vectors: It calls permcor2 to calculate permuted correlation between vectors and permcor to calculate permuted correlation on strata. This can be useful to obtain data-points for a multivariate Mantel correlogram. Two matrices or vectors and a variable dividing these vectors into strata (levels) are to be specified. If the last is not given only permuted correlation between the two matrices (dist-objects) is done. If the second matrix/vector is a subsetting object the correlation can be done on the first object for each of the strata with mancor.

Usage

pcol(x, y, z = NULL, method="pearson", permutations=1000, 
	solo=FALSE, ...)

permcor(x, y, subsetter, method="pearson", permutations=1000, alpha=0.05, trace=FALSE, ...)

permcor2(x, y, method="pearson", permutations=1000, subset=NULL, complete=TRUE, loop=FALSE, ...)

mancor(dis, classes, width=NULL, method="pearson", permutations=1000, alpha=0.05, trace=FALSE, ...)

## S3 method for class 'permcor': plot(x, y, ...)

Arguments

x
Matrix (dist-objekt) or vector of numeric values (atomic) containing distances or similarities returned by sim, vegdist,
y
If solo=FALSE an object of the same qualities and dimensions (or length) as x to correlate to. See Details for the case solo=TRUE. For the plotting method an optional object. Not needed here.
z
Vector or dist-objekt of a variable which defines the strata, or levels for which the permuted correlation shall be calculated. Doesn't have to be a factor but it has to be convertible into factor. see Details for more.
subsetter
Vector of a variable which defines the strata, or levels for which the permuted correlation shall be calculated. Usually conversion from dist-object to vector is done in pcol. If permcor is run separately it has to b
method
Method of correlation, as it is done by cor.test, see help there for details. Defaults to Pearson correlation coefficients. Other options are Kendall and Spearman rank correlations.
permutations
number of permutations, defaults to 1000 to get a significance level of p = 0.001.
solo
If TRUE y is assumed to be a subsetting matrix, dist-object or vector giving strata to correlate x with and calculate the data-points for a Multivariate Mantel Correlogram for one distance-matrix.
width
If solo=TRUE the subsetting object is assumed to contain classes already. If width is specified (defaults to NULL), the classes are defined inside the function and width gives the class width.
trace
Set to TRUE to follow the runs of the for-loops in functions permcor and mancor. See details for when it is appropriate to set via pcol.
complete
Should only complete cases be considered? Defaults to TRUE.
alpha
The initial alpha-level against which should be tested. Depending on sub-function it is internally changed via Bonferroni-correction if necessary.
subset
If Case is 1 (see details) a subset of cases from x and y can be defined for correlation.
loop
Triggers the method for permutation inside the function. Shall it be looped (for-loop, loop = TRUE) or be done by an apply method (loop = FALSE)? Determines speed. F
dis
Same as x for mancor.
classes
If mancor shall be run, second item is a vector or dist-objekt of a variable which defines the strata, or levels for which the permuted correlation shall be calculated. Doesn't have to be a factor but it has to be convertible int
permcor
(In plot.permcor) an object returned by permcor2 is easily plotted with plot.permcor. The actual correlation value is plotted against an histogram of the distribution of the permuted values.
...
Arguments to other functions, for instance to cor.test regarding specifications of the test, however only the correlation value is taken from this function. but here you could change from pearson to k

Value

  • Returns different objects, depending on given arguments and triggers.
  • case 1a permcor-object with the following items is returned:
    • call
    { The call to the function. } method{ The correlation method as used by cor.test. } statistic{ The initial correlation value which is tested against the permuted values. } signif{ The significance of the calculation. } n{ The number of cases. } permutations{ The number of permutations as specified by permutations. } perms{ The result of the permuted runs. It is not printed by default but can be accessed via result$perms. The correlation value can be plotted against an histogram of the distribution of the permuted values to visualize the significance with the default plotting method.}

encoding

UTF-8

item

  • case 2
  • method
  • gesN
  • strata
  • permutations
  • out
  • case 3

code

trace

itemize

  • call

Details

pcol is a wrapper for the other functions. Depending on the input and the setting of solo the following functions are invoked (They can also be run separately. In this case x, y, and z must be given as vectors).
  1. Ifxandyaredist-objects, or vectors containing distance or similarity values and everything else is set to defaults a simple permuted correlation withpermcor2is run. This corresponds to a Mantel test. The two data-objects are correlated withcor.test, then theyis permuted and withcorthe correlation is calculated again and written to a vector. This is repeatedpermutationtimes. Finally, the initial correlation value is compared to the permuted values. The number of times, the permuted values exceed the initial value is divided by the number of permutations to obtain a significance value. Thus, with 1000 permutations a minimum p of 0.001 can be tested.
  2. If asubsetteris given inz, the permuted correlation is done for every stratum or level given by the subsetting object - this could e.g. be direction or distance classes flagging which plots share a similar distance and therefore fall into the same class. The resulting data-points can be used to plot a correlogram which allows for the analysis of non-stationarity in the relationships betweenxandy.
  3. Ifyis itself a subsetting object (distance classes or so) you have to setsolo=TRUE. Than the matrix or vector inxis correlated against this classes. This is handled bymancor. The parameterwidthallows for the calculation of classes inside the function. If for instance a distance-matrix with geographical distances is given,widthspecifies the width of the distance classes, they are computed and used to correlate the data inxagainst. This produces the data-points for a multivariate Mantel correlogram in the sense of Oden & Sokal (1986) (see also Legendre & Legendre 1998 for a comprehensive coverage of the subject).

References

Legendre, P, & Legendre, L. (1998) Numerical Ecology. 2nd English Edition. Elsevier. Oden, N. L. & Sokal, R. R. (1986) Directional Autocorrelation: An Extension of Spatial Correlograms to Two Dimensions. Systematic Zoology 35: 608-617.

See Also

mantel for a different implementation of Mantel tests, cor.test

Examples

Run this code
data(abis)

## calulcate soerensen of species data
abis.soer <- sim(abis.spec)
## calculate distance (Euclidean) regarding some disturbance 
## variables (feces counts)
abis.pert <- dist(abis.env[,19:25])
## are compositional similarity and dissimilarity of disturbance related?
pcol(abis.soer, abis.pert)
## the relationship is significant, but not very strong

Run the code above in your browser using DataLab