colMeans.mcmc.list is a "method" for (non-generic) colMeans() applicable to mcmc.list objects.
var.mcmc.list is a "method" for (non-generic)
var() applicable to mcmc.list objects. Since MCMC chains
are assumed to all be sampling from the same underlying
distribution, their pooled mean is used.
sweep.mcmc.list is a "method" for (non-generic)
sweep() applicable to mcmc.list objects.
lapply.mcmc.list is a "method" for (non-generic)
lapply() applicable to mcmc.list objects.
colMeans.mcmc.list(x, ...)
var.mcmc.list(x, ...)
sweep.mcmc.list(x, STATS, FUN = "-", check.margin = TRUE, ...)
lapply.mcmc.list(X, FUN, ...)colMeans.mcmc returns a vector with length equal to
the number of mcmc chains in x with the mean value for
each chain.
sweep.mcmc.list returns an appropriately modified
version of x
lapply.mcmc.list returns an mcmc.list each of
whose chains had been passed through FUN.
These implementations should be equivalent (within
numerical error) to the same function being called on
as.matrix(x), while avoiding construction of the large matrix.
data(line, package="coda")
colMeans(as.matrix(line)) # also coda
#> alpha beta sigma
#> 2.9875644 0.7991864 0.9680519
colMeans.mcmc.list(line) # "Method"
#> alpha beta sigma
#> 2.9875644 0.7991864 0.9680519
data(line, package="coda")
var(as.matrix(line)) # coda
#> alpha beta sigma
#> alpha 0.24839754 -0.02399442 0.05650231
#> beta -0.02399442 0.11335568 -0.05193148
#> sigma 0.05650231 -0.05193148 0.54952775
var.mcmc.list(line) # "Method"
#> alpha beta sigma
#> alpha 0.24839754 -0.02399442 0.05650231
#> beta -0.02399442 0.11335568 -0.05193148
#> sigma 0.05650231 -0.05193148 0.54952775
data(line, package="coda")
colMeans.mcmc.list(line)-1:3
#> alpha beta sigma
#> 1.987564 -1.200814 -2.031948
colMeans.mcmc.list(sweep.mcmc.list(line, 1:3))
#> alpha beta sigma
#> 1.987564 -1.200814 -2.031948
data(line, package="coda")
colMeans.mcmc.list(line)[c(2,3,1)]
#> beta sigma alpha
#> 0.7991864 0.9680519 2.9875644
colMeans.mcmc.list(lapply.mcmc.list(line, `[`,,c(2,3,1)))
#> beta sigma alpha
#> 0.7991864 0.9680519 2.9875644