Computing ergodic mean with CODA

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Computing ergodic mean with CODA

Raquel Rangel de Meireles Guimarães
Hi all,

I would like to compute ergodic mean using MCMC output from WinBUGS. I
tried using CODA package, but it seems that it is not implemented yet.

Could anyone help me to compute this? Attached to this email are my
output and index files.

Kind regards,

Raquel

--
Raquel Rangel de Meireles Guimarães
Doutoranda em Demografia
[hidden email]
http://ufmg.academia.edu/RaquelGuimaraes
Cedeplar - Centro de Desenvolvimento e Planejamento Regional
Avenida Antônio Carlos, 6627, Sala 2090, Pampulha, BH-MG
Telefones: (31) 3409-7144 - (31) 9732-2132
Faculdade de Ciências Econômicas, UFMG (http://www.cedeplar.ufmg.br)


______________________________________________
[hidden email] 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.

index-full.ind (190 bytes) Download Attachment
out-full.out (606K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Computing ergodic mean with CODA

bbolker
Raquel Rangel de Meireles Guimarães <raquelrguimadem <at> gmail.com> writes:

>
> Hi all,
>
> I would like to compute ergodic mean using MCMC output from WinBUGS. I
> tried using CODA package, but it seems that it is not implemented yet.
>
> Could anyone help me to compute this? Attached to this email are my
> output and index files.
>
> Kind regards,
>
> Raquel
>
> --

[the data were not in the most convenient form;
one of the preferences is for a *small* reproducible
example ...  I cut & pasted them into a file to
recreate the original mcmc object].

  Based on a quick look at [Ntzoufras, Ioannis. 2009. Bayesian modeling using
WinBUGS. John Wiley and Sons.], I think cumsum(x)/(1:length(x)) is the
ergodic mean (essentially a running cumulative mean).


x <- read.table("~/R/misc/ergod.dat")
library(coda)
v <- as.mcmc(matrix(x[,2],nrow=5000))
em <- sweep(apply(v,2,cumsum),1,(1:nrow(v)),"/")
library(reshape)
m <- melt(em)
xyplot(value~X1|X2,type="l",data=m,
       scales=list(y=list(relation="free")))

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Computing ergodic mean with CODA

Giovanni Petris
In reply to this post by Raquel Rangel de Meireles Guimarães
Hola Raquel,

As Ben already told you, ergodic means are pretty easy to compute from
scratch. If you are lazy, or you want something more, like estimated
standard errors, you can check out the functions ergMean and mcmcMean in
package dlm.

Best,
Giovanni Petris

On Sun, 2010-11-07 at 14:34 -0200, Raquel Rangel de Meireles Guimarães
wrote:

> Hi all,
>
> I would like to compute ergodic mean using MCMC output from WinBUGS. I
> tried using CODA package, but it seems that it is not implemented yet.
>
> Could anyone help me to compute this? Attached to this email are my
> output and index files.
>
> Kind regards,
>
> Raquel
>
> --
> Raquel Rangel de Meireles Guimarães
> Doutoranda em Demografia
> [hidden email]
> http://ufmg.academia.edu/RaquelGuimaraes
> Cedeplar - Centro de Desenvolvimento e Planejamento Regional
> Avenida Antônio Carlos, 6627, Sala 2090, Pampulha, BH-MG
> Telefones: (31) 3409-7144 - (31) 9732-2132
> Faculdade de Ciências Econômicas, UFMG (http://www.cedeplar.ufmg.br)
>
> ______________________________________________
> [hidden email] 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.

______________________________________________
[hidden email] 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.