Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need to use our own permutations of indices in Local Moran's Index #344

Open
martirenom opened this issue Jul 30, 2024 · 1 comment
Open

Comments

@martirenom
Copy link

martirenom commented Jul 30, 2024

Hi there,

We are in need to use our own permutations that maintain certain linearity of the data when calculating LMI. This is done at the function Moran_Local(), which in turn calls crand() (esda/crand.py). Could you please implement that the function takes an external array of permuted indices (within crand() called permuted_ids), that are user provided? That would be perfect for our needs and could be tailored to other users that may need different permutation strategies.

For example, vec_permutations(10, 11, 10, 66666) within crand() would result in:

array([[5, 8, 7, 0, 1, 6, 4, 3, 9, 2],
       [0, 3, 8, 5, 4, 2, 6, 1, 9, 7],
       [6, 7, 4, 8, 2, 9, 0, 3, 5, 1],
       [8, 3, 1, 0, 7, 2, 4, 6, 9, 5],
       [3, 9, 7, 2, 8, 6, 0, 5, 1, 4],
       [8, 6, 1, 0, 7, 2, 5, 3, 4, 9],
       [7, 9, 2, 0, 5, 6, 3, 4, 1, 8],
       [8, 3, 7, 4, 0, 5, 2, 1, 9, 6],
       [2, 1, 0, 3, 9, 7, 6, 8, 5, 4],
       [6, 0, 5, 8, 9, 1, 2, 7, 4, 3]])

However, if we want to keep certain linearly restrained permutations we would use an array similar to this:

array([[6, 7, 8, 9, 5, 3, 4, 0, 1, 2],
       [6, 7, 8, 9, 5, 1, 2, 3, 4, 0],
       [5, 6, 7, 8, 9, 1, 2, 3, 4, 0],
       [4, 0, 1, 2, 3, 8, 9, 5, 6, 7],
       [1, 2, 3, 4, 0, 8, 9, 5, 6, 7],
       [2, 3, 4, 0, 1, 9, 5, 6, 7, 8],
       [2, 3, 4, 0, 1, 5, 6, 7, 8, 9],
       [3, 4, 0, 1, 2, 8, 9, 5, 6, 7],
       [1, 2, 3, 4, 0, 7, 8, 9, 5, 6],
       [1, 2, 3, 4, 0, 8, 9, 5, 6, 7]])

In summary, in our application, we do not want to use a totally random permutation of the data and such, we propose to add this feature to the function.

Thanks in advance,
Marc

@martinfleis
Copy link
Member

Hi, I don't think that there's anything blocking the implementation of this. Essentially, if someone passes an array of the right shape to permutations, instead of an integer, we can just use that directly.

Given you have a use case for that, could you try putting together a pull request implementing this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants