traceplot | R Documentation |
History plot for some variables in a bugs
or pbugs
object. This function allows also automatically plotting those variables
with deficient converge according to the effective sample size (Neff) &
Brooks-Gelman-Rubin (Rhat) criteria.
traceplot(x, var.pattern = character(), var.names = character(),
not.converged = FALSE, convergence.criteria = c(100, 1.1), mfrow = NULL,
max.devices = 10, ...)
x |
Object of class |
var.pattern |
Character. Regular expression (as used in
|
var.names |
Character. Vector with the literal names of the variables to be plotted. |
not.converged |
Logical, default: FALSE. Plot just those variables with deficient convergence? |
convergence.criteria |
Numeric vector of length 2 with thresholds for
the Neff and Rhat criteria. If |
mfrow |
A vector of length 2, specifying the number of rows and columns on each device. Default NULL (tries to accommodate the number of parameters using mfrow values from c(1, 1) to c(4, 4)). |
max.devices |
Maximum number of devices to generate containing the requested history plots. Equal to 10 by default. |
... |
Additional arguments to be passed to |
If length(var.names) == 0 & length(var.pattern) == 0 &
!not.converged
, history plots will be plotted for all the variables in the
corresponding bugs
or pbugs
object.
## Not run:
library(pbugs)
data(sample_df)
bugs_model <- function() {
for (i in 1:N) {
y[i] ~ dbern(pi[i])
logit(pi[i]) <- beta[1] + beta[2] * x1[i] + beta[3] * x2[i] + beta[4] * x3[i]
}
for (j in 1:4) {
beta[j] ~ dflat()
}
}
bugs_data <- with(
sample_df,
list(y = y, x1 = x1, x2 = x2, x3 = x3, N = length(y))
)
bugs_init <- function() list(beta = rnorm(4, sd = .5))
bugs_pars <- c("beta", "pi")
traceplot(result, var.names = c("beta[1]", "beta[3]"))
traceplot(result, var.pattern = "beta")
traceplot(result, var.pattern = "beta|pi\\[1\\d?\\]")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.