thresh_2d: Producing two-dimensional invariant regions

Description Usage Arguments Value Examples

View source: R/thresh_2d.R

Description

This function produces two-dimensional threshold lines and invariant regions, as shown by Phillippo et al. (2018).

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
thresh_2d(
  thresh,
  idx,
  idy,
  xlab = paste("Adjustment to data point", idx),
  ylab = paste("Adjustment to data point", idy),
  xlim = NULL,
  ylim = NULL,
  breaks = waiver(),
  xbreaks = breaks,
  ybreaks = breaks,
  fill = rgb(0.72, 0.8, 0.93, 0.7),
  lwd = 1,
  fontsize = 12
)

Arguments

thresh

A thresh object, as produced by nma_thresh.

idx

Integer specifying the index (with respect to thresh$thresholds) of the first data point to consider adjusting. Will be shown on the x axis.

idy

Integer specifying the index (with respect to thresh$thresholds) of the second data point to consider adjusting. Will be shown on the y axis.

xlab

Character string giving the label for the x axis.

ylab

Character string giving the label for the y axis.

xlim

Numeric vector of length 2, giving the x axis limits.

ylim

Numeric vector of length 2, giving the y axis limits.

breaks

Numeric vector giving position of tick marks on the x and y axes. Calculated automatically by default.

xbreaks

Numeric vector giving position of tick marks on the x axis. Equal to breaks by default, if set this overrides any value given to breaks.

ybreaks

Numeric vector giving position of tick marks on the y axis. Equal to breaks by default, if set this overrides any value given to breaks.

fill

Fill colour for invariant region. Defaults to a nice shade of blue rgb(.72, .80, .93, .7).

lwd

Line width for threshold lines. Default 1.

fontsize

Font size for labels. Default 12.

Value

A ggplot object containing the 2D threshold plot, which is returned invisibly and plotted (unless assigned).

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# Please see the vignette "Examples" for worked examples including use of
# this function, including more information on the brief code below.

vignette("Examples", package = "nmathresh")

### Contrast level thresholds for Thrombolytic treatments NMA
K <- 6   # Number of treatments

# Contrast design matrix is
X <- matrix(ncol = K-1, byrow = TRUE,
            c(1, 0, 0, 0, 0,
              0, 1, 0, 0, 0,
              0, 0, 1, 0, 0,
              0, 0, 0, 1, 0,
              0, -1, 1, 0, 0,
              0, -1, 0, 1, 0,
              0, -1, 0, 0, 1))

# Reconstruct hypothetical likelihood covariance matrix using NNLS
lik.cov <- recon_vcov(Thrombo.post.cov, prior.prec = .0001, X = X)

# Thresholds are then
thresh <- nma_thresh(mean.dk = Thrombo.post.summary$statistics[1:(K-1), "Mean"],
                     lhood = lik.cov,
                     post = Thrombo.post.cov,
                     nmatype = "fixed",
                     X = X,
                     opt.max = FALSE)

# Produce an invariant region for simultaneous adjustments to both arms of Study 1
thresh_2d(thresh, 1, 2,
          xlab = "Adjustment in Study 1 LOR: 3 vs. 1",
          ylab = "Adjustment in Study 1 LOR: 4 vs. 1",
          xlim = c(-1.5, 0.5), ylim = c(-2, 14),
          ybreaks = seq(-2, 14, 2))

nmathresh documentation built on July 8, 2020, 5:17 p.m.