permutations in localG_perm · Issue #124 · r-spatial/spdep (original) (raw)

Thank you for the very prompt fix #123 - the probabilities look more reasonable to me now. However, the G values are not as expected, which led me to pick up on another couple of potential issues:

  1. For both localG (line 49 in localG.R) and localG_perm (line 346 in lisa_perm.R), the final G values are calculated by:
    res <- res / sqrt(VG)
    For localG, VG is calculated from the dataset, but in localG_perm, VG is the variance of the expected value from the permutations. I am not sure why the variance in the permutations should affect the values of G. Should VG be calculated as for localG in both functions?
  2. In localG_perm, I see that the sampling is done with replacement. Of course values would need to be replaced within each column, but I think that replacement should be FALSE within each row (so you do not have any duplicate values/observations within the lagged sample).

Thank you again, and sorry for all the trouble.