
10.3 Testing the Equality of Normal Means When Samples Are Paired 367
#microdamage.odc
model{
for (i in 1:n){
score[i] ~ dnorm(mu[age[i]], prec[age[i]])
}
mu[1] ~ dnorm(0, 0.00001)
mu[2] ~ dnorm(0, 0.00001)
prec[1] ~ dgamma(0.001, 0.001)
prec[2] ~ dgamma(0.001, 0.001)
d <- mu[1] - mu[2]
r <- prec[1]/prec[2]
ph1 <- step(-d) #ph1=1 if d < 0
ph0 <- 1-ph1
}
DATA
list(n=30,score=c(0.790, 0.944, 0.958, 1.011, 0.714, 0.256, 0.406,
0.135, 0.316, 0.179, 1.264, 1.410, 1.160, 1.374,
0.601, 1.029, 1.264, 1.183, 1.856, 1.899, 0.486,
0.813, 0.820, 1.327, 1.325, 2.012, 1.026, 1.130,
0.605, 0.870),
age = c(1,1,1,1,1,1,1,1,1,1,1,1,1,
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2))
INITS
list( mu = c(1,1), prec=c(1,1))
mean sd MC error val2.5pc median val97.5pc start sample
d –0.4194 0.1771 5.438E-4 –0.7688 –0.4192 –0.071 1001 100000
mu[1] 0.7339 0.1326 4.099E-4 0.4703 0.7338 0.9968 1001 100000
mu[2] 1.153 0.118 3.685E-4 0.9188 1.153 1.389 1001 100000
ph0 0.01011 0.1 3.112E-4 0.0 0.0 0.0 1001 100000
ph1 0.9899 0.1 3.112E-4 1.0 1.0 1.0 1001 100000
r 1.244 0.7517 0.002553 0.3456 1.071 3.155 1001 100000
The posterior probability of H
1
is 0.9899, thus H
0
is rejected. Note that
the credible interval for the difference d is all negative, suggesting that the
two-sided test would be significant (in Bayesian terms). The ratio of precisions
(and variances) r has a credible set that contains 1; thus the variances could
be assumed equal. This assumption has no bearing on the Bayesian procedure
(unlike the classical approach).
10.3 Testing the Equality of Normal Means When
Samples Are Paired
When comparing two treatments it is desirable that the experimental units be
as alike as possible so that the difference in responses can be attributed chiefly