Learn R Programming

RoBMA (version 1.2.0)

plot.RoBMA: Plots a fitted RoBMA object

Description

plot.RoBMA allows to visualize different "RoBMA" object parameters in various ways. See type for the different model types.

Usage

# S3 method for RoBMA
plot(
  x,
  parameter,
  type = "averaged",
  plot_type = "base",
  mean = TRUE,
  median = FALSE,
  CI = 0.95,
  prior = FALSE,
  order = NULL,
  digits_estimates = 2,
  show_figures = if (parameter == "omega" & (weights | any(type %in% "individual")))
    -1,
  weights = FALSE,
  rescale_x = FALSE,
  ...
)

Arguments

x

a fitted RoBMA object

parameter

a parameter to be plotted. Either "mu", "tau", "theta", or "omega". A bivariate plot for model-averaged estimates of "mu" and "tau" can be obtained by c("mu","tau") if type = "averaged". In addition, a forest plot with the original estimates can be obtained by "forest" or added to the theta estimates by c("theta", "forest").

type

what type of estimates should be plotted. Options are "averaged" for the model-averaged estimates, "conditional" for the conditional estimates, or "individual" for the individual models estimates. The options c("individual", "conditional") can be supplied together to show only coditional individual models.

plot_type

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

mean

whether the mean should be plotted.

median

whether the median should be plotted.

CI

width of the confidence intervals.

prior

add prior density to the plot. Only available for type = "averaged" or type = "conditional". Defaults to FALSE.

order

either (1) ordering of the studies for parameter = "theta" or parameter = "forest". Defaults to NULL - ordering as supplied to the fitting function. However, studies can be ordered either "ascending" or "descending" by effect size, or by "alphabetical" by labels. Or (2) ordering models for type = "individual". The default orders models according to their number. However, models can be ordered either "ascending" or "descending" by posterior model probability c("ascending", "prob"), or marginal likelihood c("descending", "marglik") by marginal likelihood.

digits_estimates

number of decimals to be displayed for parameter = "theta", parameter = "forest", and type = "individual" plot.

show_figures

which figures should be returned in the case when multiple plots are generated. Useful when parameter = "omega", type = "individual" which generates a figure for each weights cut-off. Defaults to -1 which omits the first weight. Set to NULL to show all figures or to c(1,3) to show only the first and third one.

weights

whether the weights or weight function should be returned. Only applicable when parameter = "omega". Defaults to FALSE - the weight function is plotted.

rescale_x

whether the x-axis should be rescaled in order to make the x-ticks equally spaced. Available only for the weightfunction plot. Defaults to FALSE.

...

additional arguments to be passed to par if plot_type = "base". Especially useful for parameter == "theta", parameter == "forest" or type = "individual" where automatic margins might cut out parts of the labels.

See Also

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"
# plot function allows to visualize the results of a fitted RoBMA object, for example,
# the model-averaged mean parameter estimate
plot(fit, parameter = "mu")

# or show both the prior and posterior distribution
plot(fit, parameter = "mu", prior = TRUE)

# condtional plots might by obtained by specifying
plot(fit, parameter = "mu", type = "conditional")

# plotting function also allows to visualize the weight function
# (or individual weights by adding 'weights = TRUE')
plot(fit, parameter = "omega")

# or the forest plot (the estimated study effects can be shown by setting 'parameter = "theta"')
plot(fit, parameter = "forest")

# it is also possible to compare the individual model estimates
# and order them by the posterior probability
plot(fit, parameter = "mu", type = "individual", order = "prob")

# }

Run the code above in your browser using DataLab