# Using weight component in Moran I calculation

I'm trying to understand the Moran I calculation, and there is something I don't understand. In this tutorial, Moran I described as the slope value of the correlation between one polygon to the neighbors mean value :

However, in other sources (including wikipedia), there is specific formula :

Based on this, it seems like the calculation is more complex, and also, there is spatial weight. I know about the weights that it can be for example rook or queen, and also neighbor degree, but I don't understand how that being expressed in this formula.

What is the weight component and how is it being expressed in the formula as number?

The source of confusion may be in the two W terms in your equation--this may suggest different types of weights in the formula. It will therefore be helpful to re-express the Moran’s I equation in a different form as follows:

Using the dataset you reference in your post as an example, yi is the income for a polygon of interest, i, and yj is the income for all other polygons, j, in the dataset. ybar is the mean income values for all polygons in the dataset. The weight wij is `0` if polygon j is not a neighbor of polygon i. If polygon j is a neighbor of polygon i, then the weight wij takes on a non-zero value. This non-zero value can vary depending on how a neighbor’s weight is defined. n is the total number of polygons.

To understand how the weights are used in the formula, we’ll work with the example you share. The map of the 16 polygons along with the income values are shown in the following figure.

The first step in the workflow is to conceptualize the idea of a neighbor. This can be contiguous polygons, distance between centroids, kth neighbors, etc…

The next step is to compute the neighborhood matrix. Here, all polygons are represented in both the rows and columns. The ith polygons are listed along the rows, the jth polygons along the columns. The intersection of the two is the weight the polygon in the jth column contributes to the neighboring polygons of the ith row. The weight values can be computed in many different ways. For example, the values can be binary (1 for neighboring polygons and 0 otherwise), or fractions where the sum of each neighboring polygon fraction sums to one—-this gives us the mean value of the neighboring polygons, for example. The figure below adopts the latter matrix computation.

Once the weight matrix is computed, its weight values are used to compute the Moran’s I value. The weights are used in both the numerator and the denominator as shown in the following figure.

• thank you for your answer! you have explained very clear. I still have one question - what is the difference between the moran I coefficient to the Moran I value that we get from the full equation? from your explaination. it seems to me wrong to say that the Moran I value is the coefficient Commented Jan 25, 2022 at 7:57
• also it looks like the calculation is only for polygon no 1, (because of the 18734-18146) repeating for all polygons, so it is confusing- how do we get conclusion from this for all the polygons? Commented Jan 25, 2022 at 8:17
• The calculations I show are a subset of all calculations involved in computing the Moran's I index. There would not be enough space in the graphic to show all calculations. Note the summation term across all polygons i. The first three lines in each equation block represent the first three neighbors of polygons 1, 2 ... , 16. Commented Jan 25, 2022 at 19:29
• yes, I know is only subset ,thank you for this. I still don't understand the connection between the OLS regression to the MORAN I equation, it seems like totally different calculations, though I understand that MORAN I calcualtion is like you described, where does the OLS regression takes part? Commented Feb 15, 2022 at 10:28
• @Reut, the "covariance term" over the "inverse of variance term" in the above Moran's I equation is the same equation used in OLS regression to estimate the slope term. Scroll down a few paragraphs on this link to see a form of the OLS equation. The Moran's I equation simply adds weight terms to indicate which neighboring values are used to compute the spatially lagged variable y_j. Commented Feb 16, 2022 at 13:38