Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecture 16 MCMC for Poisson response models. Lecture Contents Multilevel Poisson Model MCMC Algorithms for Poisson Models MLwiN for Poisson models WinBUGS.

Similar presentations


Presentation on theme: "Lecture 16 MCMC for Poisson response models. Lecture Contents Multilevel Poisson Model MCMC Algorithms for Poisson Models MLwiN for Poisson models WinBUGS."— Presentation transcript:

1 Lecture 16 MCMC for Poisson response models

2 Lecture Contents Multilevel Poisson Model MCMC Algorithms for Poisson Models MLwiN for Poisson models WinBUGS for Poisson models Comparisons

3 Multilevel Poisson model The Poisson distribution is used to model count data. It is often used in disease data as an approximation to the Binomial distribution where the exposure (number of trials) is used as an offset variable. In the practical we will look in detail at a veterinary epidemiology dataset on TB cases in animal herds in Canada. Here the response is the number of cases of TB in the period 1985 to 1994 in herds of cattle, cervids and bison. Note that the data contains only herds which were infected in outbreaks of TB and the data has been falsified to meet confidentiality regulations.

4 Multilevel Poisson Regression A multilevel Poisson regression model can be written as follows: You will notice the offset (log(exp ij )) which in the TB example is the number of animal days at risk in the group. Including this offset allows comparison of rates rather than number of cases which is more sensible as otherwise the model will simply predict that more cases are seen in herds with more days at risk!

5 Bayesian Multilevel Poisson model To extent the model into a Bayesian framework we need to include priors for the fixed effects and between herd variance. We will use the standard diffuse priors as shown below:

6 MCMC Algorithm Our MLwiN algorithm has 3 steps: 1. Generate β i by Univariate Normal MH Sampling in MLwiN or Gamerman method in WinBUGS. 2. Generate each u j by Univariate Normal MH Sampling in MLwiN or AR sampling in WinBUGS. 3. Generate 1/σ u 2 from its Gamma conditional distribution.

7 A final model for TB-Real ? We will consider here only the following model for the dataset which contains all feasible predictors. The model to the right has been fitted using 1 st order MQL estimation. Note: to construct this model you will need to make predictors categorical via the Names window and construct the offset via the Calculate window.

8 MLwiN MH Estimation Using MH in MLwiN gives the following estimates after 50,000 iterations:

9 Trajectories plot The (thinned) trajectories are as follows:

10 WinBUGS code model { # Level 1 definition for(i in 1:N) { reactors[i] ~ dpois(mu[i]) log(mu[i]) <- offs[i] + beta[1] * cons[i] + beta[2] * type_2[i] + beta[3] * type_3[i] + beta[4] * type_5[i] + beta[5] * sex_2[i] + beta[6] * age_1[i] + beta[7] * age_2[i] + u2[farm_id[i]] * cons[i] } # Higher level definitions for (j in 1:n2) { u2[j] ~ dnorm(0,tau.u2) } # Priors for fixed effects for (k in 1:7) { beta[k] ~ dflat() } # Priors for random terms tau.u2 ~ dgamma(0.001000,0.001000) sigma2.u2 <- 1/tau.u2 } Here we see the use of dpois for a Poisson distribution. Note that when code is generated via MLwiN the offset is always named offs. Fortunately WinBUGS allows variable names to include the underscore character.

11 WinBUGS timing comparison WinBUGS took 2 minutes 4 seconds for 55,000 iterations compared with 15 seconds in MLwiN. The chain for the intercept and two worst mixing fixed effects were as follows:

12 WinBUGS/MLwiN estimates The following estimates were produced: Parameter1 st MQLMLwiNWinBUGS β0β0 -10.071-11.231 (-12.96, -9.78)-11.289 (-13.09, -9.68) β1β1 -0.388-0.405 (-1.082, 0.289)-0.405 (-1.065, 0.248) β2β2 -0.412-0.241 (-1.205, 0.752)-0.238 (-1.219, 0.721) β3β3 -0.319-0.250 (-2.019, 1.303)-0.240 (-1.992, 1.322) β4β4 -0.350-0.352 (-0.760, 0.053)-0.348 (-0.772, 0.051) β5β5 2.7152.873 (1.614, 4.503)2.919 (1.569, 4.606) β6β6 2.4572.626 (1.400, 4.235)2.671 (1.374, 4.331) σ2uσ2u 2.9042.016 (0.964, 3.883)2.043 (0.964, 4.029)

13 Effective sample size comparison ParameterMLwiNWinBUGSRatio β0β0 662153.26 β1β1 52028295.44 β2β2 30413284.37 β3β3 86543625.04 β4β4 3666225216.14 β5β5 772373.08 β6β6 722243.11 σ2uσ2u 3244154984.78 Note that the Ratio in ESS figures below have to be balanced by the fact that MLwiN is 124/15 = 8.27 times faster!

14 Information for the practical In the final practical of the week you are asked to look at fitting more Poisson models to the tb-real dataset. You can use the DIC for Poisson models in both MLwiN and WinBUGS to find firstly the best single level model and then the best random effects model.


Download ppt "Lecture 16 MCMC for Poisson response models. Lecture Contents Multilevel Poisson Model MCMC Algorithms for Poisson Models MLwiN for Poisson models WinBUGS."

Similar presentations


Ads by Google