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
.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, ...)
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.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.dist
-object to vector is done in pcol
. If permcor
is run separately it has to bcor.test
, see help there for details. Defaults to Pearson correlation coefficients. Other options are Kendall and Spearman rank correlations.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.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.permcor
and mancor
. See details
for when it is appropriate to set via pcol
.details
) a subset of cases from x
and y
can be defined for correlation.for
-loop, loop = TRUE
) or be done by an apply
method (loop = FALSE
)? Determines speed. Fx
for mancor
.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 intplot.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.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 kpermcor
-object with the following items is returned:
cor.test
. }
permutations
. }
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.}trace
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).
x
andy
aredist
-objects, or vectors containing distance or similarity values and everything else is set to defaults a simple permuted correlation withpermcor2
is run. This corresponds to a Mantel test. The two data-objects are correlated withcor.test
, then they
is permuted and withcor
the correlation is calculated again and written to a vector. This is repeatedpermutation
times. 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.subsetter
is 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 betweenx
andy
.y
is itself a subsetting object (distance classes or so) you have to setsolo
=TRUE. Than the matrix or vector inx
is correlated against this classes. This is handled bymancor
. The parameterwidth
allows for the calculation of classes inside the function. If for instance a distance-matrix with geographical distances is given,width
specifies the width of the distance classes, they are computed and used to correlate the data inx
against. 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).mantel
for a different implementation of Mantel tests, cor.test
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