Debian Codegraph @

tests/prob_prog/order-two/rb-command.Rev

raw
1 ## Two approaches to set up an order-two Markov model
2
3 ## Works
4
5 x[1] ~ dnNormal(0,1)
6
7 delta ~ dnNormal(0,sqrt(1/3))
8
9 x[2] := x[1] + delta
10
11 for (i in 1:98) {
12
13 x[i+2] ~ dnNormal(2 * x[i+1] - x[i],1)
14
15 }
16
17 print("Take 1, calculating log-probability of x[1]")
18
19 print(x[1].lnProbability())
20
21 clear()
22
23 ## Non-centered parameterization. Doesn't work (Rev will need to be force-closed)
24
25 x[1] ~ dnNormal(0,1)
26
27 delta ~ dnNormal(0,sqrt(1/3))
28
29 x[2] := x[1] + delta
30
31 for (i in 1:98) {
32
33 dx[i] ~ dnNormal(0,1)
34
35 x[i+2] := dx[i] - x[i] + 2 * x[i+1]
36
37 # # Use below print statement to watch how time to compute probability slows as model is built
38
39 print(x[1].lnProbability())
40 }
41
42 print("Take 2, calculating log-probability of x[1]")
43
44 print(x[1].lnProbability())
45
46 moves[1] = mvSlide(x[1])
47
48 mymodel = model(x[1])
49
50 # mymodel.graph("temp.dot",verbose=true,bg="honeydew2")
51
52 monitors[1] = mnScreen()
53
54 mymcmc = mcmc(mymodel, moves, monitors)
55
56 mymcmc.run(10)
57
58 q()