diff --git a/DESCRIPTION b/DESCRIPTION
index 90156c1..81b40d8 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -3,16 +3,17 @@ Title: Biomarker Kinetics Modelling
Version: 0.0.0.9000
Authors@R: c(person("Timothy", "Russell", email = "timothy.russell@lshtm.ac.uk", role = c("aut")),
person("Alex", "Hill", email = "alex.hill@gmail.com", role = c("aut", "cre")))
-Description: Fit kinetic curves to biomarker data, using a Bayesian hierarchical model
+Description: Fit kinetic curves to biomarker data, using a Bayesian hierarchical model.
License: GPL (>= 3)
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
-RoxygenNote: 7.3.1
+RoxygenNote: 7.3.2
Imports:
cmdstanr,
data.table,
forcats,
fs,
+ ggplot2,
instantiate,
logger,
mosaic,
@@ -26,11 +27,11 @@ Additional_repositories:
SystemRequirements: CmdStan (https://mc-stan.org/users/interfaces/cmdstan)
Suggests:
dplyr,
- ggplot2,
knitr,
lubridate,
rmarkdown,
- testthat
+ testthat,
+ vdiffr
VignetteBuilder: knitr
LinkingTo:
cpp11
diff --git a/NAMESPACE b/NAMESPACE
index d5b46ca..577ae7a 100644
--- a/NAMESPACE
+++ b/NAMESPACE
@@ -1,5 +1,7 @@
# Generated by roxygen2: do not edit by hand
+S3method(plot,biokinetics_population_trajectories)
+S3method(plot,biokinetics_priors)
export(add_exposure_data)
export(biokinetics)
export(biokinetics_priors)
@@ -14,4 +16,14 @@ importFrom(data.table,.N)
importFrom(data.table,.NGRP)
importFrom(data.table,.SD)
importFrom(data.table,data.table)
+importFrom(ggplot2,aes)
+importFrom(ggplot2,facet_wrap)
+importFrom(ggplot2,geom_line)
+importFrom(ggplot2,geom_point)
+importFrom(ggplot2,geom_ribbon)
+importFrom(ggplot2,geom_smooth)
+importFrom(ggplot2,ggplot)
+importFrom(ggplot2,guide_legend)
+importFrom(ggplot2,guides)
+importFrom(ggplot2,scale_y_continuous)
useDynLib(epikinetics, .registration = TRUE)
diff --git a/R/biokinetics.R b/R/biokinetics.R
index 6d4a558..e93e1e1 100644
--- a/R/biokinetics.R
+++ b/R/biokinetics.R
@@ -191,7 +191,7 @@ biokinetics <- R6::R6Class(
return(dt)
},
- extract_parameters = function(params, n_draws = 2500) {
+ extract_parameters = function(params, n_draws) {
private$check_fitted()
params_proc <- rlang::parse_exprs(params)
@@ -265,6 +265,26 @@ biokinetics <- R6::R6Class(
package = "epikinetics"
)
},
+ #' @description Plot the kinetics trajectory predicted by the model priors.
+ #' Note that this is on a log scale, regardless of whether the data was provided
+ #' on a log or a natural scale.
+ #' @return A ggplot2 object.
+ #' @param tmax Integer. The number of time points in each simulated trajectory. Default 150.
+ #' @param n_draws Integer. The number of trajectories to simulate. Default 2000.
+ plot_prior_predictive = function(tmax = 150,
+ n_draws = 2000) {
+ plot(private$priors,
+ tmax = tmax,
+ n_draws = n_draws,
+ data = private$data)
+ },
+ #' @description Plot model input data with a smoothing function. Note that
+ #' this plot is on a log scale, regardless of whether data was provided on a
+ #' log or a natural scale.
+ #' @return A ggplot2 object.
+ plot_model_inputs = function() {
+ plot_sero_data(private$data, private$all_formula_vars)
+ },
#' @description View the data that is passed to the stan model, for debugging purposes.
#' @return A list of arguments that will be passed to the stan model.
get_stan_data = function() {
@@ -286,9 +306,9 @@ biokinetics <- R6::R6Class(
},
#' @description Extract fitted population parameters
#' @return A data.table
- #' @param n_draws Numeric
+ #' @param n_draws Integer. Default 2000.
#' @param human_readable_covariates Logical. Default TRUE.
- extract_population_parameters = function(n_draws = 2500,
+ extract_population_parameters = function(n_draws = 2000,
human_readable_covariates = TRUE) {
private$check_fitted()
has_covariates <- length(private$all_formula_vars) > 0
@@ -322,10 +342,10 @@ biokinetics <- R6::R6Class(
},
#' @description Extract fitted individual parameters
#' @return A data.table
- #' @param n_draws Numeric
+ #' @param n_draws Integer. Default 2000.
#' @param include_variation_params Logical
#' @param human_readable_covariates Logical. Default TRUE.
- extract_individual_parameters = function(n_draws = 2500,
+ extract_individual_parameters = function(n_draws = 2000,
include_variation_params = TRUE,
human_readable_covariates = TRUE) {
private$check_fitted()
@@ -367,11 +387,12 @@ biokinetics <- R6::R6Class(
#' @param summarise Boolean. Default TRUE. If TRUE, summarises over draws from posterior parameter distributions to
#' return 0.025, 0.5 and 0.975 quantiles, labelled lo, me and hi, respectively. If FALSE returns values for individual
#' draws from posterior parameter distributions.
- #' @param n_draws Integer. Maximum number of samples to include. Default 2500.
+ #' @param n_draws Integer. Maximum number of samples to include. Default 2000.
simulate_population_trajectories = function(
t_max = 150,
summarise = TRUE,
- n_draws = 2500) {
+ n_draws = 2000) {
+
private$check_fitted()
validate_numeric(t_max)
validate_logical(summarise)
@@ -388,25 +409,28 @@ biokinetics <- R6::R6Class(
dt_out <- dt_out[
, lapply(.SD, function(x) if (is.factor(x)) forcats::fct_drop(x) else x)]
- if (private$scale == "log") {
- return(dt_out)
+ if (private$scale == "natural") {
+ if (summarise) {
+ dt_out <- convert_log2_scale_inverse(
+ dt_out, vars_to_transform = c("me", "lo", "hi"))
+ } else {
+ dt_out <- convert_log2_scale_inverse(
+ dt_out, vars_to_transform = "mu")
+ }
}
- if (summarise) {
- dt_out <- convert_log2_scale_inverse(
- dt_out, vars_to_transform = c("me", "lo", "hi"))
- } else {
- dt_out <- convert_log2_scale_inverse(
- dt_out, vars_to_transform = "mu")
- }
+ class(dt_out) <- append("biokinetics_population_trajectories", class(dt_out))
+ attr(dt_out, "summarised") <- summarise
+ attr(dt_out, "scale") <- private$scale
+ attr(dt_out, "covariates") <- private$all_formula_vars
dt_out
},
#' @description Process the stan model results into a data.table.
#' @return A data.table of peak and set titre values. Columns are tire_type, mu_p, mu_s, rel_drop_me, mu_p_me,
#' mu_s_me, and a column for each covariate. See the data vignette for details:
#' \code{vignette("data", package = "epikinetics")}
- #' @param n_draws Integer. Maximum number of samples to include. Default 2500.
- population_stationary_points = function(n_draws = 2500) {
+ #' @param n_draws Integer. Maximum number of samples to include. Default 2000.
+ population_stationary_points = function(n_draws = 2000) {
private$check_fitted()
validate_numeric(n_draws)
@@ -458,11 +482,11 @@ biokinetics <- R6::R6Class(
#' @param summarise Boolean. If TRUE, average the individual trajectories to get lo, me and
#' hi values for the population, disaggregated by titre type. If FALSE return the indidivudal trajectories.
#' Default TRUE.
- #' @param n_draws Integer. Maximum number of samples to draw. Default 2500.
+ #' @param n_draws Integer. Maximum number of samples to draw. Default 2000.
#' @param time_shift Integer. Number of days to adjust the exposure day by. Default 0.
simulate_individual_trajectories = function(
summarise = TRUE,
- n_draws = 2500,
+ n_draws = 2000,
time_shift = 0) {
private$check_fitted()
validate_logical(summarise)
@@ -534,7 +558,10 @@ biokinetics <- R6::R6Class(
by = c("calendar_day", "titre_type"))
}
- dt_out[, time_shift := time_shift]
+ dt_out <- dt_out[, time_shift := time_shift]
+ class(dt_out) <- append("biokinetics_individual_trajectories", class(dt_out))
+ attr(dt_out, "summarised") <- summarise
+ dt_out
}
)
)
diff --git a/R/epikinetics-package.R b/R/epikinetics-package.R
index 5ac6050..35b5299 100644
--- a/R/epikinetics-package.R
+++ b/R/epikinetics-package.R
@@ -11,6 +11,7 @@
#' @importFrom data.table .NGRP
#' @importFrom data.table .SD
#' @importFrom data.table data.table
+#' @importFrom ggplot2 aes facet_wrap geom_point geom_ribbon geom_line geom_smooth ggplot guides guide_legend scale_y_continuous
#' @useDynLib epikinetics, .registration = TRUE
## usethis namespace: end
diff --git a/R/plot.R b/R/plot.R
new file mode 100644
index 0000000..d8949ce
--- /dev/null
+++ b/R/plot.R
@@ -0,0 +1,133 @@
+#' @title Simulate biomarker kinetics predicted by the given biokinetics priors
+#' and optionally compare to a dataset.
+#' @export
+#' @description Simulate trajectories by drawing random samples from the given
+#' priors for each parameter in the biokinetics model.
+#' @return A ggplot2 object.
+#' @param x A named list of type 'biokinetics_priors'.
+#' @param \dots Further arguments passed to the method.
+#' @param tmax Integer. The number of time points in each simulated trajectory. Default 150.
+#' @param n_draws Integer. The number of trajectories to simulate. Default 2000.
+#' @param data Optional data.frame with columns time_since_last_exp and value. The raw data to compare to.
+plot.biokinetics_priors <- function(x,
+ ...,
+ tmax = 150,
+ n_draws = 2000,
+ data = NULL) {
+
+ # Declare variables to suppress notes when compiling package
+ # https://github.com/Rdatatable/data.table/issues/850#issuecomment-259466153
+ t0 <- tp <- ts <- m1 <- m2 <- m3 <- NULL
+ time_since_last_exp <- me <- lo <- hi <- value <- mu <- NULL
+
+ if (!is.null(data)) {
+ validate_required_cols(data, c("time_since_last_exp", "value"))
+ }
+ params <- data.table(
+ t0 = stats::rnorm(n_draws, x$mu_t0, x$sigma_t0), # titre value at t0
+ tp = stats::rnorm(n_draws, x$mu_tp, x$sigma_tp), # time of peak
+ ts = stats::rnorm(n_draws, x$mu_ts, x$sigma_ts), # time of set point
+ m1 = stats::rnorm(n_draws, x$mu_m1, x$sigma_m1), # gradient 1
+ m2 = stats::rnorm(n_draws, x$mu_m2, x$sigma_m2), # gradient 2
+ m3 = stats::rnorm(n_draws, x$mu_m3, x$sigma_m3) # gradient 3
+ )
+
+ times <- data.table(t = 1:tmax)
+ params_and_times <- times[, as.list(params), by = times]
+
+ params_and_times[, mu := biokinetics_simulate_trajectory(t, t0, tp, ts, m1, m2, m3),
+ by = c("t", "t0", "tp", "ts", "m1", "m2", "m3")]
+
+ summary <- params_and_times[, .(me = stats::quantile(mu, 0.5, names = FALSE),
+ lo = stats::quantile(mu, 0.025, names = FALSE),
+ hi = stats::quantile(mu, 0.975, names = FALSE)), by = t]
+
+ plot <- ggplot(summary) +
+ geom_line(aes(x = t, y = me)) +
+ geom_ribbon(aes(x = t, ymin = lo, ymax = hi), alpha = 0.5)
+
+ if (!is.null(data)) {
+ add_censored_indicator(data)
+ dat <- data[time_since_last_exp <= tmax,]
+ plot <- plot +
+ geom_point(data = dat, size = 0.5,
+ aes(x = time_since_last_exp,
+ y = value,
+ shape = censored)) +
+ guides(shape = guide_legend(title = "Censored"))
+ }
+ plot
+}
+
+plot_sero_data <- function(data, covariates = character(0)) {
+ validate_required_cols(data, c("time_since_last_exp", "value", "titre_type"))
+ # Declare variables to suppress notes when compiling package
+ # https://github.com/Rdatatable/data.table/issues/850#issuecomment-259466153
+ time_since_last_exp <- value <- titre_type <- NULL
+
+ ggplot(data) +
+ geom_point(aes(x = time_since_last_exp, y = value, colour = titre_type)) +
+ geom_smooth(aes(x = time_since_last_exp, y = value, colour = titre_type)) +
+ facet_wrap(eval(parse(text = facet_formula(covariates)))) +
+ guides(colour = guide_legend(title = "Titre type"))
+}
+
+#' Plot method for "biokinetics_population_trajectories" class
+#'
+#' @param x An object of class "biokinetics_population_trajectories". These are
+#' generated by running biokinetics$simulate_population_trajectories(). See
+#' \href{../../epikinetics/html/biokinetics.html#method-biokinetics-simulate_population_trajectories}{\code{biokinetics$simulate_population_trajectories()}}
+#' @param \dots Further arguments passed to the method.
+#' @param data Optional data.table containing raw data as provided to the biokinetics model.
+#' @export
+plot.biokinetics_population_trajectories <- function(x, ..., data = NULL) {
+ covariates <- attr(x, "covariates")
+
+ # Declare variables to suppress notes when compiling package
+ # https://github.com/Rdatatable/data.table/issues/850#issuecomment-259466153
+ time_since_last_exp <- value <- me <- titre_type <- lo <- hi <- NULL
+ day <- last_exp_day <- NULL
+
+ if (attr(x, "summarised")) {
+ plot <- ggplot(x) +
+ geom_line(aes(x = time_since_last_exp, y = me, colour = titre_type)) +
+ geom_ribbon(aes(x = time_since_last_exp,
+ ymin = lo,
+ ymax = hi,
+ fill = titre_type), alpha = 0.5)
+ } else {
+ plot <- ggplot(x) +
+ geom_line(aes(x = time_since_last_exp, y = mu,
+ colour = titre_type, group = .draw), alpha = 0.1, linewidth = 0.1)
+ }
+ if (!is.null(data)) {
+ validate_required_cols(data)
+ add_censored_indicator(data)
+ plot <- plot +
+ geom_point(data = data,
+ aes(x = as.integer(day - last_exp_day, units = "days"),
+ y = value, shape = censored), size = 0.5, alpha = 0.5)
+ }
+ if (attr(x, "scale") == "natural") {
+ plot <- plot + scale_y_continuous(trans = "log2")
+ }
+ plot +
+ facet_wrap(eval(parse(text = facet_formula(covariates)))) +
+ guides(fill = guide_legend(title = "Titre type"),
+ colour = "none",
+ shape = guide_legend(title = "Censored"))
+}
+
+facet_formula <- function(covariates) {
+ paste("~", paste(c("titre_type", covariates), collapse = "+"))
+}
+
+add_censored_indicator <- function(data) {
+ if (!("censored" %in% colnames(data))) {
+ # censored is an optional column in input data
+ # if not present, treat all points as uncensored
+ data[, censored:= FALSE]
+ } else {
+ data[, censored:= censored != 0]
+ }
+}
diff --git a/R/utils.R b/R/utils.R
index 1ee1a2e..532f9c8 100644
--- a/R/utils.R
+++ b/R/utils.R
@@ -1,7 +1,6 @@
convert_log2_scale <- function(
- dt_in, vars_to_transform = "titre",
+ dt_in, vars_to_transform = "value",
simplify_limits = TRUE) {
-
dt_out <- data.table::copy(dt_in)
for (var in vars_to_transform) {
if (simplify_limits == TRUE) {
diff --git a/man/biokinetics.Rd b/man/biokinetics.Rd
index 5481497..4e5f3f0 100644
--- a/man/biokinetics.Rd
+++ b/man/biokinetics.Rd
@@ -11,6 +11,8 @@ fit it to a dataset.
\subsection{Public methods}{
\itemize{
\item \href{#method-biokinetics-new}{\code{biokinetics$new()}}
+\item \href{#method-biokinetics-plot_prior_predictive}{\code{biokinetics$plot_prior_predictive()}}
+\item \href{#method-biokinetics-plot_model_inputs}{\code{biokinetics$plot_model_inputs()}}
\item \href{#method-biokinetics-get_stan_data}{\code{biokinetics$get_stan_data()}}
\item \href{#method-biokinetics-get_covariate_lookup_table}{\code{biokinetics$get_covariate_lookup_table()}}
\item \href{#method-biokinetics-fit}{\code{biokinetics$fit()}}
@@ -62,6 +64,45 @@ An epikinetics::biokinetics object.
}
}
\if{html}{\out{
}}
+\if{html}{\out{ }}
+\if{latex}{\out{\hypertarget{method-biokinetics-plot_prior_predictive}{}}}
+\subsection{Method \code{plot_prior_predictive()}}{
+Plot the kinetics trajectory predicted by the model priors.
+Note that this is on a log scale, regardless of whether the data was provided
+on a log or a natural scale.
+\subsection{Usage}{
+\if{html}{\out{}}\preformatted{biokinetics$plot_prior_predictive(tmax = 150, n_draws = 2000)}\if{html}{\out{
}}
+}
+
+\subsection{Arguments}{
+\if{html}{\out{}}
+\describe{
+\item{\code{tmax}}{Integer. The number of time points in each simulated trajectory. Default 150.}
+
+\item{\code{n_draws}}{Integer. The number of trajectories to simulate. Default 2000.}
+}
+\if{html}{\out{
}}
+}
+\subsection{Returns}{
+A ggplot2 object.
+}
+}
+\if{html}{\out{ }}
+\if{html}{\out{ }}
+\if{latex}{\out{\hypertarget{method-biokinetics-plot_model_inputs}{}}}
+\subsection{Method \code{plot_model_inputs()}}{
+Plot model input data with a smoothing function. Note that
+this plot is on a log scale, regardless of whether data was provided on a
+log or a natural scale.
+\subsection{Usage}{
+\if{html}{\out{}}\preformatted{biokinetics$plot_model_inputs()}\if{html}{\out{
}}
+}
+
+\subsection{Returns}{
+A ggplot2 object.
+}
+}
+\if{html}{\out{ }}
\if{html}{\out{ }}
\if{latex}{\out{\hypertarget{method-biokinetics-get_stan_data}{}}}
\subsection{Method \code{get_stan_data()}}{
@@ -115,7 +156,7 @@ A CmdStanMCMC fitted model object: \url{https://mc-stan.org/cmdstanr/reference/C
Extract fitted population parameters
\subsection{Usage}{
\if{html}{\out{}}\preformatted{biokinetics$extract_population_parameters(
- n_draws = 2500,
+ n_draws = 2000,
human_readable_covariates = TRUE
)}\if{html}{\out{
}}
}
@@ -123,7 +164,7 @@ Extract fitted population parameters
\subsection{Arguments}{
\if{html}{\out{}}
\describe{
-\item{\code{n_draws}}{Numeric}
+\item{\code{n_draws}}{Integer. Default 2000.}
\item{\code{human_readable_covariates}}{Logical. Default TRUE.}
}
@@ -140,7 +181,7 @@ A data.table
Extract fitted individual parameters
\subsection{Usage}{
\if{html}{\out{
}}\preformatted{biokinetics$extract_individual_parameters(
- n_draws = 2500,
+ n_draws = 2000,
include_variation_params = TRUE,
human_readable_covariates = TRUE
)}\if{html}{\out{
}}
@@ -149,7 +190,7 @@ Extract fitted individual parameters
\subsection{Arguments}{
\if{html}{\out{
}}
\describe{
-\item{\code{n_draws}}{Numeric}
+\item{\code{n_draws}}{Integer. Default 2000.}
\item{\code{include_variation_params}}{Logical}
@@ -170,7 +211,7 @@ Process the model results into a data table of titre values over time.
\if{html}{\out{
}}\preformatted{biokinetics$simulate_population_trajectories(
t_max = 150,
summarise = TRUE,
- n_draws = 2500
+ n_draws = 2000
)}\if{html}{\out{
}}
}
@@ -183,7 +224,7 @@ Process the model results into a data table of titre values over time.
return 0.025, 0.5 and 0.975 quantiles, labelled lo, me and hi, respectively. If FALSE returns values for individual
draws from posterior parameter distributions.}
-\item{\code{n_draws}}{Integer. Maximum number of samples to include. Default 2500.}
+\item{\code{n_draws}}{Integer. Maximum number of samples to include. Default 2000.}
}
\if{html}{\out{
}}
}
@@ -201,13 +242,13 @@ titre_type and a column for each covariate in the hierarchical model. See the da
\subsection{Method \code{population_stationary_points()}}{
Process the stan model results into a data.table.
\subsection{Usage}{
-\if{html}{\out{
}}\preformatted{biokinetics$population_stationary_points(n_draws = 2500)}\if{html}{\out{
}}
+\if{html}{\out{
}}\preformatted{biokinetics$population_stationary_points(n_draws = 2000)}\if{html}{\out{
}}
}
\subsection{Arguments}{
\if{html}{\out{
}}
\describe{
-\item{\code{n_draws}}{Integer. Maximum number of samples to include. Default 2500.}
+\item{\code{n_draws}}{Integer. Maximum number of samples to include. Default 2000.}
}
\if{html}{\out{
}}
}
@@ -226,7 +267,7 @@ computationally expensive and may take a while to run if n_draws is large.
\subsection{Usage}{
\if{html}{\out{
}}\preformatted{biokinetics$simulate_individual_trajectories(
summarise = TRUE,
- n_draws = 2500,
+ n_draws = 2000,
time_shift = 0
)}\if{html}{\out{
}}
}
@@ -238,7 +279,7 @@ computationally expensive and may take a while to run if n_draws is large.
hi values for the population, disaggregated by titre type. If FALSE return the indidivudal trajectories.
Default TRUE.}
-\item{\code{n_draws}}{Integer. Maximum number of samples to draw. Default 2500.}
+\item{\code{n_draws}}{Integer. Maximum number of samples to draw. Default 2000.}
\item{\code{time_shift}}{Integer. Number of days to adjust the exposure day by. Default 0.}
}
diff --git a/man/epikinetics-package.Rd b/man/epikinetics-package.Rd
index 77153e1..29fb876 100644
--- a/man/epikinetics-package.Rd
+++ b/man/epikinetics-package.Rd
@@ -6,7 +6,7 @@
\alias{epikinetics-package}
\title{epikinetics: Biomarker Kinetics Modelling}
\description{
-Fit kinetic curves to biomarker data, using a Bayesian hierarchical model
+Fit kinetic curves to biomarker data, using a Bayesian hierarchical model.
}
\author{
\strong{Maintainer}: Alex Hill \email{alex.hill@gmail.com}
diff --git a/man/plot.biokinetics_population_trajectories.Rd b/man/plot.biokinetics_population_trajectories.Rd
new file mode 100644
index 0000000..333ae60
--- /dev/null
+++ b/man/plot.biokinetics_population_trajectories.Rd
@@ -0,0 +1,20 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/plot.R
+\name{plot.biokinetics_population_trajectories}
+\alias{plot.biokinetics_population_trajectories}
+\title{Plot method for "biokinetics_population_trajectories" class}
+\usage{
+\method{plot}{biokinetics_population_trajectories}(x, ..., data = NULL)
+}
+\arguments{
+\item{x}{An object of class "biokinetics_population_trajectories". These are
+generated by running biokinetics$simulate_population_trajectories(). See
+\href{../../epikinetics/html/biokinetics.html#method-biokinetics-simulate_population_trajectories}{\code{biokinetics$simulate_population_trajectories()}}}
+
+\item{\dots}{Further arguments passed to the method.}
+
+\item{data}{Optional data.table containing raw data as provided to the biokinetics model.}
+}
+\description{
+Plot method for "biokinetics_population_trajectories" class
+}
diff --git a/man/plot.biokinetics_priors.Rd b/man/plot.biokinetics_priors.Rd
new file mode 100644
index 0000000..3f116a8
--- /dev/null
+++ b/man/plot.biokinetics_priors.Rd
@@ -0,0 +1,27 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/plot.R
+\name{plot.biokinetics_priors}
+\alias{plot.biokinetics_priors}
+\title{Simulate biomarker kinetics predicted by the given biokinetics priors
+and optionally compare to a dataset.}
+\usage{
+\method{plot}{biokinetics_priors}(x, ..., tmax = 150, n_draws = 2000, data = NULL)
+}
+\arguments{
+\item{x}{A named list of type 'biokinetics_priors'.}
+
+\item{\dots}{Further arguments passed to the method.}
+
+\item{tmax}{Integer. The number of time points in each simulated trajectory. Default 150.}
+
+\item{n_draws}{Integer. The number of trajectories to simulate. Default 2000.}
+
+\item{data}{Optional data.frame with columns time_since_last_exp and value. The raw data to compare to.}
+}
+\value{
+A ggplot2 object.
+}
+\description{
+Simulate trajectories by drawing random samples from the given
+priors for each parameter in the biokinetics model.
+}
diff --git a/src/stan/antibody_kinetics_main.stan b/src/stan/antibody_kinetics_main.stan
index 808fc88..61708a2 100644
--- a/src/stan/antibody_kinetics_main.stan
+++ b/src/stan/antibody_kinetics_main.stan
@@ -149,7 +149,7 @@ model {
// Likelihood for observations at lower limit: log2(value/5) = 0
target += normal_lcdf(0 | mu[cens_lo_idx], sigma);
- // Censoring at log2(value/5) = 7, originally value = 2560
+ // Censoring at log2(value/5) = 9, originally value = 2560
target += normal_lccdf(9 | mu[cens_hi_idx], sigma);
// Covariate-level mean priors, parameterised from previous studies
diff --git a/tests/testthat.R b/tests/testthat.R
index 9fc03dd..41aef3c 100644
--- a/tests/testthat.R
+++ b/tests/testthat.R
@@ -1,4 +1,5 @@
library(testthat)
library(epikinetics)
+library(vdiffr)
test_check("epikinetics")
diff --git a/tests/testthat/_snaps/plots/inputdata-covariates.svg b/tests/testthat/_snaps/plots/inputdata-covariates.svg
new file mode 100644
index 0000000..20b5d78
--- /dev/null
+++ b/tests/testthat/_snaps/plots/inputdata-covariates.svg
@@ -0,0 +1,2506 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
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+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Ancestral
+
+Previously infected (Pre-Omicron)
+
+
+
+
+
+
+
+
+
+
+Delta
+
+Infection naive
+
+
+
+
+
+
+
+
+
+
+Delta
+
+Previously infected (Pre-Omicron)
+
+
+
+
+
+
+
+
+
+
+Alpha
+
+Infection naive
+
+
+
+
+
+
+
+
+
+
+Alpha
+
+Previously infected (Pre-Omicron)
+
+
+
+
+
+
+
+
+
+
+Ancestral
+
+Infection naive
+
+
+
+
+
+
+0
+200
+400
+600
+
+
+
+
+0
+200
+400
+600
+
+
+
+
+0
+200
+400
+600
+0
+3
+6
+9
+
+
+
+
+0
+3
+6
+9
+
+
+
+
+time_since_last_exp
+value
+
+Titre type
+
+
+
+
+
+
+
+
+
+
+
+
+Alpha
+Ancestral
+Delta
+inputdata_covariates
+
+
diff --git a/tests/testthat/_snaps/plots/inputdata.svg b/tests/testthat/_snaps/plots/inputdata.svg
new file mode 100644
index 0000000..e4c509f
--- /dev/null
+++ b/tests/testthat/_snaps/plots/inputdata.svg
@@ -0,0 +1,2408 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Alpha
+
+
+
+
+
+
+
+
+
+
+Ancestral
+
+
+
+
+
+
+
+
+
+
+Delta
+
+
+
+
+
+
+0
+200
+400
+600
+
+
+
+
+0
+200
+400
+600
+
+
+
+
+0
+200
+400
+600
+0
+3
+6
+9
+
+
+
+
+time_since_last_exp
+value
+
+Titre type
+
+
+
+
+
+
+
+
+
+
+
+
+Alpha
+Ancestral
+Delta
+inputdata
+
+
diff --git a/tests/testthat/_snaps/plots/multiplecovariates-unsum.svg b/tests/testthat/_snaps/plots/multiplecovariates-unsum.svg
new file mode 100644
index 0000000..b459444
--- /dev/null
+++ b/tests/testthat/_snaps/plots/multiplecovariates-unsum.svg
@@ -0,0 +1,3482 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Ancestral
+
+NA
+
+mRNA1273
+
+
+
+
+
+
+
+
+
+
+Ancestral
+
+NA
+
+others
+
+
+
+
+
+
+
+
+
+
+Delta
+
+Infection naive
+
+NA
+
+
+
+
+
+
+
+
+
+
+Delta
+
+Previously infected (Pre-Omicron)
+
+NA
+
+
+
+
+
+
+
+
+
+
+Delta
+
+NA
+
+AZD1222
+
+
+
+
+
+
+
+
+
+
+Alpha
+
+NA
+
+others
+
+
+
+
+
+
+
+
+
+
+Ancestral
+
+Infection naive
+
+NA
+
+
+
+
+
+
+
+
+
+
+Ancestral
+
+Previously infected (Pre-Omicron)
+
+NA
+
+
+
+
+
+
+
+
+
+
+Ancestral
+
+NA
+
+AZD1222
+
+
+
+
+
+
+
+
+
+
+Ancestral
+
+NA
+
+BNT162b2
+
+
+
+
+
+
+
+
+
+
+Alpha
+
+Infection naive
+
+NA
+
+
+
+
+
+
+
+
+
+
+Alpha
+
+Previously infected (Pre-Omicron)
+
+NA
+
+
+
+
+
+
+
+
+
+
+Alpha
+
+NA
+
+AZD1222
+
+
+
+
+
+
+
+
+
+
+Alpha
+
+NA
+
+BNT162b2
+
+
+
+
+
+
+
+
+
+
+Alpha
+
+NA
+
+mRNA1273
+
+
+
+
+
+
+0
+50
+100
+150
+
+
+
+
+0
+50
+100
+150
+
+
+
+
+0
+50
+100
+150
+
+
+
+
+0
+50
+100
+150
+
+
+
+
+0
+50
+100
+150
+64
+2048
+65536
+2097152
+
+
+
+
+64
+2048
+65536
+2097152
+
+
+
+
+64
+2048
+65536
+2097152
+
+
+
+
+64
+2048
+65536
+2097152
+
+
+
+
+time_since_last_exp
+mu
+multiplecovariates_unsum
+
+
diff --git a/tests/testthat/_snaps/plots/multiplecovariates.svg b/tests/testthat/_snaps/plots/multiplecovariates.svg
new file mode 100644
index 0000000..61c4096
--- /dev/null
+++ b/tests/testthat/_snaps/plots/multiplecovariates.svg
@@ -0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
+
+
+
+Ancestral
+
+Infection naive
+
+NA
+
+
+
+
+
+
+
+
+
+
+Ancestral
+
+Previously infected (Pre-Omicron)
+
+NA
+
+
+
+
+
+
+
+
+
+
+Ancestral
+
+NA
+
+AZD1222
+
+
+
+
+
+
+
+
+
+
+Ancestral
+
+NA
+
+BNT162b2
+
+
+
+
+
+
+
+
+
+
+Alpha
+
+Infection naive
+
+NA
+
+
+
+
+
+
+
+
+
+
+Alpha
+
+Previously infected (Pre-Omicron)
+
+NA
+
+
+
+
+
+
+
+
+
+
+Alpha
+
+NA
+
+AZD1222
+
+
+
+
+
+
+
+
+
+
+Alpha
+
+NA
+
+BNT162b2
+
+
+
+
+
+
+
+
+
+
+Alpha
+
+NA
+
+mRNA1273
+
+
+
+
+
+
+0
+50
+100
+150
+
+
+
+
+0
+50
+100
+150
+
+
+
+
+0
+50
+100
+150
+
+
+
+
+0
+50
+100
+150
+
+
+
+
+0
+50
+100
+150
+64
+2048
+65536
+2097152
+
+
+
+
+64
+2048
+65536
+2097152
+
+
+
+
+64
+2048
+65536
+2097152
+
+
+
+
+64
+2048
+65536
+2097152
+
+
+
+
+time_since_last_exp
+me
+
+Titre type
+
+
+
+
+
+
+Alpha
+Ancestral
+Delta
+multiplecovariates
+
+
diff --git a/tests/testthat/_snaps/plots/populationtrajectories-data.svg b/tests/testthat/_snaps/plots/populationtrajectories-data.svg
new file mode 100644
index 0000000..25a0e04
--- /dev/null
+++ b/tests/testthat/_snaps/plots/populationtrajectories-data.svg
@@ -0,0 +1,2508 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
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+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Ancestral
+
+Previously infected (Pre-Omicron)
+
+
+
+
+
+
+
+
+
+
+Delta
+
+Infection naive
+
+
+
+
+
+
+
+
+
+
+Delta
+
+Previously infected (Pre-Omicron)
+
+
+
+
+
+
+
+
+
+
+Alpha
+
+Infection naive
+
+
+
+
+
+
+
+
+
+
+Alpha
+
+Previously infected (Pre-Omicron)
+
+
+
+
+
+
+
+
+
+
+Ancestral
+
+Infection naive
+
+
+
+
+
+
+0
+200
+400
+600
+
+
+
+
+0
+200
+400
+600
+
+
+
+
+0
+200
+400
+600
+128
+8192
+524288
+33554432
+
+
+
+
+128
+8192
+524288
+33554432
+
+
+
+
+time_since_last_exp
+me
+
+Titre type
+
+
+
+
+
+
+Alpha
+Ancestral
+Delta
+
+Censored
+
+
+
+
+FALSE
+TRUE
+populationtrajectories_data
+
+
diff --git a/tests/testthat/_snaps/plots/populationtrajectories-logscale.svg b/tests/testthat/_snaps/plots/populationtrajectories-logscale.svg
new file mode 100644
index 0000000..dceb8df
--- /dev/null
+++ b/tests/testthat/_snaps/plots/populationtrajectories-logscale.svg
@@ -0,0 +1,2512 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
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+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Ancestral
+
+Previously infected (Pre-Omicron)
+
+
+
+
+
+
+
+
+
+
+Delta
+
+Infection naive
+
+
+
+
+
+
+
+
+
+
+Delta
+
+Previously infected (Pre-Omicron)
+
+
+
+
+
+
+
+
+
+
+Alpha
+
+Infection naive
+
+
+
+
+
+
+
+
+
+
+Alpha
+
+Previously infected (Pre-Omicron)
+
+
+
+
+
+
+
+
+
+
+Ancestral
+
+Infection naive
+
+
+
+
+
+
+0
+200
+400
+600
+
+
+
+
+0
+200
+400
+600
+
+
+
+
+0
+200
+400
+600
+0
+5
+10
+15
+20
+
+
+
+
+
+0
+5
+10
+15
+20
+
+
+
+
+
+time_since_last_exp
+me
+
+Titre type
+
+
+
+
+
+
+Alpha
+Ancestral
+Delta
+
+Censored
+
+
+
+
+FALSE
+TRUE
+populationtrajectories_logscale
+
+
diff --git a/tests/testthat/_snaps/plots/populationtrajectories-unsum.svg b/tests/testthat/_snaps/plots/populationtrajectories-unsum.svg
new file mode 100644
index 0000000..f06ec39
--- /dev/null
+++ b/tests/testthat/_snaps/plots/populationtrajectories-unsum.svg
@@ -0,0 +1,1170 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
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+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Ancestral
+
+Previously infected (Pre-Omicron)
+
+
+
+
+
+
+
+
+
+
+Delta
+
+Infection naive
+
+
+
+
+
+
+
+
+
+
+Delta
+
+Previously infected (Pre-Omicron)
+
+
+
+
+
+
+
+
+
+
+Alpha
+
+Infection naive
+
+
+
+
+
+
+
+
+
+
+Alpha
+
+Previously infected (Pre-Omicron)
+
+
+
+
+
+
+
+
+
+
+Ancestral
+
+Infection naive
+
+
+
+
+
+
+0
+50
+100
+150
+
+
+
+
+0
+50
+100
+150
+
+
+
+
+0
+50
+100
+150
+128
+8192
+524288
+33554432
+
+
+
+
+128
+8192
+524288
+33554432
+
+
+
+
+time_since_last_exp
+mu
+populationtrajectories_unsum
+
+
diff --git a/tests/testthat/_snaps/plots/populationtrajectories.svg b/tests/testthat/_snaps/plots/populationtrajectories.svg
new file mode 100644
index 0000000..1aa7f3f
--- /dev/null
+++ b/tests/testthat/_snaps/plots/populationtrajectories.svg
@@ -0,0 +1,245 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Ancestral
+
+Previously infected (Pre-Omicron)
+
+
+
+
+
+
+
+
+
+
+Delta
+
+Infection naive
+
+
+
+
+
+
+
+
+
+
+Delta
+
+Previously infected (Pre-Omicron)
+
+
+
+
+
+
+
+
+
+
+Alpha
+
+Infection naive
+
+
+
+
+
+
+
+
+
+
+Alpha
+
+Previously infected (Pre-Omicron)
+
+
+
+
+
+
+
+
+
+
+Ancestral
+
+Infection naive
+
+
+
+
+
+
+0
+50
+100
+150
+
+
+
+
+0
+50
+100
+150
+
+
+
+
+0
+50
+100
+150
+128
+8192
+524288
+33554432
+
+
+
+
+128
+8192
+524288
+33554432
+
+
+
+
+time_since_last_exp
+me
+
+Titre type
+
+
+
+
+
+
+Alpha
+Ancestral
+Delta
+populationtrajectories
+
+
diff --git a/tests/testthat/_snaps/plots/priorpredictive.svg b/tests/testthat/_snaps/plots/priorpredictive.svg
new file mode 100644
index 0000000..bd09980
--- /dev/null
+++ b/tests/testthat/_snaps/plots/priorpredictive.svg
@@ -0,0 +1,2315 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
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b/tests/testthat/test-data.R
@@ -52,7 +52,9 @@ test_that("Natural scale data is converted to log scale for stan", {
dat <- data.table::fread(system.file("delta_full.rds", package = "epikinetics"))
mod <- biokinetics$new(data = dat)
stan_data <- mod$get_stan_data()
- expect_equal(stan_data$value, convert_log2_scale(dat, "value")$value, ignore_attr = TRUE)
+ expect_equal(stan_data$value,
+ convert_log2_scale(dat, "value")$value,
+ ignore_attr = TRUE)
})
test_that("Log scale data is passed directly to stan", {
diff --git a/tests/testthat/test-plots.R b/tests/testthat/test-plots.R
new file mode 100644
index 0000000..710ec71
--- /dev/null
+++ b/tests/testthat/test-plots.R
@@ -0,0 +1,124 @@
+test_that("Can plot prior prediction up to tmax", {
+ priors <- biokinetics_priors()
+ plot <- plot(priors, tmax = 100, n_draws = 500)
+ expect_equal(nrow(plot$data), 100)
+ expect_equal(length(plot$layers), 2)
+})
+
+test_that("Can plot prior prediction with data points", {
+ data <- data.table::fread(system.file("delta_full.rds", package = "epikinetics"))
+ priors <- biokinetics_priors()
+ expect_error(plot(priors, data = data), "Missing required columns: time_since_last_exp")
+ data[, `:=`(time_since_last_exp = as.integer(day - last_exp_day, units = "days"))]
+ plot <- plot(priors, data = data, n_draws = 500)
+ expect_equal(length(plot$layers), 3)
+})
+
+test_that("Can plot prior predictions from model", {
+ data <- data.table::fread(system.file("delta_full.rds", package = "epikinetics"))
+ priors <- biokinetics_priors(mu_values = c(4.1, 11, 65, 0.2, -0.01, 0.01),
+ sigma_values = c(2.0, 2.0, 3.0, 0.01, 0.01, 0.001))
+
+ mod <- biokinetics$new(priors = priors,
+ data = data)
+ set.seed(1)
+ plot <- mod$plot_prior_predictive(tmax = 400, n_draws = 500)
+ expect_equal(nrow(plot$data), 400)
+ expect_equal(length(plot$layers), 3)
+})
+
+test_that("Prior predictions from model are the same", {
+ data <- data.table::fread(system.file("delta_full.rds", package = "epikinetics"))
+ priors <- biokinetics_priors(mu_values = c(4.1, 11, 65, 0.2, -0.01, 0.01),
+ sigma_values = c(2.0, 2.0, 3.0, 0.01, 0.01, 0.001))
+
+ mod <- biokinetics$new(priors = priors,
+ data = data)
+ set.seed(1)
+ plot <- mod$plot_prior_predictive(tmax = 400, n_draws = 500)
+ vdiffr::expect_doppelganger("priorpredictive", plot)
+})
+
+test_that("Can plot input data", {
+ data <- data.table::fread(system.file("delta_full.rds", package = "epikinetics"))
+ mod <- biokinetics$new(data = data)
+ plot <- mod$plot_model_inputs()
+ vdiffr::expect_doppelganger("inputdata", plot)
+
+ mod <- biokinetics$new(data = data, covariate_formula = ~0 + infection_history)
+ plot <- mod$plot_model_inputs()
+ vdiffr::expect_doppelganger("inputdata_covariates", plot)
+})
+
+mock_model <- function(name, package) {
+ list(sample = function(x, ...) readRDS(test_path("testdata", "testdraws.rds")))
+}
+
+mock_model_multiple_covariates <- function(name, package) {
+ list(sample = function(x, ...) readRDS(test_path("testdata", "testdraws_multiplecovariates.rds")))
+}
+
+test_that("Can plot summarised and un-summarised population trajectories", {
+ # note that this is using a pre-fitted model with very few iterations, so the
+ # fits won't look very good
+ local_mocked_bindings(
+ stan_package_model = mock_model, .package = "instantiate"
+ )
+ mod <- biokinetics$new(file_path = system.file("delta_full.rds", package = "epikinetics"),
+ covariate_formula = ~0 + infection_history)
+ mod$fit()
+ trajectories <- mod$simulate_population_trajectories(summarise = TRUE)
+ vdiffr::expect_doppelganger("populationtrajectories", plot(trajectories))
+
+ unsummarised_trajectories <- mod$simulate_population_trajectories(summarise = FALSE)
+ vdiffr::expect_doppelganger("populationtrajectories_unsum", plot(unsummarised_trajectories))
+})
+
+test_that("Can plot summarised and un-summarised population trajectories for multiple covariates", {
+ # note that this is using a pre-fitted model with very few iterations, so the
+ # fits won't look very good
+ local_mocked_bindings(
+ stan_package_model = mock_model_multiple_covariates, .package = "instantiate"
+ )
+ mod <- biokinetics$new(file_path = system.file("delta_full.rds", package = "epikinetics"),
+ covariate_formula = ~0 + infection_history + last_vax_type)
+ mod$fit()
+ trajectories <- mod$simulate_population_trajectories(summarise = TRUE)
+ vdiffr::expect_doppelganger("multiplecovariates", plot(trajectories))
+
+ unsummarised_trajectories <- mod$simulate_population_trajectories(summarise = FALSE)
+ vdiffr::expect_doppelganger("multiplecovariates_unsum", plot(unsummarised_trajectories))
+})
+
+test_that("Can plot population trajectories with data", {
+ local_mocked_bindings(
+ stan_package_model = mock_model, .package = "instantiate"
+ )
+ # note that this is using a pre-fitted model with very few iterations, so the
+ # fits won't look very good
+ data <- data.table::fread(system.file("delta_full.rds", package = "epikinetics"))
+ mod <- biokinetics$new(data = data, covariate_formula = ~0 + infection_history)
+ fit <- mod$fit()
+ trajectories <- mod$simulate_population_trajectories()
+ plot <- plot(trajectories, data = data)
+ expect_equal(length(plot$scales$scales), 1)
+ vdiffr::expect_doppelganger("populationtrajectories_data", plot)
+})
+
+test_that("Can plot population trajectories with log scale input data", {
+ local_mocked_bindings(
+ stan_package_model = mock_model, .package = "instantiate"
+ )
+ # note that this is using a pre-fitted model with very few iterations, so the
+ # fits won't look very good
+ data <- data.table::fread(system.file("delta_full.rds", package = "epikinetics"))
+ data <- convert_log2_scale(data)
+ mod <- biokinetics$new(data = data,
+ covariate_formula = ~0 + infection_history,
+ scale = "log")
+ fit <- mod$fit()
+ trajectories <- mod$simulate_population_trajectories()
+ plot <- plot(trajectories, data = data)
+ expect_equal(length(plot$scales$scales), 0)
+ vdiffr::expect_doppelganger("populationtrajectories_logscale", plot)
+})