[R] coda sweave

Ista Zahn istazahn at gmail.com
Tue Apr 27 20:32:15 CEST 2010


Hi Randall,

Sounds like you need to make friends with the str() function, and
perhaps read the documentation about data types in R. For your
particular problem:

library(coda)
m1 <- matrix(runif(100), nrow=10)
m1.sum <- summary(mcmc(m1))
str(m1.sum)

library(xtable)
xtable(m1.sum$statistics)
xtable(m1.sum$quantiles)

Best,
Ista

On Tue, Apr 27, 2010 at 12:22 PM, Randall Wrong <randall.wrong at gmail.com> wrote:
> This is the kind of output I get with summary(mcmc(x)). I would like it in
> LaTeX. There are two tables.
>
> Iterations = 1:10
> Thinning interval = 1
> Number of chains = 1
> Sample size per chain = 10
> 1. Empirical mean and standard deviation for each variable,
>   plus standard error of the mean:
>        Mean    SD Naive SE Time-series SE
> [1,]  0.7237 3.374    1.067          1.252
> [2,] -1.7883 4.317    1.365          1.644
> [3,]  0.8384 3.422    1.082          1.047
> [4,]  1.0750 3.195    1.010          1.087
> 2. Quantiles for each variable:
>        2.5%      25%     50%     75% 97.5%
> var1 -1.5408 -0.91681 -0.1798  0.7134 7.929
> var2 -4.1454 -3.89975 -3.5207 -2.1781 7.706
> var3 -2.0412 -0.79606  0.3247  1.0445 7.999
> var4 -0.9809 -0.08847  0.1895  0.4980 8.015
>
> Thank you very much for any help,
> Randall
>
> 2010/4/27 Randall Wrong <randall.wrong at gmail.com>
>
>> I forgot to say that the coda package is loaded.
>>
>> Randall
>>
>> 2010/4/27 Randall Wrong <randall.wrong at gmail.com>
>>
>>  Dear R users,
>>>
>>> I have a matrix x of simulated values. Each column corresponds to one
>>> variable.
>>>
>>> summary(mcmc(x)) works fine
>>>
>>> I would like however to transform the ouput into a nice LaTeX code.
>>>
>>> xtable( summary(mcmc(x)) ) does not work.
>>>
>>> Thanks
>>> Randall
>>>
>>>
>>
>>
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Ista Zahn
Graduate student
University of Rochester
Department of Clinical and Social Psychology
http://yourpsyche.org



More information about the R-help mailing list