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

Continuous variable behaving as a categoric in the tMsPGOcc model #49

Open
Xuletajr opened this issue Jan 27, 2025 · 2 comments
Open

Continuous variable behaving as a categoric in the tMsPGOcc model #49

Xuletajr opened this issue Jan 27, 2025 · 2 comments

Comments

@Xuletajr
Copy link

Dear Jeff,

I have been working on fitting a dynamic model (tMsPGOcc) to a bird community dataset, aiming to explore the community's occupancy response to a categorical variable, "Type," which represents land use/land cover (farming, restoration, and forest), as well as continuous landscape variables like NDVI. However, I encountered an issue when including both the continuous variable (NDVI) and the categorical variable ("Type") in the model. Specifically, the continuous variable appears to behave as if it were categorical. The model output generates 119 parameters for NDVI—one less than the total number of sites (120). To investigate further, I ran a single-species model (tPGOcc) for one species to check if the behavior persists, and the issue remained the same. I’ve attached a screenshot below to illustrate the problem (please disregard the low Rhat and ESS values, as I used low n.samples just to test the model's operation.).

Image

If I exclude the categorical variable "Type" and retain only the continuous variable (NDVI), the issue disappears entirely, and the model output behaves as expected. Additionally, I conducted another test by selecting only the first year of sampling and running a static multispecies model (msPGOcc). In this case, the output was correct, generating a single parameter for NDVI at the community level. These small tests suggest that the issue may be specific to the dynamic models, which seem to be misinterpreting my input data. Below, I’ve included the tMsPGOcc output using only the continuous variable for your reference.

Image

I look forward to hearing your thoughts and guidance on this.

@doserjef
Copy link
Collaborator

Hi José,

Thanks very much for bringing this to my attention. This indeed is a bug under some specific circumstances with the multi-season models. This bug only seems to happen when the categorical variable only varies across space and not also across seasons. In other words, the bug occurs when the categorical variable is given as a vector in the occ.covs portion of the data list. This isn't super nice behavior, so apologies for that. The quickest way to fix this would just be to supply the categorical variable as a site x season matrix in the data list (with the site-specific values simply repeated across the columns), which should make the problem go away. Let me know if that doesn't solve the issue for you.

I'm going to keep the issue open for now, as it is something I should fix to prevent the odd behavior from happening. Thanks again for pointing this out.

Jeff

@Xuletajr
Copy link
Author

Xuletajr commented Feb 8, 2025

Hi Jeff,

Thank you so much for your quick response and for looking into this issue. I really appreciate the explanation and the suggested fix.

I followed your recommendation and supplied the categorical variable as a site × season matrix in the data list, and that completely resolved the issue—the model now runs perfectly!

Thanks again for your help and for keeping this on your radar for a future fix. I appreciate your work on this great package!

Best,
José

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