Created
February 4, 2021 21:54
-
-
Save omarfsosa/6416ac11e8035b04a4fa334da290e6b3 to your computer and use it in GitHub Desktop.
Modelling poisson data with selection bias.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
functions { | |
real normalisation(real lam, int lb, int ub) { | |
real result = 0; | |
for (x in lb:ub) { | |
result += (lam^x)/tgamma(x+1); | |
} | |
result *= exp(-lam); | |
return result; | |
} | |
} | |
data { | |
int N; | |
int L; | |
int U; | |
int<lower=L, upper=U> y[N]; | |
} | |
parameters { | |
real<lower=0> beta; | |
} | |
model { | |
for (val in y) { | |
target += poisson_lpmf(val | beta) - log(normalisation(beta, L, U)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment