plot.mediation.test: Plots the output of 'function's 'mediation_test_minimax' and...

View source: R/utils.R

plot.mediation.testR Documentation

Plots the output of functions mediation_test_minimax and mediation_test_Bayes with the rejection region.

Description

Plots the output of functions mediation_test_minimax and mediation_test_Bayes with the rejection region.

Usage

## S3 method for class 'mediation.test'
plot(
  x,
  filename = NULL,
  return_fig = FALSE,
  xlim = c(-4, 4),
  ylim = c(-4, 4),
  ...
)

Arguments

x

An output of functions mediation_test_minimax or mediation_test_Bayes.

filename

Either NULL (defaults) or a file name to create on disk.

return_fig

A logical, to request that the 'ggplot2' object be returned (if 'TRUE') or not (if 'FALSE').

xlim, ylim

Two vectors of numerics, the wished x-axis and y-axis ranges (both default to 'c(-4, 4)').

...

Not used.

Value

Nothing unless 'return_fig' is set to 'TRUE', in which case the function returns the 'ggplot2' object.

Examples

n <- 10
x <- MASS::mvrnorm(n, mu = c(0, 0), Sigma = diag(c(1, 1)))
delta <- matrix(stats::runif(2 * n, min = -3, max = 3), ncol = 2)
epsilon <- stats::rbinom(n, 1, 1/2)
delta <- delta * cbind(epsilon, 1 - epsilon)
x <- x + delta
(mt <- mediation_test_minimax(x, alpha = 1/20))
plot(mt)


achambaz/mediation.test documentation built on Oct. 20, 2024, 9:25 a.m.