I use the following code to calculate maximum eigenvalue in stata
encode Name, gen(name)
spset name, coord(latitude longitude )
spset, modify coordsys(latlong)
spmat idistance W longitude latitude,id(name) replace
spmat getmatrix W mataW
spmat eigenvalues W
spmat getmatrix W, eig(lambda)
mata:
mataW_n = mataW/max(lambda)
end
But I got the following error:
mataW_n = mataW/max(lambda)
minmax(): 3253 nonreal found where real required
max(): - function returned error
<istmt>: - function returned error
(0 lines skipped)
I have tried mata
function of eigensystem()
to get the eigenvalue L
, and then use max(L)
. But it got the same error. How to deal with this problem?
Many thanks!