## generate some data
set.seed(111)
n <- 500
## regressors
dat <- data.frame(x = runif(n, -3, 3))
## response
dat$y <- with(dat, 1.5 + sin(x) + rnorm(n, sd = 0.6))
if (FALSE) {
## estimate model
b <- bayesx(y ~ sx(x), data = dat)
summary(b)
## plot sampling path for
## the variance
plot(b, term = "sx(x)", which = "var-samples")
## plot sampling paths for
## coefficients
plot(b, term = "sx(x)", which = "coef-samples")
## plot maximum autocorrelation of
## all sampled parameters of term s(x)
plot(b, term = "sx(x)", which = "coef-samples", max.acf = TRUE)
## extract samples of term sx(x)
sax <- as.matrix(samples(b, term = "sx(x)"))
## now use plotsamples
plotsamples(sax, selected = "sx(x)")
## some variations
plotsamples(sax, selected = "sx(x)", acf = TRUE)
plotsamples(sax, selected = "sx(x)", acf = TRUE, lag.max = 200)
}
Run the code above in your browser using DataLab