Skip to content

Instantly share code, notes, and snippets.

@jrnold
Created September 18, 2012 03:48
Show Gist options
  • Save jrnold/3741130 to your computer and use it in GitHub Desktop.
Save jrnold/3741130 to your computer and use it in GitHub Desktop.
S4 defintiions of mcmc and mcmc.list
##' Redefine mcmc as S4 class
setClass("mcmc", contains="matrix",
representation(start="numeric",
end="numeric",
thin="numeric"))
setOldClass("mcmc", S4Class="mcmc")
setClass("mcmc.list", contains="list",
validity = function(object) {
if (length([email protected]) == 0) {
TRUE
} else {
allmcmc <- all(lapply([email protected], is, class2="mcmc"))
if (allmcmc) {
TRUE
} else {
"Not all elements in the list are mcmc objects."
}
}
})
setOldClass("mcmc.list", S4Class="mcmc.list")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment