contactmodel / COVID19-Japan-Reff

218 stars 35 forks source link

Is the parameter of Gamma on the Stan code correct? #4

Closed kaz184 closed 4 years ago

kaz184 commented 4 years ago

In the model section of the Stan code, Gamma's parameters is like this: https://github.com/contactmodel/COVID19-Japan-Reff/blob/3bc9cf975e477bac5df85adad4c0a4bbd0494ab6/scripts/fit_infection.stan#L125

But if we want to use Gamma as Poisson distribution, the line needs to be like this: target += gamma_lpdf(tail(domestic_backproj, K-1) | Rt .* conv + 1, 1.0) because Gamma(y=λ | α=k+1, β=1) = λ^k exp(-λ) / Γ(k+1) = Poisson(k | λ) where k is integer.

Is this right?

aakhmetz commented 4 years ago

Hello––no, for the reference, see Li, Dushoff, Bolker 2018, Figure 2 therein.

In brief: if the Gamma distribution is to simulate continuous random variables, the Poisson distribution is for discrete counts, I don't think you can simply match their PDFs like you did.

Best regards, Andrei

ps: the formula is strange Gamma(y=λ | α=k+1, β=1) – what is the data, what are the parameters of the distribution here?

kaz184 commented 4 years ago

I employed the expression of Gamma distribution from Stan official doc.

I've misunderstood the intention of using Gamma distribution; domestic_backproj variable is a real-valued vector, it cannot be used as the data in Poisson distribution, and Gamma distribution is used to address this type mismatch problem. Now I'm convinced with that formulation is valid.

Thank you for taking your time to answer.

aakhmetz commented 4 years ago

Yes, there is a bit of trouble with continuous vs. discrete variable, and the (expected) backprojected values are not integers.

Best, Andrei

On Sat, 16 May 2020 at 18:06, kaz184 notifications@github.com wrote:

I employed the expression of Gamma distribution from Stan official doc https://mc-stan.org/docs/2_22/functions-reference/gamma-distribution.html .

I've misunderstood the intention of using Gamma distribution; domestic_backproj variable is a real-valued vector, it cannot be used as the data in Poisson distribution https://mc-stan.org/docs/2_18/functions-reference/poisson.html, and Gamma distribution is used to address this type mismatch problem. Now I'm convinced with that formulation is valid.

Thank you for taking your time to answer.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/contactmodel/COVID19-Japan-Reff/issues/4#issuecomment-629613697, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAQSSFXLQBFRCV5QW3AWE7TRRZJPXANCNFSM4NCZY2GQ .