model{
for(i in 1:n){
FEV[i] ~ dnorm(mu[i],tau)
mu[i] <- beta[1] + beta[2]*Age[i] + beta[3]*Smoke[i] + beta[4]*Age[i]*Smoke[i]
}
beta[1:r] ~ dmnorm(beta0[1:r],C0inv[1:r,1:r]) # BCJ prior
tau ~ dgamma(a,b)
#beta[1] ~ dnorm(0,0.001) # Diffuse prior
#beta[2] ~ dnorm(0,0.001)
#beta[3] ~ dnorm(0,0.001)
#beta[4] ~ dnorm(0,0.001)
#tau ~ dgamma(0.001,0.001)
## Estimate mean FEV for smokers and nonsmokers who are 10, ..., 19 years old
for(i in 1:10){
meanFEVs[i] <- beta[1] + (beta[2]+beta[4])*(i+9) + beta[3]
meanFEVns[i] <- beta[1] + beta[2]*(i+9)
}
## Easy to estimate relative means and mean differences as well
RM <- meanFEVns[9]/meanFEVs[9] ## RM comparing 18 year old smoker to 18 year old nonsmoker
MD <- meanFEVs[9]-meanFEVns[4] ## MD comparing 18 year old smoker to 13 year old nonsmoker
## Predict the FEV for a 20 year old smoker and nonsmoker
FEV20s ~ dnorm(mu20s,tau)
FEV20ns ~ dnorm(mu20ns,tau)
mu20s <- beta[1] + (beta[2]+beta[4])*20 + beta[3]
mu20ns <- beta[1] + beta[2]*20
}