BiologicalRecordsCentre / sparta

Species Presence/Absence R Trends Analyses
http://biologicalrecordscentre.github.io/sparta/index.html
MIT License
21 stars 24 forks source link

Improving the Julian Date formulation #119

Closed drnickisaac closed 5 years ago

drnickisaac commented 5 years ago

The current model fits a polynomial term for detectability, following van Strien et al 2010. I am concerned this is numerically unstable, possibly because different combinations of parameter values have quite very similar fits. Yesterday (1/3/19) I wrote a simulation to create data for sparta. I found that sparta was not particularly effective in estimating the parameter values for a small but rich dataset (few sites but many visits per site per year). I wonder whether an alternative formulation would be better. Specifically, I envisage the detection phenology being fitted as a normal distribution. The beta1 parameter would estimate the mean detection date and beta2 the standard deviation. To implement this we’d probably have to code up the density function: f(x) = 1/(√(2 π) σ) e^-((x - μ)^2/(2 σ^2)) where μ is the mean of the distribution and σ the standard deviation. In R:

norm_dens <- function(beta1, beta2, JulDate){
  1/((2*pi)^0.5 * beta2) * exp(-((JulDate - beta1)^2 / (2* beta2^2)))
}`

which is testable as follows:

days <- 1:36*10
x<-sapply(days, norm_dens, beta1=182, beta2=20)
plot(days, x)

In BUGS:

f_x <- 1/((2*pi)^0.5 * beta2) * exp(-((JulDate[k] - beta1)^2 / (2* beta2^2)))

The f_x line would be a modifier on the basic detection model.

@JackHHatfield91 does this make sense? I suspect this would be easy to implement in BUGS: the difficulty would be in editing getObsModel to allow ensure backwards compatibility.

JHHatfield commented 5 years ago

Julian date is currently centred on 1st July. Do we still want this to be the case?

drnickisaac commented 5 years ago

Noting that we may not want to center under the alternate formulation above

JHHatfield commented 5 years ago

Now incorporated