Download Bayesian Cognitive Modeling: A Practical Course

Transcript
Censored Data
63
160
140
95%
0.39 − 0.41
Posterior Density
120
100
80
60
40
20
0
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
Rate
t
Fig. 5.9
Posterior density for Cha Sa-soon’s rate of answering questions correctly.
The script ChaSaSoon.txt implements this graphical model in WinBUGS.
# ChaSaSoon Censored Data
model
{
for (i in 1:nattempts){
# If the Data Were Unobserved y[i]=1, Otherwise y[i]=1
z.low[i] <- 15*equals(y[i],1)+0*equals(y[i],0)
z.high[i] <- 25*equals(y[i],1)+n*equals(y[i],0)
z[i] ~ dbin(theta,n)I(z.low[i],z.high[i])
}
# Uniform Prior on Rate Theta
theta ~ dbeta(1,1)
}
Note the use of the equals command, which returns 1 when its arguments match,
and 0 when they mismatch. Thus, when y[i]=1, for censored data, z.low[i] is set
to 15 and z.hi[i] is set to 25. When y[i]=0 z.low[i] is set to 0 and z.hi[i]
is set to n. These z.low[i] and z.hi[i] values are then applied to censor the
Binomial distribution that generates the test scores.
The code ChaSaSoon.m or ChaSaSoon.R applies the model to the data from Cha
Sa-soon. The posterior density for θ is shown in Figure 5.9, and can be seen to be
relatively peaked. Despite the fact that we do not know the actual scores for 949
of the 950 results, we are still able to infer a lot about θ.