Solutions to Practical 19

1.  The offset column can be created in the calculate window as follows:

Then we can name the column ‘logpar’ in the Names window. The categorical variables can be defined as categorical by bringing up the Names window and then clicking on the categories button which brings up the following window (e.g. for type)

We now click on Apply and then on Quit

2.  We will start by fitting a Null model as follows:

Note these results are after 5000 iterations but we will run all other models for 50,000 after a burnin of 5,000 and thinning factor 10. To set up the offset you need to have clicked on the π on the second line to bring up the required box.

The DIC for this model is

->BDIC

Bayesian Deviance Information Criterion (DIC)

Dbar D(thetabar) pD DIC

538.98 538.01 0.97 539.95

If we try each of the three predictors separately we get

Predictor / pD / DIC
Type / 3.96 / 527.51
Sex / 1.91 / 541.31
Age / 2.73 / 510.33

This shows that age is the most important predictor and type is also significant. We will now try some further models:

Predictor / pD / DIC
Type+Age / 5.68 / 492.41
Type+Age+Sex / 6.90 / 491.63
Type+Age+Type*Age / - / -

Note that a model with both type and age is significantly better. A model with all three predictors doesn’t give a significantly better DIC (although it is slightly better). We tried adding interactions but the model had difficulty converging suggesting we do not have enough data to fit all the interactions. The model with type and age is as follows:

Interestingly the effect of age categories 1 and 2 is fairly similar and a model with an alternative age>12 months predictor gives a marginally better model with DIC given below

->BDIC

Bayesian Deviance Information Criterion (DIC)

Dbar D(thetabar) pD DIC

486.15 481.30 4.85 491.01

3.  Random effect modelling:

If we again begin with the NULL model but with farm effects we get:

If we look at the DIC diagnostic we see that this model is far better than any of the models we have thus far fitted

->BDIC

Bayesian Deviance Information Criterion (DIC)

Dbar D(thetabar) pD DIC

272.79 252.56 20.22 293.01

If we repeat our attempts of adding predictors into this model we get the following:

Predictor / pD / DIC
Type / 23.01 / 296.68
Sex / 21.49 / 287.62
Age / 22.42 / 266.16
Age + Sex / 23.19 / 264.97
Type + Age + Sex / 25.56 / 267.44
Age>0 + Sex / 22.19 / 264.07

So we see that in the random effects modelling framework (i.e. after accounting for clustering in farms) type of animal ceases to be important as this is picked up in the farm effects while sex of animal becomes (borderline) significant. If we run the models for Age alone and Age+Sex for 500k iterations and we still get Age+Sex as the better model (DIC 264.76 vs 266.16)

The adventurous among you might now like to try fitting random coefficients for age and sex! However neither appear to converge in the quasilikelihood methods.

4.  Note no solutions are given here but you should hopefully get the same conclusions only with less iterations in WinBUGS.

S19-4