Skip to content

Conversation

@philpatton
Copy link
Contributor

Estimating species distributions with occupancy models

This would add a new example notebook for species distribution modeling with occupancy models, an extremely common task/model in ecology. See here for the relevant issue. I apologize in advance for any rookie mistakes!

Helpful links

@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@review-notebook-app
Copy link

review-notebook-app bot commented Jan 28, 2026

View / edit / reply to this conversation on ReviewNB

fonnesbeck commented on 2026-01-28T22:08:27Z
----------------------------------------------------------------

Surprised to see a linear date effect -- would have thought it to be non-linear. How is date encoded?


philpatton commented on 2026-01-29T00:44:57Z
----------------------------------------------------------------

I added a little note that the surveys took place from January to April, and also added a note saying "see below for figure showing the predictors"

@review-notebook-app
Copy link

review-notebook-app bot commented Jan 28, 2026

View / edit / reply to this conversation on ReviewNB

fonnesbeck commented on 2026-01-28T22:08:28Z
----------------------------------------------------------------

Would be helpful to have a short visualization to give readers a sense of what the input data look like (related to my comment about dates above)


philpatton commented on 2026-01-29T00:45:58Z
----------------------------------------------------------------

Definitely! I added a little figure showing histograms for elevation and forest cover at quadrats, and a bar chart for the number of surveys per month.

@review-notebook-app
Copy link

review-notebook-app bot commented Jan 28, 2026

View / edit / reply to this conversation on ReviewNB

fonnesbeck commented on 2026-01-28T22:08:29Z
----------------------------------------------------------------

Could you not use a ZeroInflatedBinomial here?


philpatton commented on 2026-01-29T00:57:16Z
----------------------------------------------------------------

In a similar notebook on my personal webpage, I show how to use ZeroInflatedBinomial for models where $p$ is constant. I'm not positive but I don't think you can use it when $p$ varies by survey, because the zero-inflation status for sites with a detection is known. For example, if y[0, :] = [1, 0, 1], we know that the second zero is a sampling zero, and shouldn't be inflated, if that makes sense. But when detection is constant across surveys, we can sum the y's by row, such that y[0] = 2 and all zeros could be sampling or structural.

@review-notebook-app
Copy link

review-notebook-app bot commented Jan 28, 2026

View / edit / reply to this conversation on ReviewNB

fonnesbeck commented on 2026-01-28T22:08:29Z
----------------------------------------------------------------

Ah, okay. The linear date effect makes more sense if the surveys are only over 4 months. Should add this detail to the intro (or again, do some data viz).


philpatton commented on 2026-01-29T00:58:34Z
----------------------------------------------------------------

See comments above, but I added both the detail and the visualization.

@review-notebook-app
Copy link

review-notebook-app bot commented Jan 28, 2026

View / edit / reply to this conversation on ReviewNB

fonnesbeck commented on 2026-01-28T22:08:30Z
----------------------------------------------------------------

typo: Not -> Note


philpatton commented on 2026-01-29T00:58:43Z
----------------------------------------------------------------

Corrected

@fonnesbeck
Copy link
Member

This is very cool, @philpatton. I used to build a lot of these models, so getting one into examples is exciting. Only a couple of questions.

Copy link
Contributor Author

I added a little note that the surveys took place from January to April, and also added a note saying "see below for figure showing the predictors"


View entire conversation on ReviewNB

Copy link
Contributor Author

Definitely! I added a little figure showing histograms for elevation and forest cover at quadrats, and a bar chart for the number of surveys per month.


View entire conversation on ReviewNB

Copy link
Contributor Author

In a similar notebook on my personal webpage, I show how to use ZeroInflatedBinomial for models where $p$ is constant. But I don't think you can use it when $p$ varies by survey, because the zero-inflation status for sites with a detection is known. For example, if y[0, :] = [1, 0, 1], we know that the second zero is a sampling zero, and shouldn't be inflated, if that makes sense. But when detection is constant across surveys, we can sum the y's by row, such that y[0] = 2 and all zeros could be sampling or structural.


View entire conversation on ReviewNB

Copy link
Contributor Author

See comments above, but I added both the detail and the visualization.


View entire conversation on ReviewNB

Copy link
Contributor Author

Corrected


View entire conversation on ReviewNB

@philpatton
Copy link
Contributor Author

Thanks for the comments @fonnesbeck! I actually knew that, because I think we're academic cousins of some sort, since my master's adviser, Krishna Pacifici, also did his PhD with Mike Conroy.

Copy link
Member

@fonnesbeck fonnesbeck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@fonnesbeck fonnesbeck merged commit 270f33a into pymc-devs:main Jan 30, 2026
2 checks passed
@philpatton philpatton deleted the occupancy branch January 30, 2026 14:09
@philpatton
Copy link
Contributor Author

Awesome! Thanks for taking the time to review @fonnesbeck!

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

Successfully merging this pull request may close these issues.

2 participants