Douglas Bates vas escriure el dia dl, 08 oct 2012:
> What tools are popular for the analysis and visualization of samples
> created by stan? In particular, I would be interested in tools that use
> both lp__ and the parameter values.
Hi all,
Although this was posted several days ago, I would like to add that there
is a new package in R called "ggmcmc" that is intended to do precisely
that: visual inspection of convergence. Now it only shows the usual plots
(densities, traceplots, running means, comparisons of full chain and last
part, autocorrelations, crosscorrelations, histograms and even
caterpillarplots), but I am planning to extend it to show visually the
formal diagnostics.
To use it in stan:
install.packages("ggmcmc", dependencies=TRUE)
Assume that 'm' is the result of a call to stan(), with the default 4
chains, then:
-----8<---------------
library(ggmcmc)
s <- extract(m, inc_warmup=FALSE)
s <- mcmc.list(mcmc(s[,1,-4]), mcmc(s[,2,-4]), mcmc(s[,3,-4]), mcmc(s[,4,-4]))
S <- ggs(s)
-----8<---------------
And now 'S' is an object ready to be plotted using ggmcmc
(ggs_traceplot(S), ggs_running(S), ...)
Or simply the wrapper function "ggmcmc(S)".
If stan is used without 'rstan', and the samples have been stored in
s_1.csv and s_2.csv:
-----8<---------------
library(coda)
s1 <- read.table("s_1.csv", sep=",", header=TRUE)
s2 <- read.table("s_2.csv", sep=",", header=TRUE)
s.mcmc <- mcmc.list(mcmc(s1[,-c(1:3)]), mcmc(s2[,-c(1:3)]))
S <- ggs(s.mcmc)
-----8<---------------
I have written a detailed example on how to process Stan samples in ggmcmc:
http://blog.xavier-fim.net/2012/10/processing-stan-samples-with-ggmcmc
And there is a general introduction to ggmcmc:
http://xavier-fim.net/packages/ggmcmc/
Hope this helps,
--
- Xavier -