Dear Statalisters,
I created a matrix of distances in a Stata dataset: where variable unit_ID identifies units down the rows (i), and variables named after each unit (j) so that d_ij contains the distance between units. I then use spmatrix fromdata to turn this into a spatial weight matrix:
The problem is in the spectral normalization. I get a spatial weight matrix full of missing values. What could be going on here? My matrix has 0 on the diagonal, of course the distance of a unit to itself is 0. The Wminmax I generated works, and so does Wnone.
In p. 147 of Stata's SP Manual:
I created a matrix of distances in a Stata dataset: where variable unit_ID identifies units down the rows (i), and variables named after each unit (j) so that d_ij contains the distance between units. I then use spmatrix fromdata to turn this into a spatial weight matrix:
Code:
* Inverse distance, no normalization * spmatrix fromdata Wnone = d_*, idist normalize(none) spmatrix summarize Wnone * Inverse distance, minmax normalization * spmatrix fromdata Wminmax = d_*, idist normalize(minmax) spmatrix summarize Wminmax * Inverse distance, spectral normalization (default) * spmatrix fromdata Wspectral = d_*, idist normalize(spectral) spmatrix summarize Wspectral
In p. 147 of Stata's SP Manual:
- normalize(spectral) and normalize(minmax) produce matrices that differ from the original only by a scalar multiple.
- The scaling factor c from normalize(spectral) is always less than or equal to the scaling factor from normalize(minmax).
- spmatrix create and other Sp matrix commands use spectral normalization by default because it is the smallest scaling that in general guarantees nonsingularity without changing the model specification of the original matrix. However, normalize(spectral) is computationally expensive. It can take a long time for large matrices. If this is a consideration, normalize(minmax) is faster to compute and will yield results that are close to those of normalize(spectral).
Comment