There is a function pymc3.traceplot()
that plots the traceplots of the sampling process. I see that the function takes an argument lines
that takes a dictionary, in which you can pass the means as lines to be plotted. How would you go about doing this?
Asked
Active
Viewed 2,101 times
1 Answers
1
You can pass any value you want not only the mean.
theta_val = 0.35
pm.traceplot(trace, lines={'theta':theta_val})
theta
is the name of the variable in the model and theta_val
is the value you want to plot (overlap).
You can compute the mean from the trace by doing:
trace['theta'].mean()
or you can also do something like:
lines = {var:trace[var].mean() for var in trace.varnames}

aloctavodia
- 2,040
- 21
- 28
-
hey @aloctavodia, that works if you precompute the mean values for the variables. What if you want to programmatically compute the mean for each variable? – Nigel Ng Feb 15 '17 at 09:07
-
Hi! I edited my answer. Please, let me know if that is what you want. – aloctavodia Feb 15 '17 at 11:52
-
perfect! That was what I was looking for. – Nigel Ng Feb 16 '17 at 12:59