Skip to content

MCMC results into LaTeX

3 messages · Shige Song, Dieter Menne

#
Dear All,

What is the preferred way to get Bayesian analysis results (such as
those from MCMCpacki, MCMCglmm, and DPpackage) into LaTeX table
automatically? I have been using the "apsrtable" package and similar
functions in "memisc" package, but neither seems to handle MCMC output
directly. Many thanks.

Shige
#
Shige Song wrote:
It depends on what you want as output. Let's assume the summary of an
MCMCpack function:
First direct it to a variable, and check the available data frames. Then
output these with latex.

If you do this very often: latex is a generic, so you could write a simple
function that creates customized output for a class "summary.mcmc". For
example, it could output both statistics and quantiles together, and do
reasonable rounding based on the standard errors.

Dieter


library(MCMCpack)
library(Hmisc)
x<-rep(1:10,5)
y<-rnorm(50,mean=x)
qreg <- summary(MCMCquantreg(y~x))
str(qreg)
#List of 6
# $ statistics: num [1:3, 1:4] 0.3479 0.9029 0.3413 0.2602 0.0391 ...
#  ..- attr(*, "dimnames")=List of 2
#  .. ..$ : chr [1:3] "(Intercept)" "x" "sigma"
#  .. ..$ : chr [1:4] "Mean" "SD" "Naive SE" "Time-series SE"
# $ quantiles : num [1:3, 1:5] -0.139 0.825 0.257 0.168 0.878 ...
#  ..- attr(*, "dimnames")=List of 2
#  .. ..$ : chr [1:3] "(Intercept)" "x" "sigma"
#  .. ..$ : chr [1:5] "2.5%" "25%" "50%" "75%" ...
...
# - attr(*, "class")= chr "summary.mcmc"

latex(qreg$statistics,file="")
latex(qreg$quantiles,file="")
#
Dear Dieter,

That sounds like a good solution, thanks.

Shige

On Mon, Apr 12, 2010 at 2:27 AM, Dieter Menne
<dieter.menne at menne-biomed.de> wrote: