## ----include = FALSE----------------------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.width = 6,
  fig.height = 4,
  dpi = 96
)

## ----setup--------------------------------------------------------------------
library(freqTLS)

## ----data---------------------------------------------------------------------
data(zebrafish_o2)
zf <- subset(zebrafish_o2, ploidy == "diploid")
table(zf$oxygen)

## ----standardize--------------------------------------------------------------
std <- standardize_data(
  zf,
  temp = "temp", duration = "duration_min",
  n_total = "n_total", n_surv = "n_surv",
  duration_unit = "minutes"
)

## ----fit----------------------------------------------------------------------
fit <- suppressWarnings(fit_4pl(
  std,
  ctmax = ~ 0 + oxygen,
  z     = ~ 0 + oxygen,
  t_ref = 60,
  family = "beta_binomial"
))
fit

## ----tls----------------------------------------------------------------------
ox <- tls(fit, by = "oxygen", method = "wald")
ox$summary

## ----ranking, echo = FALSE----------------------------------------------------
ct <- ox$summary[ox$summary$quantity == "CTmax", ]
ct <- ct[order(ct$median), ]

## ----eye-ctmax, fig.height = 4.5, fig.alt = "Confidence Eyes for zebrafish CTmax by oxygen treatment: three pale confidence lenses with hollow point estimates, one per treatment, the freqTLS uncertainty display rather than a posterior density."----
plot_confidence_eye(fit, parm = get_ctmax(fit)$parameter, method = "wald")

## ----eye-z, fig.height = 4.5, fig.alt = "Confidence Eyes for zebrafish z (thermal sensitivity) by oxygen treatment: three pale confidence lenses with hollow point estimates."----
plot_confidence_eye(fit, parm = get_z(fit)$parameter, method = "wald")

## ----survival, fig.height = 4.5, fig.alt = "Fitted zebrafish survival curves under three oxygen treatments: survival probability declining with exposure duration, observed proportions overlaid."----
plot_survival_curves(fit)

