Fixed effect binomial model
Modify the fixed effect binomial code provided in class to perform the following exercises:
First, keep the number of binomial samples to n.sample=1 but change the number of trials for each sample to 10
by the statements:
>n.samples<-10
>n<-rep(10,n.samples)
Hint: when you perform these exercises, I suggest you take the code I wrote as a template, modify it, and save it for
each of the 4 cases below as different files!
1) simulate binomial data with p=0.4 and n=10 as above. Analyse with the Bayesian model for a binomial likelihood with vague prior p~dbeta(1,1) (note this is equivalent to dunif(0,1) and the same data with an informative prior p~dbeta(30,70), which is roughly equivalent to having a previous study with x=30 successes in n=100 trials. Hint: simulate the data, then run 2 bugs statements using that data with different model scripts (one for each prior)
2) now increase the number of trials to n=100 and repeat by
>n<-rep(100,n.samples)
Analyse with the vague and informative priors as above
3) Comment on the relative influence of the prior distribution for each case
Random effect binomial model
For the random effect binomial model, change the number of trials from 10 to 100 as above, and analyses with the given noniformative priors
mu~dnorm(0,0.001)
#put a uniform on the sd
sigma~dunif(0,10)
and 2 informative priors
mu~dnorm(-0.84,0.001)
(keep sigma the same)
and
mu~dnorm(-0.84,0.1)
(keep sigma the same)
Repeat the above but decrease number of trials to 10 per sample.
Model selection
For the n<-rep(n.trials=100,n.samples=10) generate data under the random effect model with p.avg=0.4 and sigma=1.0. Then compare 1) fixed effect model with p constant, 2) fixed effect model with p time varying and 3) random effect models using DIC, keeping the priors vague for each model, that is for the fixed effect model p~dunif(0,1) and for the random effect model mu~dnorm(0,0.001), sigma~dunif(0,10). What do you conclude?