Skip to contents

This version of the Mantel test supports asymmetric matrices and multiple partial-Mantel controls, a combination of features that is not possible using other widely available Mantel functions such as mantel.partial.

Usage

mantel_test(
  x,
  y,
  z = NULL,
  nperm = 999,
  method = "pearson",
  alternative = c("two.sided", "less", "greater")
)

Arguments

x, y

Square matrices (can be asymmetric).

z

Optional list of one or more square control matrices if partial Mantel is desired.

nperm

Number of random permutations to perform (positive integer).

method

Correlation method (see cor for details).

alternative

A character string specifying the alternative hypothesis, must be one of "two.sided" (default), "greater" or "less".

Value

A list with the following components:

  • `stat`: The correlation coefficient between x and y, measured on the data provided. This will be a partial correlation if z is specified.

  • `quantile`: The quantile of the observed stat in the null distribution.

  • `p.value`: Significance, derived from the combination of quantile and alternative.

  • `perm`: A vector of null correlations based on permuted data.

Examples

# A convenience function to generate symmetric matrices:
sym_matrix <- function(x){
   n <- which(cumsum(1:100) == length(x)) + 1
   m <- matrix(0, n, n)
   m[lower.tri(m)] <- x
   m[upper.tri(m)] <- t(m)[upper.tri(t(m))]
   m
}

# Simulate some example data:
g <- runif(45)
w <- runif(45)
d <- runif(45)
e <- sample(0:1, 45, T)
G <- sym_matrix(g) # e.g. a genetic matrix
W <- sym_matrix(w) # e.g. a wind matrix
D <- sym_matrix(d) # e.g. a distance matrix
E <- sym_matrix(e) # e.g. an environment matrix

