Learn R Programming

RoBMA (version 1.2.0)

diagnostics: Checks a fitted RoBMA object

Description

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").

Usage

diagnostics(
  fit,
  parameter,
  type,
  plot_type = "base",
  show_figures = if (parameter == "omega") -1 else NULL,
  show_models = NULL,
  par_transform = TRUE,
  lags = 30,
  title = is.null(show_models) | length(show_models) > 1,
  ...
)

Arguments

fit

a fitted RoBMA object

parameter

a parameter to be plotted. Either "mu", "tau", "theta", or "omega".

type

what type of model check should 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.

plot_type

whether to use a base plot "base" or ggplot2 "ggplot2" for plotting. The later requires ggplot2 package to be installed.

show_figures

which figures should be returned in case of multiple plots are generated. Useful when parameter = "omega" when a plot for each parameter would be generated. Can be also used for parameter = "theta" to obtain only a specific subset of thetas. Set to NULL to show all parameters (default for parameter = "theta").

show_models

diagnostics for which models should be produced. Defaults to NULL that shows diagnostics to all models.

par_transform

whether the figures should be produced for the par_transform parameters. Defaults to TRUE.

lags

number of lags to be shown for type = "autocorrelation". Defaults to 30.

title

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".

Details

The visualization functions are based on stan_plot function and its color schemes.

See Also

RoBMA(), summary.RoBMA()

Examples

Run this code
# NOT RUN {
# using the example data from Anderson et al. 2010 and fitting the default model
# (note that the model can take a while to fit)
fit <- RoBMA(r = Anderson2010$r, n = Anderson2010$n, study_names = Anderson2010$labels)

### ggplot2 version of all of the plots can be obtained by adding 'model_type = "ggplot"
# diagnostics function allows to visualize diagnostics of a fitted RoBMA object, for example,
# the trace plot for the mean parameter in each model model
diagnostics(fit, parameter = "mu", type = "chain")

# in order to show the trace plot only for the 11th model, add show_models parameter
diagnostics(fit, parameter = "mu", type = "chain", show_models = 11)

# furthermore, the autocorrelations
diagnostics(fit, parameter = "mu", type = "autocorrelation")

# and overlying densities for each plot can also be visualize
diagnostics(fit, parameter = "mu", type = "densities")
# }

Run the code above in your browser using DataLab