-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathM2s2596860.jags
50 lines (37 loc) · 1.3 KB
/
M2s2596860.jags
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
# Defining the updated Bayesian model with same set of
# hyperparameters
model {
# Initialization of the prior parameters tau and tau_o
tau ~ dgamma(4,0.04)
tau_o ~ dgamma(4,0.04)
# Calculating x values by iterating through each experiment
for (j in 1:n_experiments) {
# Initializing x[1,j] and x[2,j] with normal distributions
x[1,j] ~ dnorm(0,100)
x[2,j] ~ dnorm(x[1,j],tau)
#Iterating through remaining doses for each experiment
for (i in 3:n_doses) {
x[i,j] ~ dnorm(2* x[i-1,j] - x[i-2,j],tau)
}
}
# Calculating m and mu values for each experiment and dose
for(j in 1:n_experiments) {
m[1,j] <- 0
mu[1,j] <- 1
# Iterating through doses for each experiment to
# calculate m and mu values
for (i in 2:n_doses) {
m[i,j] <- m[i-1,j]-exp(x[i-1,j])
mu[i,j] <- exp(m[i,j])
}
}
# Modelling the effect for each dose in every experiment
for (j in 1:n_experiments) {
# Prior for Mj parameter following an uniform distribution
Mj[j] ~ dunif(0,4000)
for (i in 1:n_doses) {
# Model for effect[i,j] for each experiment and dose
effect[i,j] ~ dnorm(Mj[j] * mu[i,j] , tau_o)
}
}
}