mnModel - Monitor of Numeric Parameters
| posterior : | Bool (pass by value) |
| Should we print the joint posterior probability? | |
| Default : TRUE | |
| likelihood : | Bool (pass by value) |
| Should we print the likelihood? | |
| Default : TRUE | |
| prior : | Bool (pass by value) |
| Should we print the joint prior probability? | |
| Default : TRUE | |
| stochasticOnly : | Bool (pass by value) |
| Should we monitor stochastic variables only? | |
| Default : FALSE | |
| exclude : | String[] (pass by value) |
| Variables to exclude from the monitor | |
| Default : [ ] | |
| format : | String (pass by value) |
| Output format | |
| Default : separator | |
| append : | Bool (pass by value) |
| Should we append or overwrite if the file exists? | |
| Default : FALSE | |
| filename : | String (pass by value) |
| The name of the file for storing the samples. | |
| printgen : | IntegerPos (pass by value) |
| The number of generations between stored samples. | |
| Default : 1 | |
| separator : | String (pass by value) |
| The separator/delimiter between columns in the file. | |
| Default : | |
| version : | Bool (pass by value) |
| Should we record the software version? | |
| Default : FALSE |
# Binomial example: estimate success probability given 7 successes out of 20 trials
r ~ dnExp(10)
p := Probability(ifelse(r < 1, r, 1))
n <- 20
k ~ dnBinomial(n, p)
k.clamp(7)
mymodel = model(k)
moves = VectorMoves()
moves.append( mvScale(r, weight=1) )
# Set up a monitor for both r and p
all_params = mnModel(filename="all_params.log", printgen=10)
# Set up a monitor for r only
stoch_only = mnModel(filename="stoch_only.log", stochasticOnly=TRUE, printgen=10)
# Set up a monitor for p only
p_only = mnModel(filename="p_only.log", exclude=["r"], printgen=10)
# Apply the monitors and run a short simulation
mymcmc = mcmc(model=mymodel, moves=moves, monitors=[all_params, stoch_only, p_only])
mymcmc.run(generations=1000)