rbchan / unmarked

R package for hierarchical models in ecological research
https://rbchan.github.io/unmarked/
37 stars 25 forks source link

Add distsampOpen function #167

Closed kenkellner closed 4 years ago

kenkellner commented 4 years ago

Open-population distance sampling function. Basically, a hybrid of pcountOpen and gdistsamp with most of the options of both. I have added a test suite for it but there are too many combinations of configuration options to cover completely. It'll need some real world testing.

Windows binary: unmarked_0.13-2.9000.zip Source package: unmarked_0.13-2.9000.tar.gz

rbchan commented 4 years ago

Thanks Ken. I might be able to do some testing next week if you need help on that front. You could also test against the distsampOpen function in the "dso2" branch. I think it was was working for the half-normal case.

kenkellner commented 4 years ago

Thanks! I based this on dso2. You and Andy had most of the hard work done, I just added the other key functions and a few missing methods. I'll probably test it on the AHM book example if I get a chance next week, to make sure it matches up to JAGS results.

rbchan commented 4 years ago

OK, great. The only other things on my unmarked 1.0 wish list are:

Let me know if you have any interest in working on either of these. I could probably get to one or both of them eventually, but not soon.

kenkellner commented 4 years ago

I'll most likely take a look at both when I have time. Regarding predict for unmarkedRanef, I was thinking about this a bit and looking at your related code on the forums. Might it make more sense to add a posteriorSamples function rather than predict (e.g. just stopping your function 2 lines early)? Two possible advantages:

  1. I would expect users, especially newer ones, to have a tough time crafting a function a priori to act on the posterior samples from ranef either because they don't know what the input structure should be or because they aren't sure what they want the summary function to actually do until they play around with it. It seems like it would be easier to get the samples and then manipulate those as needed. This could have a show method kind of like unmarkedFrame that explicitly states what each dimension of the output corresponds to (site x time x simulation).

  2. You might want a bunch of different derived parameters and it doesn't make sense to repeatedly get new samples to calculate them when you could re-use the same samples.

I guess you could also just have a predict wrapper around posteriorSamples that also applies an arbitrary function.

rbchan commented 4 years ago

Glad to hear you're interested in working on these things. I like the idea of a posteriorSamples function with a show method for users that want to interact with the samples directly. And I'd be in favor of complementing this with a predict method that wraps around posteriorSamples.

One particularly useful type of posterior prediction that we might want to demonstrate in a vignette would be forecasting. It shouldn't be hard to demonstrate how forecasts (of the latent states or the future observations) can be made using colext, pcountOpen, and other dynamic models.

Eventually, all of this would benefit from accounting for uncertainty in the estimates of the hyperparameters, but that is no easy task and we can probably ignore it for now, as is typically done in Empirical Bayes.