/
nomonknocat.bug
55 lines (42 loc) · 1.89 KB
/
nomonknocat.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
47
48
49
50
51
52
53
54
55
model { #MODEL 3
#for use on ppv behavioral data
#collapse across all monks and categories; model session-to-session variation
#IMPORTANT: all units are in SECONDS of juice!!!!
#initialize individual priors for each monk for each category
V ~ dnorm(0,1e2) #V
sess.std ~ dunif(1e-6,1) #session-to-session variance in category values: same for all categories
sess.prec <- pow(sess.std,-2)
logomega ~ dunif(-6,2)
log(omega.std) <- logomega #standard deviation of "trial-to-trial" overdispersion for a given monk
omega.prec <- pow(omega.std,-2)
#initialize choice scale parameters -- one distribution for all monks
#based on preliminary fit of distribution
t.loc ~ dunif(0,0.5)
t.scale ~ dunif(1e-4,0.1)
t.df ~ dunif(0.1,50)
t.prec <- pow(t.scale,-2)
#draw values for each category for each session, along with precisions for the t distribution
for (ind in 1:numsess){
pred.v[ind] <- V
v[ind] ~ dnorm(pred.v[ind],sess.prec) #all draws are independent, with monk-specific sd
resid.v[ind] <- v[ind]-pred.v[ind]
choice.scale[ind] ~ dt(t.loc,t.prec,t.df)T(0,) #scale factor for dv scale
choice.prec[ind] <- pow(choice.scale[ind],-1)
}
#loop over distinct decisions
for (ind in 1:N){
pred.lp[ind] <- choice.prec[session[ind]]*(dv[ind]+v[session[ind]]) #prediction for logit(p)
linpred[ind] ~ dnorm(pred.lp[ind],omega.prec)
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 ##########
ppred.v ~ dnorm(V,sess.prec) #generate a fake set of session pses for each monk
ppred.choice.scale ~ dt(t.loc,t.prec,t.df)T(0,) #generate a session choice scale
for (ind2 in 1:10) {
ppred.resid.lp[ind2] ~ dnorm(0,omega.prec) #generate several overdispersion residuals
}
}