Nothing
## ----include = FALSE----------------------------------------------------------
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.width = 6,
fig.height = 4,
dpi = 96
)
## ----setup--------------------------------------------------------------------
library(freqTLS)
## ----simulate-----------------------------------------------------------------
set.seed(1)
dat <- simulate_tls(
temps = seq(30, 42, by = 2),
times = c(30, 60, 120, 240, 480),
reps = 3,
n = 20,
CTmax = 36,
z = 4,
phi = 50,
family = "beta_binomial",
tref = 60,
seed = 1
)
head(dat)
## ----truth--------------------------------------------------------------------
attr(dat, "truth")[c("CTmax", "z", "phi")]
## ----standardize--------------------------------------------------------------
std <- standardize_data(
dat,
temp = "temp",
duration = "duration",
n_total = "total",
n_surv = "survived",
duration_unit = "minutes"
)
## ----fit----------------------------------------------------------------------
fit <- fit_4pl(std, family = "beta_binomial")
fit
## ----fit-formula--------------------------------------------------------------
fit_f <- fit_tls(
tls_bf(survived | trials(total) ~ time(duration) + temp(temp)),
data = dat,
family = "beta_binomial",
tref = 60
)
stopifnot(isTRUE(all.equal(coef(fit_f), coef(fit), tolerance = 1e-8)))
## ----summary------------------------------------------------------------------
summary(fit)
## ----beta-censoring-----------------------------------------------------------
beta_raw <- simulate_tls(
family = "beta", times = c(30, 60, 120, 240, 480), reps = 5,
CTmax = 36, z = 4, phi = 35, tref = 60, seed = 22
)
detection_limit <- 0.02
beta_raw$limit <- detection_limit
beta_raw$below_limit <- beta_raw$prop <= detection_limit
beta_raw$recorded_prop <- ifelse(beta_raw$below_limit, detection_limit,
beta_raw$prop)
stopifnot(any(beta_raw$below_limit))
beta_std <- standardize_data(
beta_raw, temp = "temp", duration = "duration", proportion = "recorded_prop",
left_censored = "below_limit", censor_limit = "limit",
duration_unit = "minutes"
)
beta_fit <- fit_4pl(beta_std, family = "beta", t_ref = 60, quiet = TRUE)
beta_fit
## ----tidy---------------------------------------------------------------------
tidy_parameters(fit)
get_ctmax(fit)
get_z(fit)
## ----confint------------------------------------------------------------------
confint(fit, parm = "CTmax", method = "profile")
confint(fit, parm = "z", method = "profile")
## ----wald---------------------------------------------------------------------
confint(fit, parm = c("CTmax", "z"), method = "wald")
## ----survival-curves, fig.alt = "Fitted 4PL survival curves: survival probability declining with exposure duration, one curve per assay temperature, with observed proportions as points."----
plot_survival_curves(fit)
## ----confidence-eye, fig.alt = "Confidence Eye plot: independently scaled pale outlined lenses spanning profile-likelihood intervals, with dark centre marks and hollow point estimates, for CTmax and z."----
plot_confidence_eye(fit, parm = c("CTmax", "z"), method = "profile")
profile_ci <- confint(fit, parm = c("CTmax", "z"), method = "profile")
profile_ci[c("parameter", "method", "conf.status")]
## ----grouped------------------------------------------------------------------
dat_grp <- simulate_tls(
temps = seq(30, 42, by = 2), times = c(30, 60, 120, 240, 480), reps = 3, n = 20,
group = c("cool", "warm"), CTmax = c(34, 38), z = c(3, 5),
phi = 50, family = "beta_binomial", tref = 60, seed = 2
)
fit_grp <- fit_tls(
tls_bf(
survived | trials(total) ~ time(duration) + temp(temp),
CTmax ~ group,
log_z ~ group
),
data = dat_grp, family = "beta_binomial", tref = 60
)
tidy_parameters(fit_grp)
confint(fit_grp, c("CTmax:cool", "CTmax:warm", "z:cool", "z:warm"),
method = "profile")
## ----random-effect------------------------------------------------------------
dat_re <- simulate_tls(
temps = seq(30, 42, by = 2), times = c(30, 60, 120, 240, 480), reps = 2, n = 20,
CTmax = 36, z = 4, phi = 50, family = "beta_binomial",
re_sd = 1.2, n_re_groups = 10, tref = 60, seed = 3
)
fit_re <- fit_tls(
tls_bf(
survived | trials(total) ~ time(duration) + temp(temp),
CTmax ~ (1 | colony)
),
data = dat_re, family = "beta_binomial", tref = 60
)
fit_re
head(ranef(fit_re))
## ----function-map, echo = FALSE, results = "asis"-----------------------------
# Inline the SVG rather than include_graphics() so the figure does not depend on
# pkgdown copying a co-located static asset. The Pandoc raw-HTML fence is
# essential: without it, wildcard labels such as get_*_summary() are parsed as
# Markdown emphasis, which breaks the SVG namespace. Accessibility is provided
# by the SVG's <title>/<desc>.
svg_candidates <- c(
"freqTLS_function_map.svg",
system.file("doc", "freqTLS_function_map.svg", package = "freqTLS")
)
svg_path <- svg_candidates[nzchar(svg_candidates) & file.exists(svg_candidates)][1]
if (is.na(svg_path)) {
stop("The installed freqTLS function-map SVG is missing.")
}
svg_lines <- readLines(svg_path, warn = FALSE)
cat(
"```{=html}\n",
paste(svg_lines, collapse = "\n"),
"\n```\n",
sep = ""
)
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.