# cor.matrix: Function to obtain the correlation between two matrices and... In SYNCSA: Analysis of Functional and Phylogenetic Patterns in Metacommunities

## Description

The functions cor.matrix and cor.matrix.partial are similar the function `mantel` and `mantel.partial`, although the significance of the statistics is evaluated differently from Mantel. The functions pro.matrix and pro.matrix.partial use symmetric Procrustes as a measure of concordance between data sets. The function cor.mantel is similar to the function `mantel`, but allows the use of a set of predefined permutation. For more details, see `syncsa`.

## Usage

 ``` 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 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143``` ```cor.matrix( mx1, mx2, x, my1 = NULL, my2 = NULL, y, permute.my2 = FALSE, method = "pearson", dist = "euclidean", permutations = 999, norm = FALSE, norm.y = FALSE, strata = NULL, na.rm = FALSE, seqpermutation = NULL, parallel = NULL, newClusters = TRUE, CL = NULL ) cor.mantel( dist.x, dist.y, method = "pearson", permutations = 999, strata = NULL, na.rm = FALSE, seqpermutation = NULL, parallel = NULL, newClusters = TRUE, CL = NULL ) cor.matrix.partial( mx1, mx2, x, my1 = NULL, my2 = NULL, y, mz1 = NULL, mz2 = NULL, z, method = "pearson", dist = "euclidean", permute.my2 = FALSE, permute.mz2 = FALSE, permutations = 999, norm = FALSE, norm.y = FALSE, norm.z = FALSE, strata = NULL, na.rm = FALSE, seqpermutation = NULL, parallel = NULL, newClusters = TRUE, CL = NULL ) cor.matrix2( mx1, mx2, x, y, method = "pearson", dist = "euclidean", put.together = NULL, permutations = 999, strata = NULL, na.rm = FALSE, seqpermutation = NULL, parallel = NULL, newClusters = TRUE, CL = NULL ) cor.procrustes( x, y, permutations = 999, strata = NULL, na.rm = FALSE, seqpermutation = NULL, parallel = NULL, newClusters = TRUE, CL = NULL ) pro.matrix( mx1, mx2, x, my1 = NULL, my2 = NULL, y, permute.my2 = FALSE, permutations = 999, norm = FALSE, norm.y = FALSE, strata = NULL, seqpermutation = NULL, parallel = NULL, newClusters = TRUE, CL = NULL ) pro.matrix.partial( mx1, mx2, x, my1 = NULL, my2 = NULL, y, mz1 = NULL, mz2 = NULL, z, permute.my2 = FALSE, permute.mz2 = FALSE, permutations = 999, norm = FALSE, norm.y = FALSE, norm.z = FALSE, strata = NULL, seqpermutation = NULL, parallel = NULL, newClusters = TRUE, CL = NULL ) pro.matrix2( mx1, mx2, x, y, put.together = NULL, permutations = 999, strata = NULL, seqpermutation = NULL, parallel = NULL, newClusters = TRUE, CL = NULL ) ```

## Arguments

 `mx1` Matrix that multiplied by mx2 results in the matrix x. `mx2` Matrix that when multiplied by mx1 results in the matrix x. See 'details' below. `x` Matrix that will be correlated with the matrix y. `my1` Matrix that multiplied by my2 results in the matrix y. `my2` Matrix that when multiplied by my1 results in the matrix y. See 'details' below. `y` Matrix that will be correlated with the matrix x. `permute.my2` Logical argument (TRUE or FALSE) to specify if realize parallel permutation in matrix my2. `method` Correlation method, as accepted by cor: "pearson", "spearman" or "kendall". `dist` Dissimilarity index, as accepted by vegdist: "manhattan", "euclidean", "canberra", "bray", "kulczynski", "jaccard", "gower", "altGower", "morisita", "horn", "mountford", "raup" , "binomial" or "chao". `permutations` Number of permutations in assessing significance. `norm` Logical argument (TRUE or FALSE) to specify if x is standardized within variables (Default norm = FALSE). `norm.y` Logical argument (TRUE or FALSE) to specify if y is standardized within variables (Default norm = FALSE). `strata` Argument to specify restricting permutations within species groups (Default strata = NULL). `na.rm` Logical argument (TRUE or FALSE) to specify if pairwise deletion of missing observations when computing dissimilarities (Default na.rm = FALSE). `seqpermutation` A set of predefined permutation, with the same dimensions of permutations (Default seqpermutation = NULL). `parallel` Number of parallel processes. Tip: use parallel::detectCores() (Default parallel = NULL). `newClusters` Logical argument (TRUE or FALSE) to specify if make new parallel processes or use predefined socket cluster. Only if parallel is different of NULL (Default newClusters = TRUE). `CL` A predefined socket cluster done with parallel package. `dist.x` Dissimilarity matrices of class dist. `dist.y` Dissimilarity matrices of class dist. `mz1` Matrix that multiplied by mz2 results in the matrix z. `mz2` Matrix that when multiplied by mz1 results in the matrix z. See 'details' below. `z` Matrix whose effect will be removed from the correlation between x and y. `permute.mz2` Logical argument (TRUE or FALSE) to specify if realize parallel permutation in matrix mz2. `norm.z` Logical argument (TRUE or FALSE) to specify if z is standardized within variables (Default norm = FALSE). `put.together` List to specify group of traits. Each group specify receive the same weight that one trait outside any group, in the way each group is considered as unique trait (Default put.together = NULL). This argument must be a list, see examples in `syncsa`.

## Details

The null model is based on permutations in the matrix mx2, typically the matrices B, U and Q, except in the function cor.mantel when the permutations are done in one of distance matrix.

Null model described by Pillar et al. (2009) and Pillar & Duarte (2010). For more details on the matrices and the null model, see `syncsa`.

## Value

 `Obs` Correlation between matrices. `p` Significance level based on permutations.

## Author(s)

Vanderlei Julio Debastiani <vanderleidebastiani@yahoo.com.br>

## References

Pillar, V.D.; Duarte, L.d.S. (2010). A framework for metacommunity analysis of phylogenetic structure. Ecology Letters, 13, 587-596.

Pillar, V.D., Duarte, L.d.S., Sosinski, E.E. & Joner, F. (2009). Discriminating trait-convergence and trait-divergence assembly patterns in ecological community gradients. Journal of Vegetation Science, 20, 334:348.

`syncsa`, `organize.syncsa`, `mantel`, `procrustes`