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
The
listwoject contains two elementsweightsandneighbours. Each is a list of the same length where each element ofneighborscontains all of thejvalues for observationi. The elementweightscontains the spatial weight for every element inneighbours.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.