Skip to contents

Draws one panel per hypothesis of a hypothesis() result, stacked in one column, nvariables panels to a page, as brms's plot.brmshypothesis() lays them out. Each panel shows what the method has: the distribution of the draws (a histogram with a density line) for method = "boot" and for posterior draws, the profile of the log-likelihood for method = "profile", and the normal density of the Wald estimate otherwise. Vertical lines mark the estimate, the interval and zero.

Usage

# S3 method for class 'frmtmb_hypothesis'
plot(
  x,
  nvariables = 5,
  N = NULL,
  ignore_prior = FALSE,
  chars = 40,
  colors = NULL,
  theme = NULL,
  ask = TRUE,
  plot = TRUE,
  ...
)

# S3 method for class 'frmtmb_hyp_plot'
print(x, ...)

# S3 method for class 'frmtmb_hyp_plot'
plot(x, ...)

Arguments

x

A frmtmb_hypothesis object, or one frmtmb_hyp_plot for the print and plot methods of a plot object.

nvariables

The number of hypotheses per page.

N

brms's older name for nvariables. When set, it replaces nvariables with brms's deprecation warning.

ignore_prior

If TRUE, leave out the density of the prior draws; see the section on prior draws.

chars

The number of characters of a hypothesis kept in its panel title. A longer one is cut and ends in "..." before its last four characters, as in brms. NULL keeps all of it.

colors

Two colors, as in brms. The first fills the histogram of the draws. The second draws the density of the prior draws, where there are any (see the section on prior draws). The default fills with light gray and draws the prior in a darker gray.

theme

brms's ggplot2 theme. NULL (the default) changes nothing. A ggplot2 theme object is not applied, and a warning says so. Anything else is an error, as in brms.

ask

If TRUE (the default), prompt before each new page after the first on an interactive device. NULL, the default before this version, is taken as TRUE.

plot

If FALSE, return the plot objects without drawing them.

...

do_plot, brms's deprecated name for plot, is accepted with brms's warning. Base graphical parameters (main, lwd, ...) are accepted, as every plot() method must accept them, and ignored with a warning that names them. A name that abbreviates an argument of this method is that argument, by R's partial matching, as in brms: col = "red" is colors = "red", and stops because colors needs two colors. Any other argument is an error that names it.

Value

A list of frmtmb_hyp_plot objects, one per page, invisibly.

What plot = FALSE returns

brms returns a list of ggplot objects, one per page, and draws them unless plot = FALSE. frmtmb draws with base graphics and does not depend on ggplot2, so it returns a list of frmtmb_hyp_plot objects, one per page. Each holds the hypotheses of its page and the settings of the call, and printing or plotting one draws that page. The list is returned invisibly whether or not the call draws, as brms returns its list.

Prior draws

brms overlays the density of the prior draws of each hypothesis unless ignore_prior = TRUE, and so does this method, as a line in the second of colors. A hypothesis of draws made by frmtmb.sample::frm_sample(sample_prior = "yes") carries prior draws wherever every parameter it names has them. A maximum-likelihood fit has no prior, and draws made without prior draws have none, so their prior_samples is all NA and only the posterior is drawn, as brms does in that case.

See also

Examples

set.seed(1)
dd <- data.frame(x1 = rnorm(80), x2 = rnorm(80))
dd$y <- rnorm(80, 1 + 0.5 * dd$x1 - 0.2 * dd$x2)
fit <- frm(bf(y ~ x1 + x2), family = gaussian(), data = dd)
h <- hypothesis(fit, c("x1 > 0", "x1 + x2 = 0"))
plot(h, ask = FALSE)

# the page objects, drawn one at a time
p <- plot(h, plot = FALSE)
length(p)
#> [1] 1
p[[1]]