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

Use nimbleEcology and/or my own dHMM likelihood? #21

Open
oliviergimenez opened this issue Aug 27, 2023 · 0 comments
Open

Use nimbleEcology and/or my own dHMM likelihood? #21

oliviergimenez opened this issue Aug 27, 2023 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@oliviergimenez
Copy link
Owner

There are several tricks that we need to know to use nimbleEcology::d(D)HMM(o)(), including i) can't accomodate individuals with first == K and ii) doesn't condition on first capture. I wonder whether I should use my own likelihood w/ forward algo. See extracts of discussions from the NIMBLE users mailing list below.

What nimble is trying to tell you is that the dHMM distribution expects a dimension=1 node for the "value", which means a vector. Generally, "y[i,(first[i]+1):K]" will be a vector, except when first[i] = K for some value(s) of i, in which case that reduces to a single value, or a scalar, or a dimension=0 quantity. Unfortunately, at this point, nimble cannot distinguish between dimension=0 scalars, and vectors of length 1, which is causing the error you're seeing.

What` you'll have to do to get around this, since capture histories of length=1 generally do not contribute anything to inference, is to remove the capture histories for which first[i]=K from the dataset - remove the individuals that were first sighted on the final sampling occasion K.

This generally won't affect inference, unless you were also doing inference on the initial state probabilities "init[1:9]", which it appears you are not, since those appear to be hard-coded as c(1,0,0,0,....) in your model, meaning you condition on the initial state of capture being state 1, and also individuals being observed in that first time period. So removing these individuals won't affect the inferences from your model, it will just require a little bit of data manipulation, and changing the value of N.

I think Daniel's response is exactly correct. dHMM doesn't condition on first capture, meaning that we expect you to have at least two observations of each individual. Since a one-observation individual has a simpler likelihood you could probably handle those separately; that's another workaround that could work for you. Or, you could include the first instance of each individual and provide y[i, first[i] : K] as Daniel suggested. If you want to condition on first capture I think you could do that pretty easily by hard-coding your detection matrix for the first event for each individual. Let me know if this is unclear and if you want any support going in one of these directions!

See solution for the CJS model by Jay Rotella here https://groups.google.com/g/nimble-users/c/_anpyNTx1_I/m/z2JMHAgmAAAJ

I think Daniel's response is exactly correct. dHMM doesn't condition on first capture, meaning that we expect you to have at least two observations of each individual. Since a one-observation individual has a simpler likelihood you could probably handle those separately; that's another workaround that could work for you. Or, you could include the first instance of each individual and provide y[i, first[i] : K] as Daniel suggested. If you want to condition on first capture I think you could do that pretty easily by hard-coding your detection matrix for the first event for each individual. Let me know if this is unclear and if you want any support going in one of these directions!

@oliviergimenez oliviergimenez self-assigned this Aug 27, 2023
@oliviergimenez oliviergimenez added the enhancement New feature or request label Aug 27, 2023
@oliviergimenez oliviergimenez changed the title nimbleEcology vs my own dHMM likelihood? Use nimbleEcology and/or my own dHMM likelihood? Aug 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant