# [R] MCMC results into LaTeX

Shige Song shigesong at gmail.com
Mon Apr 12 13:27:30 CEST 2010

```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:
>
>
> Shige Song wrote:
>>
>>
>> What is the preferred way to get Bayesian analysis results (such as
>> those from MCMCpacki, MCMCglmm, and DPpackage) into LaTeX table
>> automatically?
>>
>
> 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="")
>
> --
> View this message in context: http://n4.nabble.com/MCMC-results-into-LaTeX-tp1836393p1836723.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help