###
# Create example data files for 20 independent chains
# with serial correlation of 0.
###
set.seed(42)
tmpdir <- tempdir()
for(i in 1:20){
x <- matrix(rnorm(1000), ncol=4)
x[,4] <- x[,4] + 1/3 * (x[,1] + x[,2] + x[,3])
colnames(x) <- c("alpha","beta","gamma", "nu")
write.table(
x,
file = file.path(
tmpdir,
paste("mcmc", i, "csv", sep=".")
),
sep = ",",
row.names=FALSE
)
}
# Read them back in as an mcmc.list object
data <- read.mcmc(20, file.path(tmpdir, "mcmc.#.csv"), sep=",")
summary(data)
Run the code above in your browser using DataLab