# Basic function usage:
mantel_test(G, W)                      # simple first-order Mantel
#> $stat
#> [1] 0.2032017
#> 
#> $quantile
#> [1] 0.9029029
#> 
#> $p.value
#> [1] 0.1941942
#> 
#> $perm
#>   [1] -7.040181e-02  5.703115e-02  1.758472e-01 -5.935805e-02 -3.899616e-01
#>   [6] -1.977872e-02 -8.709134e-02  1.505822e-01  1.431161e-01 -9.017803e-02
#>  [11]  1.787614e-01  2.371096e-02  1.463993e-01  1.004909e-01  7.387973e-03
#>  [16]  1.161808e-01  1.529255e-02 -1.549854e-01  4.598148e-02 -1.900230e-01
#>  [21] -1.199129e-01  4.819223e-02  1.664168e-01  2.114942e-01 -1.714741e-01
#>  [26] -1.931238e-01 -5.696893e-02  7.521367e-02  1.554733e-03 -1.359946e-01
#>  [31] -7.135428e-02  6.084734e-02 -3.208175e-02 -3.668626e-02  2.351264e-02
#>  [36] -2.326823e-02  1.089449e-01  6.341950e-02  9.041024e-02 -1.502366e-01
#>  [41]  1.636009e-01 -2.120984e-02 -2.963628e-02  2.596701e-02 -1.028775e-01
#>  [46]  1.000119e-01  1.683786e-01 -1.640363e-01 -9.961665e-02 -7.165014e-02
#>  [51] -1.289057e-01  8.958642e-03  3.238882e-01  2.534983e-01  1.543583e-01
#>  [56]  1.309892e-01  2.090650e-01  6.167744e-02  1.415874e-01  6.697813e-02
#>  [61]  9.083307e-02  2.243315e-01 -2.309226e-01 -1.278319e-01  1.146669e-02
#>  [66]  7.940387e-02  6.310160e-02 -1.211240e-01 -1.971159e-02 -7.457412e-02
#>  [71] -1.967227e-01 -1.543563e-01 -1.458993e-02  1.597367e-01  1.950420e-01
#>  [76] -2.931934e-01  2.166722e-01 -1.167232e-01 -6.826388e-02 -5.665301e-02
#>  [81]  5.569422e-02 -4.248871e-02  4.525774e-01 -1.432084e-02 -2.683105e-01
#>  [86]  1.364398e-01  4.900837e-01 -9.187155e-02  1.318709e-01 -7.369699e-02
#>  [91]  4.518016e-02  1.356006e-01  1.839213e-01 -6.641869e-02 -3.359209e-02
#>  [96] -2.412640e-02 -1.559632e-01 -1.266096e-01  2.527662e-01  2.874494e-01
#> [101]  3.030254e-01  2.857109e-01 -1.053340e-01  8.166884e-02  2.042995e-01
#> [106] -5.890884e-02 -9.854232e-02  2.886857e-02  1.257243e-02  1.507724e-01
#> [111] -1.143212e-01 -9.673929e-03  9.167489e-02  6.518834e-03  2.931153e-02
#> [116]  1.799270e-01 -2.323416e-02 -8.030546e-02 -4.441246e-04 -1.547259e-02
#> [121]  1.224397e-01 -2.119941e-01 -1.032524e-01  2.267331e-01 -1.134537e-01
#> [126]  1.159205e-01  2.185216e-01  1.572780e-01 -3.863889e-01 -1.582043e-01
#> [131]  9.910065e-04 -5.323873e-02  2.267365e-01 -1.752229e-01  6.510006e-03
#> [136] -1.427790e-01  1.276415e-01  1.362710e-01  1.969218e-01 -3.072891e-03
#> [141] -8.969896e-02  2.111379e-01 -1.425738e-01 -1.574836e-01 -1.774200e-01
#> [146]  9.671674e-02  8.754024e-02  2.371187e-01 -3.543545e-01  1.702680e-01
#> [151] -2.505928e-01  1.868798e-02  8.577452e-02  1.748415e-01  3.364380e-02
#> [156] -2.668725e-02 -7.541959e-05  1.043142e-01  1.022882e-02 -2.824332e-01
#> [161] -1.197197e-01 -2.020695e-01  1.684163e-01  3.348422e-02 -2.779028e-01
#> [166] -7.313519e-02 -2.425032e-02  9.351595e-02 -1.568189e-02 -1.252412e-01
#> [171] -2.227918e-01  6.503147e-02 -2.231141e-01 -1.565356e-01 -1.560696e-02
#> [176] -1.378015e-01  2.823521e-01  3.448275e-02  1.667627e-01  2.226618e-01
#> [181]  3.887875e-02  2.704106e-01 -2.527561e-02  2.414797e-01 -2.813296e-01
#> [186] -6.576568e-02  8.487600e-02 -1.645264e-01  7.973693e-02  1.986710e-01
#> [191]  1.647334e-01 -3.131382e-01  1.330945e-01  1.194464e-01 -1.047309e-01
#> [196] -2.404879e-01  1.541824e-01 -2.798783e-03  2.438602e-01  1.757268e-01
#> [201] -9.170756e-02  1.378972e-01 -2.024047e-02  5.942005e-02 -5.477197e-02
#> [206]  6.527875e-02  9.879784e-02  4.016893e-02 -2.409714e-01  8.032584e-02
#> [211]  8.841466e-02  3.086456e-02 -5.801283e-02 -1.328756e-01 -1.074092e-01
#> [216]  1.182164e-01  7.715371e-02 -1.765779e-01  7.456027e-02 -1.072063e-01
#> [221] -2.530240e-01 -9.530393e-03  1.772527e-01  9.786330e-02 -5.245106e-02
#> [226]  1.086471e-01 -2.037698e-01  2.630410e-01  5.904273e-02  2.883100e-02
#> [231]  1.984661e-01 -1.928895e-02  6.682780e-02  2.459478e-02  3.866403e-03
#> [236] -1.069279e-01 -2.008744e-01 -1.621489e-01  1.414434e-02 -3.520013e-01
#> [241]  1.539633e-01 -2.512919e-01  2.038660e-01 -1.247375e-01 -1.536635e-01
#> [246]  1.317086e-01  1.662456e-01  2.882784e-01  5.675199e-02  2.679492e-01
#> [251] -1.007816e-01  5.689208e-02  1.772550e-02  1.897048e-01  1.019304e-01
#> [256] -4.875596e-02  5.441606e-02  3.865644e-02 -2.898863e-02  1.578611e-01
#> [261]  2.722328e-01 -3.028867e-01  3.797490e-02  4.192030e-01 -5.520883e-02
#> [266] -3.612216e-01  1.765423e-01  6.401828e-02 -6.559541e-02  7.374541e-03
#> [271] -1.716742e-01 -1.967810e-02 -2.806238e-01  6.927236e-02  1.396768e-01
#> [276]  1.337792e-01  8.743651e-02 -3.299798e-02 -1.047830e-01  8.451350e-02
#> [281]  2.002232e-01  1.123347e-01  2.382004e-01 -5.763105e-02 -1.187112e-01
#> [286] -7.403255e-02  7.285814e-02  2.483369e-01 -2.052386e-01  2.203727e-02
#> [291]  2.647861e-02 -1.557612e-01 -3.530252e-01  7.412092e-02  1.291852e-01
#> [296] -1.555003e-01  5.633971e-02 -2.111099e-01  2.316723e-01 -1.106807e-01
#> [301] -1.866387e-01  5.321399e-02  2.545971e-02 -4.286505e-03  7.830461e-03
#> [306]  8.738282e-02 -1.387987e-01  8.767342e-02 -1.864614e-01  1.886244e-02
#> [311] -4.203637e-02 -3.720877e-03  2.045676e-01 -4.927008e-01 -1.484221e-01
#> [316] -1.211668e-01  2.305549e-01  2.368154e-02 -1.243000e-01 -1.512812e-01
#> [321] -2.832940e-02 -2.682103e-02 -8.664289e-02 -7.957099e-02 -2.937581e-02
#> [326]  9.947271e-03  2.507693e-03  1.207042e-01  7.582534e-02 -2.723726e-02
#> [331]  3.140351e-01 -1.229353e-01 -8.105996e-02 -8.239820e-02  6.236878e-02
#> [336] -1.533307e-01 -7.605261e-02 -1.876137e-01  6.999720e-02  3.988080e-02
#> [341]  3.113657e-02  4.479432e-02  4.808958e-02  1.897958e-02  3.079527e-02
#> [346]  1.240139e-01 -1.381041e-01 -8.524955e-02 -4.772725e-02  6.709978e-02
#> [351]  3.271128e-01  1.119427e-01 -1.154521e-01  1.138932e-01  1.576264e-01
#> [356]  8.698536e-03 -1.307985e-01 -1.054747e-01 -2.369856e-02  2.182585e-01
#> [361]  1.859686e-01 -2.129762e-02  8.567886e-02  7.306964e-02  8.818533e-03
#> [366]  3.906011e-02  7.510136e-02 -2.149455e-03  1.634025e-01 -2.247536e-01
#> [371] -2.765321e-01 -1.134141e-01  7.716946e-02 -4.664702e-02  1.192798e-01
#> [376] -1.267360e-01 -2.405159e-01 -2.699123e-01  6.693136e-02 -5.438827e-02
#> [381]  1.954131e-01  3.292238e-01  8.209656e-02 -1.139246e-01  8.174112e-03
#> [386]  2.277794e-01  6.614037e-02 -7.106673e-02 -6.241494e-02 -1.951650e-01
#> [391] -1.215568e-01  1.069345e-01 -1.204196e-01  2.654831e-01  1.290602e-01
#> [396]  2.690078e-02  3.486555e-01 -5.792850e-02 -1.626203e-01  1.022154e-02
#> [401] -2.986878e-01 -1.207510e-01 -9.641351e-03  1.615593e-01 -2.635274e-02
#> [406]  1.260184e-01 -1.987948e-01 -2.290616e-01 -2.188921e-03 -2.792668e-02
#> [411] -1.078600e-01  1.780323e-01 -2.132353e-02 -6.545400e-02 -3.831066e-02
#> [416]  2.284082e-01 -3.022993e-01  1.720562e-01  2.606752e-01  2.294465e-01
#> [421] -2.103185e-01  1.331457e-01  1.788440e-02  1.088833e-01 -2.259132e-01
#> [426] -1.897909e-02  1.051861e-01 -1.161651e-01 -6.953095e-02 -1.405165e-01
#> [431]  1.091515e-01 -1.436959e-01  6.028659e-02 -2.964621e-01 -2.512329e-01
#> [436] -4.443750e-02  3.880744e-02 -4.172057e-02  5.783852e-02  4.291564e-02
#> [441] -2.141494e-01 -2.632249e-02 -1.964174e-01  2.291020e-02  1.937772e-01
#> [446]  9.953796e-02 -1.122874e-02  1.213618e-01 -1.107548e-02 -5.346734e-02
#> [451] -2.030754e-01  8.362912e-03  1.246223e-01 -1.488865e-01 -8.709173e-02
#> [456] -2.498957e-02 -2.582661e-01  5.048911e-02 -1.971914e-01 -3.208577e-02
#> [461]  2.420021e-01 -6.658602e-02  8.441415e-02 -2.591195e-02 -1.523346e-01
#> [466]  9.037859e-02 -1.328608e-02 -1.471999e-01  2.584246e-01 -1.853257e-02
#> [471]  1.405640e-01 -3.498001e-03 -8.403164e-02 -1.272959e-01  5.089121e-02
#> [476] -3.068927e-01 -1.324195e-01  2.590378e-01 -8.228346e-02 -7.101177e-02
#> [481] -1.057969e-01 -7.516991e-02  8.891963e-03  1.257279e-01  9.287896e-02
#> [486]  1.382040e-01  1.413104e-01 -1.564521e-01 -2.088959e-01  1.603397e-01
#> [491] -2.725714e-01  8.598054e-02 -6.564822e-02 -2.298544e-02 -7.480892e-02
#> [496]  1.860817e-01 -2.152641e-02 -1.652144e-01  1.264263e-01 -1.619117e-01
#> [501] -1.123389e-01  1.044631e-01  1.647309e-02 -1.523481e-02 -2.146707e-01
#> [506]  2.287738e-01 -1.811210e-03 -2.477613e-01  6.346682e-02  2.820035e-01
#> [511]  2.694700e-02  9.028229e-02  1.981545e-01 -2.692924e-01 -1.077517e-01
#> [516] -2.767031e-01  1.689552e-01  1.813697e-01 -4.121659e-02  1.456606e-01
#> [521]  5.832700e-02  6.600261e-02 -5.707664e-02 -1.186505e-01 -1.787121e-01
#> [526]  2.815006e-01  1.267667e-01  1.578598e-01 -3.472998e-02  2.266188e-01
#> [531]  1.098372e-01  1.594698e-01  4.211224e-01  9.586160e-02 -7.483387e-04
#> [536]  2.864636e-01 -2.270091e-02 -1.460110e-01  2.275226e-01 -8.746961e-02
#> [541] -1.133227e-01 -2.291289e-02  7.849345e-02  2.349803e-01 -1.794906e-01
#> [546] -2.586948e-01  1.403276e-01  1.183079e-02 -1.396055e-01  7.808363e-02
#> [551]  1.063125e-01 -4.220401e-01  1.464612e-02 -3.362409e-02 -2.073723e-01
#> [556]  9.091394e-03  1.364137e-01  1.630225e-02  2.307328e-01  2.496038e-02
#> [561] -5.570331e-02  2.053024e-01 -1.259982e-01 -1.471465e-01  3.101776e-01
#> [566] -1.961246e-02  4.498046e-02 -2.018796e-01  1.909929e-02 -2.320622e-01
#> [571]  2.869805e-02 -1.713872e-02 -1.801125e-01 -1.612864e-01 -5.546398e-03
#> [576]  6.038912e-02 -1.437524e-01  1.994059e-01  1.815415e-01 -2.360273e-01
#> [581] -5.235446e-02 -1.013026e-01 -8.988846e-04  3.898752e-01 -4.171430e-02
#> [586] -7.712305e-02  3.141326e-01 -3.904412e-03 -1.856704e-01 -3.848648e-01
#> [591] -3.728569e-02  4.388567e-02  1.136639e-02  6.049728e-02  2.089753e-03
#> [596]  2.849314e-01  9.676979e-02 -5.654563e-02 -1.813238e-01  1.048145e-01
#> [601] -2.189282e-01  1.984295e-01  1.096637e-01 -4.518522e-02  1.470109e-01
#> [606] -7.061073e-03 -1.658644e-01  1.979829e-01 -3.557187e-02 -1.230677e-01
#> [611]  1.049288e-02  1.465329e-01 -8.503816e-02  1.285896e-03 -4.580217e-02
#> [616]  1.246080e-01  1.598883e-02 -4.952389e-01  3.499194e-02  2.466964e-01
#> [621]  1.478024e-01 -1.159585e-01  2.538613e-02  1.878332e-02 -5.006911e-02
#> [626]  2.523359e-01 -2.309812e-02 -2.647576e-01 -2.436751e-01 -1.588842e-01
#> [631]  2.839360e-02  1.371976e-01  1.152017e-01 -7.330663e-02  3.609668e-01
#> [636] -9.550077e-02 -2.615397e-01  3.777297e-02 -1.238876e-01  2.074703e-01
#> [641] -2.400256e-01  1.320047e-01 -1.605804e-02  1.829484e-02  2.230869e-02
#> [646] -5.155446e-04  7.832770e-02  1.302910e-02  5.672601e-02 -3.837795e-01
#> [651]  4.795964e-02 -1.354758e-01  1.263651e-01  2.044857e-01  4.304021e-02
#> [656] -2.063442e-02 -1.065638e-01 -3.089880e-01  2.748164e-01 -1.455847e-01
#> [661]  6.374098e-02 -1.983036e-01 -1.666178e-01  4.601631e-02 -5.779098e-02
#> [666]  3.748327e-02 -1.449826e-01  5.291080e-02  8.611377e-02  4.207087e-02
#> [671] -4.326815e-03 -4.445872e-02  2.110581e-01  3.924309e-02  4.753135e-02
#> [676]  2.148039e-02  2.331083e-01  1.150346e-01 -8.199000e-02  3.878973e-03
#> [681]  1.521831e-01 -4.128005e-02  8.296133e-02  5.811737e-02  2.195515e-01
#> [686] -1.789562e-02  9.440136e-02 -8.627600e-02 -7.175364e-02  3.682556e-01
#> [691] -9.473000e-03 -3.355245e-02 -1.995166e-01 -1.892538e-01  2.356837e-02
#> [696]  2.044893e-01 -2.305294e-01 -8.248880e-02 -9.618869e-02 -1.251547e-03
#> [701]  2.364905e-01  2.233485e-01  1.069178e-01  2.440146e-01 -7.344790e-02
#> [706]  1.219322e-01 -1.369726e-01  1.074644e-01  1.503408e-02 -1.325092e-01
#> [711]  2.929335e-02 -2.081486e-01 -2.287590e-01  2.032739e-01  6.524208e-02
#> [716]  5.804683e-03 -7.805171e-02 -1.793961e-01  1.738303e-01  2.370888e-01
#> [721] -1.608493e-02 -1.340006e-01  1.962420e-01 -1.794356e-02  1.305471e-01
#> [726] -7.332396e-02 -1.545662e-01  6.304413e-02 -5.442081e-02  4.667685e-02
#> [731] -8.112509e-02  2.881401e-02 -2.333021e-01  9.845400e-02 -2.621785e-01
#> [736] -1.954675e-01  3.565764e-01 -1.730795e-01  1.397483e-01  4.936352e-02
#> [741] -1.791970e-01  2.148488e-01  3.022758e-01  9.232248e-04  1.014086e-01
#> [746] -3.870073e-02  1.099768e-01  1.025849e-02  6.861260e-02 -8.034994e-02
#> [751]  1.286068e-01 -6.050777e-02 -6.600065e-02  7.531361e-02 -3.632543e-02
#> [756] -2.043591e-01  1.146263e-01 -1.444550e-01  2.038087e-01  3.003926e-03
#> [761]  1.042358e-01 -5.504682e-02  1.185001e-01 -1.651719e-01 -2.453910e-01
#> [766] -2.253174e-01  6.958807e-02  4.523149e-02 -6.893773e-03 -1.128219e-01
#> [771] -5.419405e-02  5.602868e-02  1.971586e-01 -4.911284e-02  7.600703e-03
#> [776] -8.962802e-02  2.489049e-02  9.982437e-02 -2.679307e-01  1.028852e-02
#> [781] -2.277010e-01  1.855116e-02 -6.599819e-02  1.833694e-02  1.039955e-01
#> [786] -1.312829e-01 -8.847896e-02  1.459896e-01 -1.126309e-01 -1.717308e-01
#> [791] -5.537863e-03 -4.690600e-02 -1.515600e-01 -1.503922e-01 -2.478706e-02
#> [796]  4.482241e-02  7.642626e-02  9.083806e-03  2.519835e-01  3.535026e-02
#> [801]  6.291819e-03 -1.219710e-01  8.387276e-02  3.510563e-01  2.015717e-01
#> [806] -7.484187e-02  7.131356e-02  1.589896e-02 -4.293338e-02 -5.157095e-03
#> [811]  1.901221e-02  8.893712e-03  2.242997e-01  4.490936e-03 -6.615791e-02
#> [816]  3.425919e-02 -2.190750e-01  2.150586e-01  9.609461e-02  1.678585e-01
#> [821] -1.313682e-01 -1.687163e-01 -1.153336e-01 -8.202440e-02 -2.619619e-01
#> [826]  1.121898e-01 -7.857227e-02  1.481776e-01  9.571906e-02  1.275671e-01
#> [831]  8.622325e-02  2.488788e-01  1.660581e-02 -1.675716e-01  6.206702e-02
#> [836] -5.103216e-02  6.507733e-02 -2.751246e-02 -1.910802e-01  1.363568e-01
#> [841] -1.695604e-01  2.723982e-02  1.318164e-01 -3.929733e-01  6.899047e-02
#> [846]  1.179169e-01  1.226527e-01  4.355057e-02 -4.439098e-02 -2.380272e-01
#> [851]  1.379625e-01  1.256730e-01 -1.552716e-01  1.823805e-02  1.582456e-01
#> [856] -9.139053e-02  1.728374e-01 -2.087384e-01 -6.422170e-02  4.684295e-02
#> [861] -2.314596e-01  7.653890e-02  1.265276e-01  1.036884e-01  9.459408e-02
#> [866] -2.357261e-02 -1.602353e-01 -6.036052e-02  1.400434e-02  1.431005e-02
#> [871]  1.436369e-01  1.473619e-01 -1.567127e-01 -9.279721e-02 -1.361578e-01
#> [876] -2.052804e-01 -2.219138e-01  2.321758e-01 -2.873775e-02 -6.456348e-02
#> [881] -1.169576e-01  7.018566e-02  3.403542e-02 -7.242968e-02  2.165127e-01
#> [886] -4.249742e-03  7.858339e-02 -6.611482e-02 -6.223243e-02 -8.524732e-02
#> [891] -2.910338e-02  7.798996e-02  1.644188e-01  7.856695e-02  3.186238e-01
#> [896] -3.279185e-02  1.095829e-01 -5.737946e-02  1.722205e-01  1.590644e-01
#> [901] -2.788800e-01  3.159674e-01  2.000704e-02 -4.956154e-02  3.483382e-01
#> [906] -6.121853e-04  4.624555e-02  2.085094e-02 -6.056279e-02  1.001764e-01
#> [911] -2.155983e-02  6.199471e-02 -2.366424e-01 -7.609943e-02 -1.120201e-01
#> [916]  6.948154e-02  2.578549e-02 -4.572955e-02 -3.234597e-02  5.488907e-02
#> [921] -1.681404e-01 -8.803954e-02  1.431247e-01 -3.352291e-01 -2.433649e-01
#> [926]  1.557310e-01 -2.914253e-01 -1.896421e-01 -9.267135e-02  1.491611e-01
#> [931] -2.314588e-04 -7.406222e-02  1.695939e-02 -2.559635e-01  2.258197e-01
#> [936]  2.880090e-01  1.202040e-01 -7.799693e-02 -1.410049e-01 -2.636154e-02
#> [941] -2.045331e-02  1.748218e-01 -1.402229e-01  3.877803e-01 -2.891913e-01
#> [946] -3.181804e-01 -2.148396e-01  6.873841e-02  1.243349e-02  1.306079e-01
#> [951]  6.893929e-02  1.261417e-01 -2.611970e-01 -2.686039e-01 -1.303599e-01
#> [956] -2.705427e-02  1.625260e-01 -2.763857e-01  9.063434e-03  9.153612e-02
#> [961]  1.304950e-01 -3.359602e-02 -2.169383e-01 -1.307847e-01 -1.981330e-02
#> [966]  9.219473e-02 -2.653273e-03 -2.984554e-01  2.492289e-02  7.637776e-02
#> [971] -2.183159e-01  1.012218e-02 -1.369621e-01 -2.680999e-02  2.421705e-02
#> [976] -9.076378e-02 -1.674180e-01 -7.740038e-02 -1.838957e-01  3.616280e-01
#> [981] -1.974368e-01  1.045149e-01  8.073621e-02 -1.532506e-01  5.115590e-02
#> [986] -6.337041e-02 -7.264289e-02 -7.737859e-02  3.174546e-01  1.040617e-01
#> [991] -2.532154e-01 -1.784139e-01 -1.430085e-01 -5.971928e-02  1.128979e-01
#> [996] -8.437456e-02  8.061966e-03  1.040676e-01  3.731498e-01
#> 
mantel_test(G, W, list(D, E))          # partial Mantel
#> $stat
#> [1] 0.2025118
#> 
#> $quantile
#> [1] 0.8968969
#> 
#> $p.value
#> [1] 0.2062062
#> 
#> $perm
#>   [1] -0.1425882464  0.1601213573  0.0968741488  0.2442176837  0.0776700505
#>   [6]  0.1320432119  0.0114451080  0.1457484987 -0.1461071074 -0.3031452179
#>  [11] -0.2739129207  0.2471280682 -0.0891225514 -0.1656708157  0.0564016320
#>  [16] -0.0038230820 -0.0164392443  0.2682491959 -0.0102003470  0.0127250716
#>  [21] -0.0278733669 -0.0811120244 -0.0656896800 -0.0310143215 -0.0183574548
#>  [26]  0.0926036132  0.0804982588  0.0803797558 -0.0981769925  0.1254347893
#>  [31]  0.0476487536 -0.0801332058 -0.1479116330  0.0989798372 -0.0029632680
#>  [36]  0.1846302834 -0.5874430140  0.2058715816 -0.0514736709  0.0215344361
#>  [41] -0.0149487614  0.2082507691  0.1869498940  0.1962063959  0.0016997769
#>  [46] -0.0423614206 -0.2018763386  0.0231747740 -0.0420582424  0.1813778321
#>  [51]  0.3045173323 -0.0164753717  0.0878456028  0.0474943551 -0.2200081353
#>  [56]  0.0107637117  0.1257540414  0.0747980661 -0.4424628195 -0.0973289748
#>  [61] -0.0505778222  0.0949275567  0.0368759667  0.1313833615 -0.1088910959
#>  [66] -0.3608417187  0.0159072134  0.0779159951 -0.1501161417  0.1313974238
#>  [71]  0.4045522694 -0.2168650091  0.3230011987 -0.0341174055  0.1613834711
#>  [76] -0.2016673494 -0.0269646103 -0.1178553289 -0.3112992349  0.0794212092
#>  [81] -0.2052588858 -0.1650499496  0.0577621099  0.0097751494  0.0584599888
#>  [86]  0.0507245623 -0.3670774258 -0.2790095750 -0.0054530365  0.0485414490
#>  [91] -0.1787231641  0.4661754760 -0.1004119559 -0.2028383490  0.2941859256
#>  [96] -0.0535056099 -0.2153639729 -0.2394188539 -0.0531527531 -0.0438199329
#> [101]  0.0713762910  0.3590613950 -0.0200769350  0.3867244826  0.0661279255
#> [106] -0.2862471666  0.1579161464  0.0378277348  0.0417594776  0.0761400929
#> [111] -0.1239476806  0.0106885206  0.3666974240 -0.0700748051 -0.2330580763
#> [116] -0.0919230664 -0.2252747144  0.0283639754 -0.1051333468 -0.3244085771
#> [121] -0.0263535724  0.0741879183  0.1055712132 -0.1345142765 -0.1892173907
#> [126]  0.0771576057  0.1084193108  0.1196644653  0.0035283903  0.1109497527
#> [131] -0.2187721127 -0.1565779592 -0.1301431093  0.0454257837  0.0220736639
#> [136] -0.1838307902  0.0324284251  0.0877432167  0.2569265420 -0.0692069115
#> [141]  0.3004097637  0.0646879007 -0.0132228420  0.1431315974 -0.1915323540
#> [146]  0.2251479403  0.3776113818  0.0710122282 -0.1146296304  0.0399462267
#> [151] -0.2122568773 -0.1503564176 -0.0580751670 -0.2002087952  0.2260165159
#> [156]  0.1444762670  0.0641183855  0.0182897385 -0.2389097056 -0.0750823701
#> [161]  0.2158986153  0.2390959838 -0.1590402247  0.3495483080  0.1847217688
#> [166]  0.2465062178 -0.0182747901  0.2613241269 -0.0574495358 -0.1470148064
#> [171]  0.1996481036  0.0073579154  0.0863391667  0.1342447404 -0.0010825913
#> [176]  0.1826801058 -0.0357448005 -0.2468843055 -0.2489175747 -0.1807064417
#> [181]  0.0988270438  0.2009989266 -0.0031187740  0.0097629043  0.0317496035
#> [186]  0.1743554531 -0.0034573940  0.1752948713 -0.0981868796  0.1178442082
#> [191] -0.2681674558  0.1961767200  0.4063904744  0.1691805454  0.0808604299
#> [196] -0.0329984275  0.2891393806 -0.0259286195 -0.1471333874 -0.2043685219
#> [201]  0.0710893819  0.0281081799  0.1262396963  0.0554480315 -0.0477013095
#> [206] -0.2667560565  0.1419306621 -0.0518668492 -0.0003907990 -0.2125363572
#> [211] -0.2385625908 -0.1234805273 -0.0539344574  0.0878959583  0.2765525696
#> [216] -0.1298353180 -0.1946250847 -0.0340958809 -0.0240860906  0.1397771786
#> [221] -0.0198253435  0.1755970029  0.0933697742 -0.0118890645  0.0506338104
#> [226]  0.2395600953 -0.0420128182  0.1087511737  0.1675004257 -0.0386216933
#> [231]  0.0126600228  0.1458147194 -0.0056054954 -0.0361881527  0.1426913890
#> [236]  0.1377211385 -0.0938479563 -0.2152983468 -0.1380376017  0.0383587006
#> [241]  0.1880919625 -0.1757844211  0.1669638914  0.0329202197  0.0802883135
#> [246] -0.1118974608  0.1292716100  0.0964443309  0.0063307656 -0.0115459587
#> [251] -0.1166479843  0.0839054344 -0.0786653952 -0.2570234522  0.1770722448
#> [256]  0.0805394599  0.2000004115  0.0780887055 -0.2052617007 -0.0315228570
#> [261]  0.1510442651 -0.0467578725 -0.1758293891 -0.1623225153 -0.1036330848
#> [266] -0.0293813824 -0.1223996661 -0.0713230451  0.1706700337  0.1913365137
#> [271]  0.2242644203 -0.0457167615 -0.1895802471 -0.1793230755 -0.1785128837
#> [276] -0.1022320805 -0.0676419187  0.0809577264 -0.1366006300 -0.0824958864
#> [281]  0.2187775739 -0.0480341467 -0.0834647988  0.1903855937 -0.0359776912
#> [286]  0.0400382189 -0.0771632718  0.0881157320 -0.1735273797 -0.1855535718
#> [291]  0.1741512876  0.1061985189 -0.0732524369 -0.3260072497  0.1126962438
#> [296]  0.0093354789  0.0286517458 -0.1279837590  0.2308232870 -0.0133142557
#> [301]  0.0122422060  0.0009586576  0.0119333361  0.0224135381  0.1801591900
#> [306] -0.0124805247  0.0284387298 -0.0828106394  0.2300355265  0.0100505667
#> [311]  0.1076125635  0.0927435405  0.2164187475 -0.1852435911  0.2866579190
#> [316]  0.1992140233 -0.2037456969 -0.1829283369 -0.0133997083 -0.0017146845
#> [321] -0.0169009629  0.0672053516  0.1277924571 -0.1182200547 -0.0529232670
#> [326] -0.1055026636 -0.1328605147 -0.1935014498  0.2127159119  0.0247770090
#> [331] -0.2285091953 -0.0534322337 -0.2438742030  0.0745963749 -0.3309807291
#> [336]  0.0137313697 -0.1946182561  0.1774681534  0.1153815575  0.1270684568
#> [341] -0.0645341878  0.0182128978 -0.2707839898 -0.1449750831 -0.1683763237
#> [346]  0.2199713222 -0.2008679031  0.0007657786 -0.1400470661 -0.1395850205
#> [351] -0.2351091094 -0.0779386648 -0.0239293046 -0.1048414141  0.1364989837
#> [356]  0.1626893599 -0.1899563722 -0.0465742627 -0.0322331624 -0.0278988040
#> [361] -0.1658153057 -0.0275158310  0.1537968140  0.1499868959 -0.1194917687
#> [366]  0.1934262521 -0.0969070794  0.2077145674 -0.1226457813  0.0022145575
#> [371] -0.2370084197  0.1313053233  0.1315694650 -0.0733716725 -0.2572455691
#> [376]  0.1107609596  0.3299960282  0.1262486871 -0.1691934454 -0.2229531254
#> [381] -0.1762932490 -0.3675021164 -0.1144983765 -0.0493293503 -0.0738650606
#> [386] -0.2092359568  0.0170270106  0.0249828847 -0.1957986810 -0.1393255186
#> [391] -0.0544841633 -0.0640563973  0.0098758883  0.1166610350  0.2716463144
#> [396]  0.0070654266 -0.0531230044  0.3290365557 -0.1440570401 -0.0313405274
#> [401] -0.0193994798  0.0178177881 -0.1324427226 -0.1872620376  0.2134951114
#> [406]  0.0217061123 -0.0639554737 -0.2233968186 -0.0136220113  0.1306149668
#> [411] -0.0534805974  0.0350210368  0.2994779428 -0.3232857722 -0.1842616205
#> [416]  0.2685487385 -0.0036889199  0.2475340252 -0.0349379640 -0.0630363010
#> [421] -0.0439516899  0.0806011119  0.1412807163 -0.0452425469 -0.1988790174
#> [426]  0.1178190813 -0.1618833357 -0.1143057677  0.1653996586  0.1734398432
#> [431]  0.1382071655 -0.2071544396 -0.2786420094  0.1376544216 -0.2724953340
#> [436] -0.1223134607  0.0089930462 -0.0264059636  0.1039167651 -0.1925263997
#> [441]  0.0428270611  0.1638663705 -0.1695183215 -0.1174904571 -0.2444690448
#> [446] -0.1289630211 -0.1797281105 -0.1059604528  0.1223291820  0.2756685257
#> [451] -0.0363431054 -0.0776099494 -0.0474393453 -0.0623721781 -0.2376353740
#> [456] -0.1008502953  0.2382903918  0.0970943864 -0.1472289647  0.3566332418
#> [461] -0.1013205071  0.1626285405  0.1470880094 -0.1530265361 -0.1069422385
#> [466]  0.1743560118  0.2220959530 -0.2452860026  0.1878715825 -0.1516855051
#> [471] -0.1985496752  0.1887129173 -0.0139267797 -0.1738750163  0.2499834144
#> [476]  0.3489962250 -0.2055557237 -0.3019061668  0.0156114436 -0.1482344743
#> [481]  0.1585963613 -0.1884890425  0.3589471345  0.0216599672  0.1538300481
#> [486] -0.2008597516 -0.0863506628 -0.0060362631  0.0127235976  0.1820277988
#> [491] -0.0317104459  0.0654807885  0.0794713523 -0.1937952021  0.1317796914
#> [496]  0.3300728456  0.0810029618  0.4048480683  0.0970050503  0.2455842674
#> [501] -0.0979208155 -0.1952694728 -0.0694889321  0.1123208786 -0.2259265088
#> [506] -0.1494419161  0.1328500284  0.3078905662  0.2862530752 -0.0820187963
#> [511] -0.4402637036  0.2420159033 -0.2161562630  0.0254302889  0.0860317928
#> [516]  0.0701855656 -0.2828876652  0.1947945140  0.4285609579 -0.0763067930
#> [521]  0.0528312955  0.1340043485  0.0033630101 -0.1186991761  0.1400016837
#> [526]  0.0228394508 -0.0633239961  0.2172081796  0.0551197259  0.1114300708
#> [531]  0.2228946897 -0.1386476270 -0.1396034330  0.0225317859  0.0027994679
#> [536]  0.2369674641  0.1581531014 -0.0157578093  0.0028232451 -0.1631293765
#> [541]  0.1526547826  0.0289800871  0.1908784804  0.1917038949  0.0894316857
#> [546] -0.2477764019  0.1938849920  0.2969936689 -0.0265049434 -0.0038348422
#> [551] -0.0455868154 -0.0011166637  0.1546877610  0.2946046919 -0.1330563078
#> [556] -0.0594942427 -0.2855450524  0.1944116004 -0.1162873471  0.0217095976
#> [561] -0.3408797269  0.1829825371  0.0932754995  0.1165414373 -0.2314404342
#> [566] -0.0334809613 -0.0145271258  0.1103943007 -0.1621013227 -0.0052228494
#> [571] -0.0915490639 -0.0378602198 -0.1739188513 -0.1416911184  0.2418159983
#> [576] -0.1017302391  0.1162697478  0.1452138132 -0.0575059350 -0.0301358567
#> [581] -0.0492047566  0.1442168613 -0.1010644101 -0.1514920916 -0.1221480068
#> [586] -0.0247369031  0.0732766169  0.0569706613 -0.1142835841  0.2416390320
#> [591] -0.1178688427  0.1356732043  0.0572584958 -0.1074228760 -0.0883379883
#> [596]  0.0798914577 -0.0940486079  0.1349959687  0.0467227749 -0.0722540074
#> [601] -0.0086475373  0.0839916386 -0.0819755463 -0.0905693717  0.0094341605
#> [606]  0.1539770401 -0.0932380562 -0.0758420518 -0.0727272395 -0.0597411780
#> [611]  0.1358666815  0.0287344352  0.0766229344  0.4172602665  0.1723726315
#> [616] -0.0826869881  0.1740865849 -0.0192328407 -0.0023863016 -0.1625819527
#> [621]  0.0280308963  0.0143243945  0.4032580858  0.1805497459  0.0925071491
#> [626]  0.0305073141 -0.1505808517 -0.2197263627  0.2578311895 -0.1704101369
#> [631] -0.0868224547  0.0376454859  0.0356454851 -0.1055197714  0.0873129939
#> [636]  0.3825574947  0.0196175072 -0.0264697147 -0.1096339650  0.1762544644
#> [641]  0.1359686922 -0.1525687944 -0.2543599898 -0.0122435550 -0.0635728196
#> [646]  0.0445445255  0.0272144847 -0.0490559333 -0.0415860458  0.0307521114
#> [651]  0.0212423604  0.0583124053  0.0092471021  0.0345001828 -0.1012724380
#> [656]  0.0099624569 -0.0903187220 -0.0428378899  0.2068596690 -0.0759302940
#> [661] -0.0847999238 -0.0918615122 -0.4247119528 -0.2350222330  0.3559129270
#> [666]  0.1307779099  0.0135476480 -0.3362845136  0.0200181870 -0.1146237691
#> [671]  0.1947558756  0.0543025692  0.2834064495 -0.1041566309  0.1394374734
#> [676]  0.0489346782  0.1086852709  0.1835433924 -0.2209088839  0.1403600145
#> [681]  0.0806198686  0.0947643172 -0.0018019232 -0.2455847149 -0.1347800228
#> [686]  0.1425805030 -0.0668594559 -0.0628100561  0.0147274151  0.1668688921
#> [691]  0.1966670587 -0.0567344656  0.2026430269  0.0474637605  0.0938001912
#> [696]  0.0801725400  0.0645671750  0.2312210540  0.0926787699  0.0614615818
#> [701]  0.2073104626 -0.1461574845  0.0507322849  0.0002869130  0.1274512901
#> [706]  0.0046362579  0.1977683303 -0.0564012153  0.3689447486 -0.3500588250
#> [711]  0.0683271897 -0.1151470052 -0.2025370922 -0.1428673725 -0.2947791093
#> [716]  0.3053223474  0.0653563032 -0.2836971147  0.0161770449 -0.1084730507
#> [721] -0.0022430782 -0.0818222452 -0.2469904853  0.2274382418 -0.4125051460
#> [726] -0.0036337749 -0.1369389287 -0.0419617369  0.0545076900 -0.0058777894
#> [731]  0.0505125252 -0.1843112776  0.1538349334  0.0739547187  0.2895440447
#> [736]  0.0271880830  0.0723212394  0.1308274282  0.0374308889  0.0511144600
#> [741]  0.1085604799  0.1874893684 -0.0735230096 -0.1735021755 -0.1655588211
#> [746]  0.1118615632 -0.0486702753 -0.0912092152 -0.2759486043  0.2445228309
#> [751] -0.1442591847 -0.0573339147 -0.0181772656  0.2464461593  0.1429658716
#> [756] -0.1354569882  0.1955807692 -0.2404660234 -0.1620497648  0.0149240133
#> [761] -0.1727855138  0.0244627024  0.1281344933 -0.2799724187  0.0378798431
#> [766]  0.1721788127 -0.0015158340 -0.1868598796  0.1169796678  0.0176309003
#> [771]  0.0894513041  0.0112126891 -0.1101837995 -0.1222607177 -0.0510014341
#> [776] -0.2464045372  0.2019148207  0.2383840735  0.0507145435 -0.1312627553
#> [781] -0.1505272061  0.2934361654  0.1732028197  0.0421029042 -0.0572204565
#> [786]  0.0025204999  0.1807386087 -0.2121548716 -0.1228131552 -0.1879907976
#> [791]  0.0710521493  0.0666544954 -0.1907350463  0.2405408377  0.0357463391
#> [796]  0.0850126236  0.1103504931 -0.0425315914 -0.1136388068 -0.2841806004
#> [801] -0.0008804449  0.1068738967  0.0117107825  0.2646810048 -0.0936196351
#> [806]  0.0810140621  0.1684349243 -0.0444131316 -0.0218945227 -0.0776568750
#> [811] -0.0413926856  0.1375973573  0.0393526058 -0.1076860492 -0.0002752573
#> [816] -0.2058789323  0.0415003285 -0.2797695986 -0.0943564566 -0.1045709105
#> [821] -0.0509445713 -0.0605322392 -0.0733523090  0.1857489644 -0.0481222072
#> [826] -0.0416405226 -0.1190128752  0.0401061315 -0.3030688961 -0.1614215784
#> [831] -0.1503026328  0.0311882903  0.1197801761 -0.2862187636  0.1308718741
#> [836]  0.0592515325  0.2158226061  0.2572067424 -0.0578987413  0.1317612898
#> [841] -0.0566611392  0.0077321097 -0.2245491385 -0.1160591760  0.2781965791
#> [846] -0.1617979629  0.1042509833  0.1659310966 -0.0176187499  0.0275800575
#> [851] -0.0300577957 -0.2067736801  0.2461534213  0.0855980649  0.2135210853
#> [856]  0.1616448027 -0.1846059831  0.3811567708  0.2298259548  0.1076924219
#> [861] -0.2631328628 -0.1630942941 -0.0259526287  0.0359744264 -0.0054235275
#> [866]  0.1571993802 -0.0869378774  0.1794489846  0.1136460134 -0.0151310611
#> [871]  0.0591462457  0.1376753525 -0.4265564339  0.0587217573  0.0831171002
#> [876] -0.0166833997 -0.1926592022  0.2191083187 -0.1558343169 -0.0339989941
#> [881]  0.0299321264 -0.0339826634 -0.2903964724  0.0993441980  0.1650470333
#> [886] -0.1040156095 -0.2472615236 -0.0274961629  0.1031041981 -0.1739636411
#> [891]  0.3328111450 -0.0443850102 -0.0028118592 -0.0219066880 -0.0025837111
#> [896]  0.1995553248  0.1160534494  0.0296983574 -0.0885179324  0.0618457052
#> [901]  0.1297624428  0.0571190088  0.1220427980 -0.1773465433  0.1248319699
#> [906] -0.1513643595  0.0461188338  0.2975883735 -0.0063311098 -0.2451391249
#> [911]  0.0884935987 -0.0974280400  0.2488825420 -0.0463105452 -0.0219757796
#> [916]  0.2678429414  0.2342119953 -0.0253751743  0.0390075040  0.0726344309
#> [921]  0.1832563597 -0.0378340158 -0.0133312748 -0.2744838912 -0.1300190536
#> [926]  0.0862738967  0.2105642551 -0.1792614310 -0.1271827597 -0.2226480573
#> [931] -0.3613323902  0.0901831052 -0.0661022354  0.2836309749 -0.1736469983
#> [936]  0.0601484417 -0.1180784017 -0.2294636141  0.1791196409  0.1729817111
#> [941] -0.0596510050  0.1949722035  0.1068592590  0.0015707906  0.3404767417
#> [946] -0.1603331647 -0.0229743758 -0.1018725918 -0.1531417353 -0.2932040624
#> [951]  0.1840119249  0.0468674792  0.2737924132 -0.2309208164  0.0770031939
#> [956]  0.0591370713  0.1935199291 -0.0332943486  0.0843391859  0.1021247672
#> [961] -0.0307789200 -0.1546100792 -0.0716834882  0.3202805411  0.1774071719
#> [966] -0.2052879742 -0.2229123505  0.0618548198 -0.0391301060  0.0508688293
#> [971]  0.1908862540  0.0378289550  0.1976046404 -0.0152159765  0.0021521377
#> [976] -0.0833426424 -0.0188422068  0.0594442730  0.0043531373  0.0261895691
#> [981] -0.2882063906  0.2123022621 -0.1117810775 -0.4010435477 -0.2710088088
#> [986] -0.2441463343 -0.1897974159  0.0202873702 -0.1370705640 -0.1665571772
#> [991] -0.2451053292  0.0769222249  0.0060320396 -0.1059344517 -0.1192937828
#> [996] -0.2134458072  0.1400280362 -0.0321323150 -0.2503149034
#> 
mantel_test(G, W, method = "kendall")  # use of alternative test statistic
#> $stat
#> [1] 0.1393939
#> 
#> $quantile
#> [1] 0.9019019
#> 
#> $p.value
#> [1] 0.1961962
#> 
#> $perm
#>   [1]  0.034343434 -0.070707071  0.062626263 -0.115151515 -0.098989899
#>   [6] -0.159595960 -0.014141414  0.127272727 -0.050505051 -0.078787879
#>  [11] -0.030303030 -0.062626263 -0.216161616 -0.103030303  0.107070707
#>  [16]  0.062626263 -0.163636364 -0.123232323 -0.058585859  0.078787879
#>  [21] -0.006060606 -0.135353535  0.155555556 -0.046464646 -0.074747475
#>  [26] -0.002020202 -0.094949495  0.062626263  0.010101010 -0.123232323
#>  [31] -0.094949495  0.034343434 -0.042424242  0.094949495 -0.119191919
#>  [36]  0.022222222  0.107070707  0.002020202 -0.301010101 -0.046464646
#>  [41] -0.155555556  0.163636364  0.264646465  0.115151515  0.074747475
#>  [46] -0.014141414  0.070707071 -0.038383838 -0.183838384 -0.006060606
#>  [51]  0.062626263 -0.066666667  0.090909091 -0.143434343  0.200000000
#>  [56] -0.167676768  0.018181818 -0.103030303 -0.018181818 -0.010101010
#>  [61]  0.107070707  0.107070707  0.155555556 -0.050505051  0.046464646
#>  [66] -0.159595960  0.042424242  0.030303030 -0.058585859  0.054545455
#>  [71]  0.155555556  0.074747475 -0.187878788  0.026262626  0.220202020
#>  [76] -0.127272727  0.022222222 -0.050505051  0.179797980 -0.066666667
#>  [81] -0.139393939 -0.054545455  0.026262626  0.094949495  0.212121212
#>  [86]  0.115151515  0.131313131  0.022222222  0.183838384 -0.147474747
#>  [91] -0.034343434  0.050505051 -0.034343434  0.022222222 -0.042424242
#>  [96] -0.107070707  0.175757576  0.094949495  0.026262626  0.086868687
#> [101]  0.010101010 -0.119191919  0.090909091 -0.010101010  0.248484848
#> [106] -0.111111111  0.224242424  0.074747475 -0.038383838 -0.010101010
#> [111]  0.123232323  0.026262626 -0.030303030 -0.002020202 -0.111111111
#> [116] -0.090909091 -0.135353535 -0.006060606  0.066666667 -0.006060606
#> [121]  0.111111111  0.050505051  0.204040404  0.050505051  0.191919192
#> [126]  0.155555556  0.070707071  0.082828283 -0.212121212 -0.151515152
#> [131] -0.268686869 -0.098989899 -0.151515152 -0.046464646  0.115151515
#> [136]  0.074747475 -0.103030303  0.175757576  0.002020202  0.074747475
#> [141]  0.163636364 -0.062626263  0.034343434  0.066666667  0.066666667
#> [146] -0.022222222  0.159595960  0.014141414  0.022222222  0.103030303
#> [151]  0.082828283  0.030303030  0.111111111 -0.058585859  0.139393939
#> [156]  0.135353535  0.062626263  0.054545455 -0.070707071 -0.054545455
#> [161] -0.090909091 -0.094949495 -0.147474747  0.018181818 -0.058585859
#> [166] -0.002020202 -0.086868687  0.010101010 -0.119191919  0.107070707
#> [171] -0.058585859  0.074747475  0.070707071 -0.054545455  0.155555556
#> [176] -0.046464646 -0.058585859 -0.050505051  0.026262626 -0.022222222
#> [181]  0.078787879  0.325252525  0.010101010 -0.115151515  0.147474747
#> [186]  0.022222222 -0.066666667  0.030303030 -0.034343434  0.030303030
#> [191] -0.054545455  0.090909091  0.038383838 -0.119191919  0.074747475
#> [196] -0.046464646 -0.123232323 -0.014141414 -0.151515152  0.086868687
#> [201]  0.183838384  0.094949495 -0.002020202 -0.058585859 -0.010101010
#> [206] -0.195959596 -0.062626263  0.135353535 -0.042424242 -0.062626263
#> [211] -0.054545455  0.050505051  0.038383838  0.183838384 -0.022222222
#> [216] -0.062626263  0.256565657  0.046464646 -0.010101010  0.066666667
#> [221] -0.010101010  0.030303030  0.030303030 -0.014141414  0.191919192
#> [226] -0.111111111  0.127272727 -0.082828283 -0.046464646 -0.022222222
#> [231] -0.195959596 -0.078787879  0.082828283  0.098989899  0.030303030
#> [236]  0.163636364 -0.062626263  0.070707071 -0.147474747 -0.107070707
#> [241] -0.094949495 -0.103030303 -0.115151515 -0.107070707 -0.086868687
#> [246] -0.034343434  0.111111111  0.107070707  0.006060606  0.082828283
#> [251] -0.066666667  0.030303030 -0.107070707  0.163636364  0.139393939
#> [256] -0.058585859 -0.006060606 -0.058585859  0.123232323  0.175757576
#> [261]  0.014141414 -0.070707071  0.030303030 -0.046464646  0.086868687
#> [266] -0.082828283 -0.058585859 -0.026262626 -0.034343434 -0.034343434
#> [271]  0.098989899  0.086868687 -0.098989899  0.103030303  0.066666667
#> [276]  0.002020202 -0.074747475  0.070707071 -0.066666667  0.163636364
#> [281]  0.111111111  0.094949495  0.115151515  0.018181818  0.058585859
#> [286]  0.111111111  0.074747475 -0.010101010  0.155555556 -0.127272727
#> [291]  0.111111111 -0.119191919 -0.103030303 -0.098989899 -0.107070707
#> [296] -0.014141414 -0.123232323 -0.058585859  0.143434343  0.030303030
#> [301] -0.111111111  0.131313131 -0.155555556  0.086868687 -0.058585859
#> [306] -0.131313131 -0.006060606 -0.018181818  0.256565657  0.074747475
#> [311]  0.026262626  0.018181818 -0.159595960  0.014141414  0.034343434
#> [316]  0.054545455 -0.123232323 -0.127272727  0.208080808  0.050505051
#> [321]  0.014141414 -0.058585859  0.062626263  0.050505051  0.098989899
#> [326] -0.010101010 -0.038383838 -0.002020202  0.026262626 -0.018181818
#> [331] -0.131313131 -0.078787879 -0.115151515 -0.074747475  0.131313131
#> [336] -0.018181818  0.006060606 -0.062626263 -0.034343434  0.171717172
#> [341] -0.058585859 -0.014141414 -0.054545455  0.151515152  0.042424242
#> [346] -0.066666667  0.107070707 -0.139393939 -0.046464646 -0.042424242
#> [351] -0.195959596 -0.046464646  0.094949495 -0.026262626 -0.050505051
#> [356] -0.256565657 -0.022222222 -0.244444444 -0.111111111 -0.139393939
#> [361] -0.030303030  0.014141414 -0.119191919 -0.123232323  0.062626263
#> [366] -0.054545455 -0.119191919 -0.167676768 -0.147474747  0.070707071
#> [371] -0.175757576  0.167676768 -0.030303030 -0.090909091 -0.094949495
#> [376]  0.038383838 -0.006060606  0.042424242  0.098989899  0.171717172
#> [381]  0.131313131 -0.070707071  0.042424242 -0.183838384  0.301010101
#> [386] -0.050505051  0.002020202 -0.058585859  0.094949495 -0.014141414
#> [391] -0.002020202 -0.135353535 -0.155555556  0.143434343 -0.054545455
#> [396] -0.094949495  0.010101010  0.082828283 -0.107070707 -0.143434343
#> [401] -0.046464646  0.006060606  0.050505051 -0.010101010 -0.022222222
#> [406]  0.139393939  0.183838384  0.050505051 -0.014141414  0.050505051
#> [411] -0.010101010  0.050505051 -0.179797980 -0.010101010  0.098989899
#> [416] -0.010101010 -0.062626263 -0.159595960 -0.042424242  0.119191919
#> [421] -0.038383838  0.098989899  0.030303030 -0.010101010  0.054545455
#> [426] -0.082828283 -0.034343434 -0.147474747 -0.070707071  0.022222222
#> [431]  0.183838384 -0.082828283  0.103030303 -0.074747475 -0.054545455
#> [436] -0.010101010  0.086868687 -0.094949495 -0.010101010 -0.030303030
#> [441] -0.090909091  0.127272727 -0.010101010  0.082828283 -0.006060606
#> [446] -0.018181818 -0.167676768  0.002020202  0.050505051 -0.054545455
#> [451] -0.183838384 -0.183838384  0.090909091 -0.034343434 -0.018181818
#> [456]  0.103030303  0.151515152  0.018181818 -0.026262626  0.127272727
#> [461] -0.026262626 -0.123232323  0.163636364  0.078787879 -0.147474747
#> [466]  0.006060606  0.078787879 -0.062626263 -0.127272727  0.224242424
#> [471]  0.127272727 -0.103030303 -0.010101010  0.030303030 -0.026262626
#> [476]  0.159595960  0.119191919 -0.090909091  0.171717172  0.010101010
#> [481] -0.119191919  0.082828283  0.026262626 -0.054545455  0.066666667
#> [486]  0.159595960 -0.062626263 -0.074747475 -0.143434343  0.090909091
#> [491] -0.030303030  0.127272727  0.268686869 -0.062626263 -0.042424242
#> [496] -0.078787879 -0.034343434  0.026262626  0.228282828 -0.082828283
#> [501]  0.038383838  0.014141414  0.014141414  0.224242424 -0.094949495
#> [506]  0.078787879 -0.070707071  0.086868687 -0.018181818  0.066666667
#> [511]  0.268686869 -0.026262626 -0.002020202 -0.070707071 -0.006060606
#> [516] -0.038383838 -0.030303030  0.078787879 -0.070707071 -0.010101010
#> [521]  0.054545455 -0.022222222  0.175757576  0.038383838  0.030303030
#> [526]  0.042424242 -0.070707071  0.147474747  0.191919192 -0.082828283
#> [531]  0.006060606  0.256565657  0.058585859 -0.195959596 -0.038383838
#> [536]  0.002020202  0.014141414  0.123232323  0.058585859 -0.018181818
#> [541]  0.135353535 -0.026262626 -0.183838384  0.038383838  0.018181818
#> [546] -0.046464646 -0.139393939 -0.086868687 -0.030303030 -0.050505051
#> [551]  0.042424242 -0.018181818  0.002020202  0.046464646 -0.212121212
#> [556]  0.050505051  0.228282828  0.123232323 -0.046464646 -0.002020202
#> [561] -0.224242424 -0.014141414  0.074747475 -0.086868687  0.078787879
#> [566]  0.224242424  0.155555556 -0.014141414  0.010101010 -0.006060606
#> [571] -0.090909091 -0.107070707  0.200000000  0.135353535 -0.094949495
#> [576]  0.002020202  0.179797980 -0.090909091  0.115151515  0.006060606
#> [581] -0.066666667  0.018181818 -0.119191919  0.135353535 -0.034343434
#> [586] -0.220202020  0.030303030 -0.002020202  0.018181818  0.026262626
#> [591] -0.010101010 -0.022222222  0.175757576  0.151515152 -0.066666667
#> [596] -0.062626263  0.002020202 -0.094949495 -0.111111111  0.066666667
#> [601] -0.038383838  0.054545455 -0.058585859  0.175757576  0.034343434
#> [606] -0.058585859  0.066666667  0.131313131  0.022222222  0.119191919
#> [611]  0.179797980 -0.058585859 -0.014141414 -0.018181818  0.159595960
#> [616] -0.030303030  0.159595960  0.042424242 -0.022222222  0.010101010
#> [621]  0.034343434 -0.038383838  0.054545455  0.006060606  0.086868687
#> [626]  0.131313131 -0.070707071  0.131313131 -0.082828283  0.086868687
#> [631]  0.066666667 -0.228282828  0.026262626  0.123232323  0.159595960
#> [636]  0.082828283 -0.147474747  0.038383838  0.127272727  0.216161616
#> [641] -0.228282828  0.082828283 -0.155555556 -0.050505051  0.054545455
#> [646] -0.054545455 -0.026262626  0.155555556 -0.103030303  0.070707071
#> [651] -0.034343434  0.111111111  0.167676768  0.034343434  0.086868687
#> [656] -0.038383838 -0.026262626  0.074747475  0.022222222 -0.002020202
#> [661]  0.014141414  0.123232323 -0.062626263  0.103030303  0.002020202
#> [666] -0.034343434  0.187878788 -0.143434343  0.026262626  0.034343434
#> [671]  0.119191919  0.103030303 -0.224242424 -0.292929293  0.155555556
#> [676]  0.066666667 -0.006060606 -0.086868687 -0.256565657 -0.163636364
#> [681]  0.127272727 -0.010101010 -0.038383838 -0.115151515 -0.050505051
#> [686] -0.090909091  0.179797980 -0.078787879  0.018181818 -0.070707071
#> [691]  0.151515152 -0.135353535 -0.139393939 -0.224242424 -0.216161616
#> [696]  0.111111111 -0.115151515 -0.082828283 -0.086868687  0.212121212
#> [701]  0.022222222  0.006060606 -0.070707071 -0.107070707  0.074747475
#> [706]  0.014141414  0.098989899 -0.042424242  0.123232323  0.103030303
#> [711] -0.002020202  0.030303030 -0.022222222 -0.115151515  0.115151515
#> [716] -0.042424242 -0.062626263  0.139393939 -0.026262626  0.082828283
#> [721]  0.038383838  0.090909091 -0.026262626 -0.066666667  0.078787879
#> [726] -0.038383838 -0.167676768 -0.026262626 -0.094949495  0.050505051
#> [731] -0.155555556  0.070707071 -0.090909091  0.179797980  0.010101010
#> [736]  0.171717172  0.082828283 -0.038383838  0.050505051  0.030303030
#> [741]  0.062626263 -0.115151515 -0.002020202  0.155555556 -0.070707071
#> [746] -0.014141414  0.042424242 -0.006060606 -0.038383838 -0.098989899
#> [751] -0.123232323  0.074747475 -0.070707071 -0.240404040  0.014141414
#> [756] -0.086868687  0.034343434 -0.151515152  0.050505051 -0.119191919
#> [761] -0.010101010 -0.026262626  0.014141414  0.268686869 -0.038383838
#> [766]  0.074747475 -0.038383838  0.046464646 -0.167676768 -0.070707071
#> [771] -0.143434343  0.014141414  0.127272727  0.046464646  0.159595960
#> [776]  0.082828283 -0.002020202 -0.042424242 -0.066666667 -0.103030303
#> [781]  0.058585859  0.123232323  0.107070707 -0.204040404 -0.030303030
#> [786] -0.026262626 -0.159595960 -0.022222222 -0.094949495  0.038383838
#> [791]  0.006060606  0.014141414 -0.086868687 -0.103030303  0.135353535
#> [796]  0.062626263  0.131313131 -0.066666667 -0.212121212  0.123232323
#> [801] -0.018181818  0.131313131  0.139393939 -0.002020202 -0.014141414
#> [806]  0.022222222  0.066666667 -0.034343434 -0.123232323 -0.050505051
#> [811] -0.054545455 -0.107070707  0.179797980 -0.010101010 -0.086868687
#> [816]  0.111111111 -0.042424242  0.054545455 -0.070707071  0.018181818
#> [821] -0.014141414 -0.034343434 -0.167676768 -0.014141414 -0.026262626
#> [826]  0.018181818 -0.022222222  0.098989899 -0.018181818  0.143434343
#> [831]  0.042424242  0.066666667 -0.256565657  0.034343434  0.167676768
#> [836] -0.074747475  0.107070707 -0.119191919 -0.006060606 -0.002020202
#> [841] -0.264646465 -0.212121212  0.006060606  0.086868687 -0.042424242
#> [846] -0.204040404 -0.123232323 -0.062626263 -0.086868687 -0.058585859
#> [851] -0.094949495 -0.119191919 -0.115151515 -0.159595960 -0.074747475
#> [856] -0.086868687 -0.058585859 -0.062626263  0.171717172 -0.131313131
#> [861] -0.090909091  0.022222222  0.046464646 -0.212121212 -0.066666667
#> [866] -0.022222222 -0.127272727  0.098989899  0.127272727  0.115151515
#> [871] -0.074747475  0.030303030 -0.030303030 -0.135353535 -0.216161616
#> [876]  0.038383838 -0.018181818 -0.054545455  0.066666667  0.022222222
#> [881]  0.066666667  0.038383838 -0.078787879  0.026262626 -0.082828283
#> [886]  0.183838384  0.167676768  0.098989899 -0.022222222  0.002020202
#> [891]  0.058585859  0.151515152 -0.058585859  0.026262626 -0.228282828
#> [896] -0.038383838 -0.155555556 -0.155555556  0.107070707 -0.042424242
#> [901]  0.050505051  0.010101010 -0.123232323 -0.006060606 -0.143434343
#> [906] -0.070707071 -0.119191919  0.066666667  0.038383838  0.078787879
#> [911] -0.026262626  0.038383838 -0.010101010 -0.038383838  0.111111111
#> [916]  0.123232323 -0.103030303  0.123232323 -0.046464646  0.074747475
#> [921] -0.010101010  0.078787879  0.034343434 -0.078787879 -0.038383838
#> [926]  0.046464646 -0.107070707  0.022222222  0.103030303 -0.010101010
#> [931]  0.058585859  0.070707071 -0.103030303  0.026262626  0.179797980
#> [936] -0.111111111  0.074747475 -0.123232323 -0.022222222 -0.103030303
#> [941] -0.038383838  0.030303030 -0.046464646  0.123232323  0.002020202
#> [946] -0.107070707 -0.123232323  0.070707071 -0.002020202 -0.224242424
#> [951] -0.078787879 -0.010101010 -0.090909091 -0.107070707  0.038383838
#> [956]  0.018181818 -0.058585859 -0.082828283  0.131313131  0.014141414
#> [961]  0.115151515  0.224242424  0.034343434  0.022222222 -0.030303030
#> [966]  0.066666667 -0.171717172 -0.002020202 -0.050505051  0.111111111
#> [971]  0.070707071  0.098989899 -0.010101010 -0.014141414  0.143434343
#> [976] -0.006060606 -0.070707071  0.094949495  0.111111111 -0.280808081
#> [981] -0.151515152  0.074747475 -0.002020202  0.143434343 -0.066666667
#> [986] -0.127272727 -0.006060606  0.046464646 -0.022222222  0.175757576
#> [991]  0.074747475  0.082828283  0.098989899 -0.131313131  0.103030303
#> [996]  0.103030303  0.090909091  0.054545455 -0.014141414
#> 

# Demonstrate that the function matches vegan::mantel.partial output:
# (using only symmetric matrices, and just one control variable, since
# vegan does not work with asymmetric matrices or multiple controls)
a <- mantel_test(G, W, list(D), nperm = 99999)
b <- vegan::mantel.partial(G, W, D, permutations = 99999)
#> Error in loadNamespace(x): there is no package called ‘vegan’
c(a$stat, b$statistic)
#> Error: object 'b' not found
c(1 - a$quantile, b$signif) # will differ slightly due to randomization
#> Error: object 'b' not found