/
monkcatpooling.bug
46 lines (35 loc) · 1.62 KB
/
monkcatpooling.bug
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
model { #MODEL 1
#for use on ppv behavioral data
#each monkey has a single curve pooled across all sessions for each category
#IMPORTANT: all units are in SECONDS of juice!!!!
#initialize individual priors for each monk for each category
for (ind in 1:nummonk){
for (ind2 in 1:numcat){
V[ind,ind2] ~ dnorm(0,1e2) #V[monk]
choice.scale[ind,ind2] ~ dt(0,1e-3,1)T(0,) #scale factor for dv scale, very weakly informative
choice.prec[ind,ind2] <- pow(choice.scale[ind,ind2],-1) #monk-specific precision for dv
}
logomega[ind] ~ dunif(-6,2)
log(omega.std[ind]) <- logomega[ind] #standard deviation of "trial-to-trial" overdispersion for a given monk
omega.prec[ind] <- pow(omega.std[ind],-2)
}
#loop over distinct decisions
for (ind in 1:N){
pred.lp[ind] <- choice.prec[sessvec[session[ind]],piccat[session[ind]]]*
(dv[ind]+V[sessvec[session[ind]],piccat[session[ind]]]) #prediction for logit(p)
linpred[ind] ~ dnorm(pred.lp[ind],omega.prec[sessvec[session[ind]]])
resid.lp[ind] <- linpred[ind] - pred.lp[ind] #residual for logit(p)
logit(p.img[ind]) <- linpred[ind]
Nimg[ind] ~ dbin(p.img[ind],Ntot[ind])
pred.N[ind] <- p.img[ind]*Ntot[ind]
resid.N[ind] <- Nimg[ind]-pred.N[ind]
}
########## now draw some things we care about ##########
for (ind in 1:nummonk){ #for each monk
ppred.v[ind,1:numcat] <- V[ind,] #generate a fake set of session pses for each monk
ppred.choice.scale[ind,1:numcat] <- choice.scale[ind,] #generate monk choice scale
for (ind2 in 1:10) {
ppred.resid.lp[ind,ind2] ~ dnorm(0,omega.prec[ind]) #generate several overdispersion residuals
}
}
}