epinowcast
Loading...
Searching...
No Matches
obs_lpmf.stan
Go to the documentation of this file.
1
28real obs_lpmf(array[] int obs, vector log_exp_obs, array[] real phi,
29 int model_obs) {
30 if (model_obs == 0) {
31 // Poisson model
32 return poisson_log_lpmf(obs | log_exp_obs);
33 } else if (model_obs == 1) {
34 // NB2 parameterisation: variance = mu + mu^2/phi (constant overdispersion)
35 return neg_binomial_2_log_lpmf(obs | log_exp_obs, phi[1]);
36 } else {
37 // NB1 parameterisation: variance = mu + phi * mu, so phi_nb2 = mu * phi
38 return neg_binomial_2_log_lpmf(
39 obs | log_exp_obs, exp(log_exp_obs + log(phi[1]))
40 );
41 }
42}
43
44real obs_lpmf(int obs, real log_exp_obs, array[] real phi, int model_obs) {
45 if (model_obs == 0) {
46 // Poisson model
47 return poisson_log_lpmf(obs | log_exp_obs);
48 } else if (model_obs == 1) {
49 // NB2 parameterisation: variance = mu + mu^2/phi (constant overdispersion)
50 return neg_binomial_2_log_lpmf(obs | log_exp_obs, phi[1]);
51 } else {
52 // NB1 parameterisation: variance = mu + phi * mu, so phi_nb2 = mu * phi
53 return neg_binomial_2_log_lpmf(
54 obs | log_exp_obs, exp(log_exp_obs + log(phi[1]))
55 );
56 }
57}
real obs_lpmf(array[] int obs, vector log_exp_obs, array[] real phi, int model_obs)
Definition obs_lpmf.stan:28