inst/doc/case-study-zebrafish.R

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

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

## ----data---------------------------------------------------------------------
data(zebrafish_o2)
zf <- droplevels(subset(
  zebrafish_o2,
  ploidy == "diploid" & oxygen %in% c("normoxia", "hyperoxia")
))
table(zf$oxygen, zf$temp)

## ----standardize--------------------------------------------------------------
zf_std <- standardize_data(
  zf, temp = "temp", duration = "duration_min",
  n_total = "n_total", n_surv = "n_surv", duration_unit = "minutes"
)
stopifnot(attr(zf_std, "tdt_meta")$duration_unit == "minutes")

## ----fit----------------------------------------------------------------------
zf_fit <- fit_4pl(
  zf_std,
  ctmax = ~ 0 + oxygen,
  z = ~ 0 + oxygen,
  low = ~ 0 + oxygen,
  up = ~ 1,
  k = ~ 1,
  family = "beta_binomial",
  t_ref = 60,
  method = "wald",
  quiet = TRUE
)
diagnose_tdt_fit(zf_fit)

## ----quantities---------------------------------------------------------------
zf_tls <- tls(zf_fit, by = "oxygen", lethal = FALSE, method = "wald")
zf_table <- zf_tls$summary
names(zf_table)[names(zf_table) == "median"] <- "estimate"
zf_table

## ----eye, fig.alt="Independently scaled Wald Confidence Eyes for zebrafish CTmax and z under normoxia and hyperoxia, shown as outlined lenses with hollow estimates."----
plot_confidence_eye(zf_fit, parm = c("CTmax", "z"), method = "wald")

Try the freqTLS package in your browser

Any scripts or data that you put into this service are public.

freqTLS documentation built on Dec. 4, 2026, 5:11 p.m.