0

In function moran in spdep package, which argument is being related to the weight matrix (or distance matrix)?

moran(x, listw, n, S0, zero.policy=NULL, NAOK=FALSE)

I have a matrix W2 which is the distance between some cities, I would like to know the matrix W2 should be placed in which of the arguments of moran function.

Here is some information about moran function: https://rdrr.io/rforge/spdep/man/moran.html

Rojer
  • 335
  • 2
  • 9

1 Answers1

0

The listw oject contains two elements weights and neighbours. Each is a list of the same length where each element of neighbors contains all of the j values for observation i. The element weights contains the spatial weight for every element in neighbours.

If you already have a matrix that you want to use you can use spdep::mat2listw(). However without a more reproducible example I can't be of much help.

thus__
  • 460
  • 3
  • 16