/
model.bug
62 lines (48 loc) · 2.22 KB
/
model.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
56
57
58
59
60
61
62
model { #MODEL 6
#for use on ppv behavioral data
#for each image category, each monkey has a session-to-session distribution of social value
#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,category]
}
sess.std[ind] ~ dunif(1e-6,1) #session-to-session variance in category values: same for all categories
sess.prec[ind] <- pow(sess.std[ind],-2)
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)
}
#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,1:numcat] <- V[sessvec[ind],]
v[ind,1:numcat] ~ dmnorm(pred.v[ind,],sess.prec[sessvec[ind]]*W) #all draws are independent (W=diag) with monk-specific sd
resid.v[ind,1:numcat] <- 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],piccat[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] ~ dmnorm(V[ind,],sess.prec[ind]*W) #generate a fake set of session pses for each monk
ppred.choice.scale[ind] ~ dt(t.loc,t.prec,t.df)T(0,) #generate a session choice scale
for (ind2 in 1:10) {
ppred.resid.lp[ind,ind2] ~ dnorm(0,omega.prec[ind]) #generate several overdispersion residuals
}
}
}