diagnostics
creates visual
checks of individual models convergence. Numerical
overview of individual models can be obtained by
summary(object, type = "models", diagnostics = TRUE)
,
or even more detailed information by
summary(object, type = "individual")
.
diagnostics(
fit,
parameter,
type,
show_models = NULL,
lags = 30,
title = is.null(show_models) | length(show_models) > 1,
...
)
diagnostics_autocorrelation(
fit,
parameter = NULL,
show_models = NULL,
lags = 30,
title = is.null(show_models) | length(show_models) > 1,
...
)
diagnostics_trace(
fit,
parameter = NULL,
show_models = NULL,
title = is.null(show_models) | length(show_models) > 1,
...
)
diagnostics_density(
fit,
parameter = NULL,
show_models = NULL,
title = is.null(show_models) | length(show_models) > 1,
...
)
a fitted RoBTT object
a parameter to be plotted. Either
"delta"
, "rho"
, "nu"
, "mu"
,
or "sigma"
.
type of MCMC diagnostic to be plotted.
Options are "chains"
for the chains' trace plots,
"autocorrelation"
for autocorrelation of the
chains, and "densities"
for the overlaying
densities of the individual chains. Can be abbreviated to
first letters.
MCMC diagnostics of which models should be
plotted. Defaults to NULL
which plots MCMC diagnostics
for a specified parameter for every model that is part of the
ensemble.
number of lags to be shown for
type = "autocorrelation"
. Defaults to 30
.
whether the model number should be displayed in title.
Defaults to TRUE
when more than one model is selected.
additional arguments to be passed to
par if plot_type = "base"
.
diagnostics
returns either NULL
if plot_type = "base"
or an object/list of objects (depending on the number of parameters to be plotted)
of class 'ggplot2' if plot_type = "ggplot2"
.
The visualization functions are based on stan_plot function and its color schemes.
if (FALSE) {
# using the example data from Darwin
data("fertilization", package = "RoBTT")
fit <- RoBTT(
x1 = fertilization$Self,
x2 = fertilization$Crossed,
prior_delta = prior("cauchy", list(0, 1/sqrt(2))),
prior_rho = prior("beta", list(3, 3)),
seed = 1,
chains = 1,
warmup = 1000,
iter = 2000,
control = set_control(adapt_delta = 0.95)
)
### ggplot2 version of all of the plots can be obtained by adding 'model_type = "ggplot"
# diagnostics function allows to visualize diagnostics of a fitted RoBTT object, for example,
# the trace plot for the mean parameter in each model model
diagnostics(fit, parameter = "delta", type = "chain")
# in order to show the trace plot only for the 11th model, add show_models parameter
diagnostics(fit, parameter = "delta", type = "chain", show_models = 11)
# furthermore, the autocorrelations
diagnostics(fit, parameter = "delta", type = "autocorrelation")
# and overlying densities for each plot can also be visualize
diagnostics(fit, parameter = "delta", type = "densities")
}