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

(BUG) L function and its Simulation Envelope under the null (CSR) not close to 0 #44

Closed
weikang9009 opened this issue Dec 11, 2019 · 5 comments
Assignees
Labels

Comments

@weikang9009
Copy link
Member

weikang9009 commented Dec 11, 2019

This issue is raised by a user of pointpats - Wei Xie.

The Simulation Envelope under the null of CSR built for the L function is nowhere near 0 (see the following figure), which is not right based on its definition.
image

@weikang9009 weikang9009 changed the title (BUG) L function and its Simulation Envelope under the null (CSR) is not close to 1 (BUG) L function and its Simulation Envelope under the null (CSR) not close to 1 Dec 11, 2019
@weikang9009 weikang9009 changed the title (BUG) L function and its Simulation Envelope under the null (CSR) not close to 1 (BUG) L function and its Simulation Envelope under the null (CSR) not close to 0 Dec 11, 2019
@ljwolf
Copy link
Member

ljwolf commented Apr 22, 2020

I think the equation is implemented incorrectly.. It should read:

    support, kestimate = _k(pp, intervals, dmin, dmax, d).T
    lestimate = np.sqrt(kestimate / np.pi)
    return np.column_stack((support, lestimate))

This is the form on wikipeda and in spatstats.

@jGaboardi
Copy link
Member

FWIW, this is the formulation found in O’Sullivan and Unwin (2010). I was going to add it into spaghetti before realizing it is not well-suited for networks.

  • D. O’Sullivan and D. J. Unwin. Point Pattern Analysis, chapter 5, pages 121–156. John Wiley & Sons, Ltd, 2010. doi:10.1002/9780470549094.ch5.

@weikang9009
Copy link
Member Author

weikang9009 commented Apr 22, 2020

I think the equation is implemented incorrectly.. It should read:

    support, kestimate = _k(pp, intervals, dmin, dmax, d).T
    lestimate = np.sqrt(kestimate / np.pi)
    return np.column_stack((support, lestimate))

This is the form on wikipeda and in spatstats.

I do not see a major difference between these two implementations - the only difference is that your implementation does not deduct the distance from the "normalized" L function. The current implementation in pointpats follows another routine (as pointed out by @jGaboardi ) and is also shown in the Wikipedia:
image
I think the main purpose is to make the interpretation more intuitive: under the null, the L function follows a horizontal line at 0.

We have found the bug and Serge has fixed it in #45. Another bug is introduced with this PR and it is supposed to be fixed in #46. I should have closed this issue (have been waiting for the close of the #46) - sorry if this induces any confusion.

@ljwolf
Copy link
Member

ljwolf commented Apr 22, 2020

I see! Feel free to close this then!

the only difference...

Right. The plotting correction is not the L function itself.

I understand the L with this adjustment is interpreted like the J but centered on zero.

I think this needs to be documented + given an option.

@weikang9009
Copy link
Member Author

weikang9009 commented Apr 22, 2020

The equation is given in the example notebook for distance statistics. I will add the missing equations for the distance functions to the inline docstrings. Thanks for the suggestion.

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

No branches or pull requests

4 participants