florianhartig / BayesianTools

General-Purpose MCMC and SMC Samplers and Tools for Bayesian Statistics
https://cran.r-project.org/web/packages/BayesianTools/index.html
117 stars 29 forks source link

Spatially constrained priors? #258

Open khufkens opened 1 year ago

khufkens commented 1 year ago

Hi @florianhartig

Thanks again for this nice package, which has served me well in the past!

I was wondering if you know how to construct spatially constraint priors.

I'm using BT to fit a sky illuminance model to light logger data to retrieve spatial positions. However, depending on the species, the locations are spatially constrained to land. How would you go about this problem of creating a spatially constraint prior?

For reference, here is some underlying theory (still rough around the edges but it should give you an idea): https://bluegreen-labs.github.io/skytrackr/articles/introduction.html

Currently I use a stepwise method where the previous location is used to define a bounding box of potential solutions (setting lower and upper bounds). While this is good this is not perfect, and gives issues as there are still "solutions" outside any reasonable domain.

https://github.com/bluegreen-labs/skytrackr

florianhartig commented 8 months ago

Hello Koen,

sorry that it took me so long to answer.

Regarding the prior: can't you just write in the prior: if not on land set likelihood -Inf or subtract a certain amount from the log likelihood (if you don't want to impose hard constraints)?

I also saw that you compared MCMC (DEzs) with an SMC - this makes sense, just wanted to note that there was an SMC in BT, but not a very good one, but we have worked on a more sophisticated SMC in

Speich, M., Dormann, C. F., & Hartig, F. (2021). Sequential Monte-Carlo algorithms for Bayesian model calibration–A review and method comparison✰. Ecological Modelling, 455, 109608.

The code for this SMC is still in the development branch, I still have to merge with the main branch. I thought this could be possibly of interest.

Best Florian

khufkens commented 8 months ago

Hi Florian,

No worries, this is just a side project, with low priority. Will look into the suggested strategy - and will have a look at the dev branch as well ! Thanks for the pointers, will keep you posted!

Cheers, K

florianhartig commented 8 months ago

ok, great. p.s.: I wrote likelihood but would be more logical to put this into the prior although technically there is no difference.