View source: R/helper_functions_application.R

geo_weights | R Documentation |

Calculates a inverse-distance based weight matrix for the function `ssMRCD`

(see details).

```
geo_weights(coordinates, N_assignments)
```

`coordinates` |
matrix of coordinates of observations. |

`N_assignments` |
vector of neighborhood assignments. |

First, the centers (means of the coordinates given) `c_i`

of each neighborhood is calculated.
Then, the Euclidean distance between the centers is calculated and the weight is based on
the inverse distance between two neighborhoods,

`w_{ij} = \frac{1}{dist(c_i, c_j)}. `

It is scaled according to a weight matrix.

Returns a weighting matrix `W`

and the coordinates of the centers per neighborhood `centersN`

.

`rescale_weights`

```
coordinates = matrix(rnorm(1000), ncol = 2, nrow = 500)
N_ass = sample(1:5, 500, replace = TRUE)
geo_weights(coordinates, N_ass)
```

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.