Description Usage Arguments Value Note Author(s)

View source: R/check_spatialcorr.R

This function tests for positive spatial autocorrelation of the (uni- or multivariate) residuals, using either Moran's I or Mantel's test.

1 2 | ```
check_spatialcorr(specdata, vars, plotit = T, test = "moran",
method = "bonferroni", model = "gls")
``` |

`specdata` |
A data frame containing at least columns for the dependent variables, as well as a column "island" and a column "habitat". |

`vars` |
A character or integer vector. The names, or indices, of the dependent variables in |

`plotit` |
Logical. Whether to plot residuals versus latitude and longitude. |

`test` |
A character, what test to perform. |

`method` |
A character, the method used for P-value correction. See |

`model` |
A character string, either |

Either the output of the `mantel.test`

function from ape, or a table summarizing the (multiple) Moran's I test(s). If `plotit = T`

, also returns a scatter plot of the residuals versus latitude and longitude.

Beware that Mantel's test is a permutation test (999 permutations), and will take longer tha Moran's I test to run. Also, note that latitudes and longitudes are used to calculate geographical distances at the surface of the Earth using the Haversine distance function implemented in the package `geosphere`

.

Raphael Scherrer

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.