Skip to content

Commit ed3e88c

Browse files
Bugs / Jags code
Bayesian state-space model. Can be run in Openbugs or Jags.
1 parent fd8543c commit ed3e88c

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

BayesianStateSpace.txt

+15-15
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
model{
22
for(s in 1:NSubjects) {
33
for(t in TrialStart:TrialEnd) {
4-
xmu[t,s] <- A[s] * x[t , s] - v[t,s] * B[s] * u[t,s]
5-
x[t+1,s] ~ dnorm(xmu[t,s], q[s])
6-
y[t,s] ~ dnorm(x[t, s], r[s])
7-
u[t,s] <- y[t,s] + p[t,s];
4+
xmu[t,s] <- A[s] * x[t , s] - v[t,s] * B[s] * e[t,s] # Equation for the aiming angle
5+
x[t+1,s] ~ dnorm(xmu[t,s], etaprec[s]) # Aiming angle plus noise
6+
y[t,s] ~ dnorm(x[t, s], epsilonprec[s]) # Equation for the movement angle
7+
e[t,s] <- y[t,s] + p[t,s] # Equation for movement error
88
}
9-
q[s] ~ dgamma(1.0E-3, 1.0E-3)
10-
r[s] ~ dgamma(1.0E-3, 1.0E-3)
9+
etaprec[s] ~ dgamma(1.0E-3, 1.0E-3) # Prior distribution for the precision etaprec[s]
10+
epsilonprec[s] ~ dgamma(1.0E-3, 1.0E-3) # Prior distribution for the precision epsilonprec[s]
1111

12-
logit(A[s]) <- A1[s]
13-
A1[s] ~ dnorm(A1mu, A1prec)
14-
logit(B[s]) <- B1[s]
15-
B1[s] ~ dnorm(B1mu, B1prec)
16-
x[1,s] ~ dnorm(0.0, 1.0E3)
12+
logit(A[s]) <- A1[s] # Logit of A1
13+
A1[s] ~ dnorm(A1mu, A1prec) # Prior distribution for A1[s]
14+
logit(B[s]) <- B1[s] # Logit of B1
15+
B1[s] ~ dnorm(B1mu, B1prec) # Prior distribution for B1[s]
16+
x[1,s] ~ dnorm(0.0, 1.0E3) # Initialization of the first aiming angle at 0
1717
}
1818

19-
A1mu ~ dnorm(0.0, 1.0E-3)
20-
A1prec ~ dgamma(1.0E-3, 1.0E-3)
21-
B1mu ~ dnorm(0.0, 1.0E-3)
22-
B1prec ~ dgamma(1.0E-3, 1.0E-3)
19+
A1mu ~ dnorm(0.0, 1.0E-3) # Hyperparameter for the mean of A1
20+
A1prec ~ dgamma(1.0E-3, 1.0E-3) # Hyperparameter for the precision of A1
21+
B1mu ~ dnorm(0.0, 1.0E-3) # Hyperparameter for the mean of B1
22+
B1prec ~ dgamma(1.0E-3, 1.0E-3) # Hyperparameter for the precision of B1
2323
}

0 commit comments

Comments
 (0)