# local_moran: Calculate the Local Moran's I Statistic In sfdep: Spatial Dependence for Simple Features

 local_moran R Documentation

## Calculate the Local Moran's I Statistic

### Description

Moran's I is calculated for each polygon based on the neighbor and weight lists.

### Usage

```local_moran(x, nb, wt, alternative = "two.sided", nsim = 499, ...)
```

### Arguments

 `x` A numeric vector. `nb` a neighbor list object for example as created by `st_contiguity()`. `wt` a weights list as created by `st_weights()`. `alternative` default `"two.sided"`. Should be one of `"greater"`, `"less"`, or `"two.sided"` to specify the alternative hypothesis. `nsim` The number of simulations to run. `...` See `?spdep::localmoran_perm()` for more options.

### Details

`local_moran()` calls `spdep::localmoran_perm()` and calculates the Moran I for each polygon. As well as provide simulated p-values.

### Value

a `data.frame` containing the columns `ii`, `eii`, `var_ii`, `z_ii`, `p_ii`, `p_ii_sim`, and `p_folded_sim`. For more details please see `spdep::localmoran_perm()`.

Other stats: `st_lag()`

### Examples

```library(magrittr)
lisa <- guerry %>%
dplyr::mutate(nb = st_contiguity(geometry),
wt = st_weights(nb),
moran = local_moran(crime_pers, nb, wt))

# unnest the dataframe column
tidyr::unnest(lisa, moran)
```

sfdep documentation built on Jan. 11, 2023, 9:08 a.m.