## ----setup, include = FALSE---------------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

## -----------------------------------------------------------------------------
library(cccrm)
bp <- bpres[, c("ID", "SIS", "METODE", "NM")]
colnames(bp) <- c("id", "sys", "met", "rep")
bp[, c("id", "met", "rep")] <- lapply(bp[, c("id", "met", "rep")], as.factor)

## -----------------------------------------------------------------------------
bp <- bp[!bp$id %in% c(24, 199, 226), ]
bp$id <- droplevels(bp$id)

## ----fig.width = 7, fig.height = 5--------------------------------------------
set.seed(17)
library(TDIagree)
x <- TDI(bp, sys, id, met, rep, p = c(0.85, 0.95))
plot(x)

## ----fig.width = 7, fig.height = 5--------------------------------------------
plot(x, main = "Blood pressure data",
     xlab = "Mean (mmHg)", ylab = "Difference (mmHg)",
     xlim = c(80, 200), ylim = c(-60, 60))

## ----fig.width = 7, fig.height = 5--------------------------------------------
plot(x, loa = TRUE,
     xlim = c(80, 200), ylim = c(-60, 60))

## ----fig.width = 7, fig.height = 5--------------------------------------------
plot(x, loa = TRUE, loa.col = "red", 
     legend = TRUE,
     xlim = c(80, 200), ylim = c(-60, 60))

## ----fig.width = 7, fig.height = 5--------------------------------------------
plot(x, loa = TRUE, loa.col = "red", 
     legend = TRUE, inset = c(-0.34, 0),
     xlim = c(80, 200), ylim = c(-60, 60))

## ----fig.width = 7, fig.height = 5--------------------------------------------
plot(x, tdi = TRUE, ub = TRUE,
     legend = TRUE, inset = c(-0.4, 0),
     xlim = c(80, 200), ylim = c(-60, 60))

## ----fig.width = 7, fig.height = 5--------------------------------------------
plot(x, tdi = TRUE, ub = TRUE,
     method = c("es", "pe"),
     legend = TRUE, inset = c(-0.4, 0),
     xlim = c(80, 200), ylim = c(-60, 60))

## ----fig.width = 7, fig.height = 5--------------------------------------------
plot(x, tdi = TRUE, ub = TRUE,
     method = c("es", "pe"), method.col = c("darkred", "darkolivegreen"),
     legend = TRUE, inset = c(-0.4, 0),
     xlim = c(80, 200), ylim = c(-60, 60))

## ----fig.width = 7, fig.height = 5--------------------------------------------
plot(x, tdi = TRUE, ub = TRUE, ub.pc = "n_cb",
     method = c("es", "pe"), method.col = c("darkred", "darkolivegreen"),
     legend = TRUE, inset = c(-0.4, 0),
     xlim = c(80, 200), ylim = c(-60, 60))

## ----fig.width = 7, fig.height = 5--------------------------------------------
plot(x, tdi = TRUE,
     method = c("es", "pe"), method.col = c("darkred", "darkolivegreen"),
     legend = TRUE, inset = c(-0.4, 0),
     xlim = c(80, 200), ylim = c(-60, 60))

## ----fig.width = 7, fig.height = 5--------------------------------------------
plot(x, ub = TRUE, ub.pc = "n_cb",
     method = c("es", "pe"), method.col = c("darkred", "darkolivegreen"),
     legend = TRUE, inset = c(-0.4, 0),
     xlim = c(80, 200), ylim = c(-60, 60))

## ----fig.width = 7, fig.height = 5--------------------------------------------
plot(x, loess = TRUE, 
     legend = TRUE, inset = c(-0.33, 0),
     xlim = c(80, 200), ylim = c(-60, 60))

## ----fig.width = 7, fig.height = 5--------------------------------------------
plot(x, loess = TRUE, loess.col = "green", 
     legend = TRUE, inset = c(-0.33, 0),
     xlim = c(80, 200), ylim = c(-60, 60))

## ----fig.width = 7, fig.height = 5--------------------------------------------
plot(x, loess = TRUE, loess.col = "green", loess.span = 2,
     legend = TRUE, inset = c(-0.33, 0),
     xlim = c(80, 200), ylim = c(-60, 60))

## ----fig.width = 7, fig.height = 5--------------------------------------------
plot(x, tdi = TRUE, ub = TRUE, method = "choudhary p",
     loa = TRUE, loess = TRUE,
     legend = TRUE, inset = c(-0.33, 0),
     xlim = c(80, 200), ylim = c(-60, 60))

## ----fig.width = 7, fig.height = 5--------------------------------------------
plot(x, tdi = TRUE, ub = TRUE, method = "choudhary p",
     loa = TRUE, loess = TRUE,
     lwd = c(2, 2, 2, 2),
     legend = TRUE, inset = c(-0.33, 0),
     xlim = c(80, 200), ylim = c(-60, 60))

## ----fig.width = 7, fig.height = 5--------------------------------------------
plot(x, tdi = TRUE, ub = TRUE, method = "choudhary p",
     loa = TRUE, loess = TRUE,
     lwd = c(2, 2, 2, 2),
     legend = TRUE, inset = c(-0.33, 0),
     xlim = c(80, 200), ylim = c(-60, 60),
     col = "darkgrey", pch = 20)

