Extract Samples of Coefficients and Variances
Function to extract the samples generated with Markov chain Monte Carlo simulation.
samples(object, model = NULL, term = NULL, coda = TRUE, acf = FALSE, ...)
object |
an object of class |
model |
for which model the samples should be provided, either an integer or a character,
e.g. |
term |
|
acf |
if set to |
coda |
if set to |
... |
further arguments passed to function |
A data.frame
or an object of class "mcmc"
or "mcmc.list"
, if argument
coda = TRUE
.
Nikolaus Umlauf, Thomas Kneib, Stefan Lang, Achim Zeileis.
## Not run: ## generate some data set.seed(111) n <- 200 ## regressor dat <- data.frame(x = runif(n, -3, 3)) ## response dat$y <- with(dat, 1.5 + sin(x) + rnorm(n, sd = 0.6)) ## estimate model b <- bayesx(y ~ sx(x), data = dat) ## extract samples for the P-spline sax <- samples(b, term = "sx(x)") colnames(sax) ## plotting plot(sax) ## linear effects samples samples(b, term = "linear-samples") ## for acf, increase lag sax <- samples(b, term = c("linear-samples", "var-samples", "sx(x)"), acf = TRUE, lag.max = 200, coda = FALSE) names(sax) head(sax) ## plot maximum autocorrelation ## of all parameters sax <- samples(b, term = c("linear-samples", "var-samples", "sx(x)"), acf = TRUE, lag.max = 50, coda = FALSE) names(sax) matplot(y = apply(sax, 1, max), type = "h", ylab = "ACF", xlab = "lag") ## example using multiple chains b <- bayesx(y ~ sx(x), data = dat, chains = 3) sax <- samples(b, term = "sx(x)") plot(sax) ## End(Not run)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.