Skip to content

Instantly share code, notes, and snippets.

@hoxo-m
Created December 18, 2019 09:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hoxo-m/a8f03df485f04d316ae80537a4586fb2 to your computer and use it in GitHub Desktop.
Save hoxo-m/a8f03df485f04d316ae80537a4586fb2 to your computer and use it in GitHub Desktop.
head.mcmc
head.mcmc <- function(x, n = 6L, ...) {
mcpar <- attr(x, "mcpar")
start <- mcpar[1]
max_end <- mcpar[2]
thin <- mcpar[3]
niter <- nrow(x)
end <- start + niter - 1
attr(x, "mcpar")[2:3] <- c(end, 1)
out <- window(x, end = min(start + n - 1, end))
end <- min(start + n * thin - 1, max_end)
attr(out, "mcpar")[2:3] <- c(end, thin)
out
}
@hoxo-m
Copy link
Author

hoxo-m commented Dec 18, 2019

x$fit@sim$iter * x$fit@sim$chain - (nrow(out) - 1) * x$fit@sim$thin,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment