Create an instance of the biomarker kinetics model and fit it to a dataset.

Methods


Method new()

Initialise the kinetics model.

Usage

biokinetics$new(
  priors = biokinetics_priors(),
  data = NULL,
  file_path = NULL,
  covariate_formula = ~0,
  preds_sd = 0.25,
  scale = "natural"
)

Arguments

priors

Object of type biokinetics_priors. Default biokinetics_priors().

data

Optional data table of model inputs. One of data or file must be provided. See the data vignette for required columns: vignette("data", package = "epikinetics").

file_path

Optional file path to model inputs in CSV format. One of data or file must be provided.

covariate_formula

Formula specifying linear regression model. Note all variables in the formula will be treated as categorical variables. Default ~0.

preds_sd

Standard deviation of predictor coefficients. Default 0.25.

scale

One of "log" or "natural". Default "natural". Is provided data on a log or a natural scale? If on a natural scale it will be converted to a log scale for model fitting.

Returns

An epikinetics::biokinetics object.


Method get_stan_data()

View the data that is passed to the stan model, for debugging purposes.

Usage

biokinetics$get_stan_data()

Returns

A list of arguments that will be passed to the stan model.


Method get_covariate_lookup_table()

View the mapping of human readable covariate names to the model variable p.

Usage

biokinetics$get_covariate_lookup_table()

Returns

A data.table mapping the model variable p to human readable covariates.


Method fit()

Fit the model and return CmdStanMCMC fitted model object.

Usage

biokinetics$fit(...)

Arguments

...

Named arguments to the sample() method of CmdStan model. objects: https://mc-stan.org/cmdstanr/reference/model-method-sample.html

Returns

A CmdStanMCMC fitted model object: https://mc-stan.org/cmdstanr/reference/CmdStanMCMC.html


Method extract_population_parameters()

Extract fitted population parameters

Usage

biokinetics$extract_population_parameters(
  n_draws = 2500,
  human_readable_covariates = TRUE
)

Arguments

n_draws

Numeric

human_readable_covariates

Logical. Default TRUE.

Returns

A data.table


Method extract_individual_parameters()

Extract fitted individual parameters

Usage

biokinetics$extract_individual_parameters(
  n_draws = 2500,
  include_variation_params = TRUE,
  human_readable_covariates = TRUE
)

Arguments

n_draws

Numeric

include_variation_params

Logical

human_readable_covariates

Logical. Default TRUE.

Returns

A data.table


Method simulate_population_trajectories()

Process the model results into a data table of titre values over time.

Usage

biokinetics$simulate_population_trajectories(
  t_max = 150,
  summarise = TRUE,
  n_draws = 2500
)

Arguments

t_max

Integer. Maximum number of time points to include.

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.

n_draws

Integer. Maximum number of samples to include. Default 2500.

Returns

A data.table containing titre values at time points. If summarise = TRUE, columns are time_since_last_exp, me, lo, hi, titre_type, and a column for each covariate in the hierarchical model. If summarise = FALSE, columns are time_since_last_exp, .draw, t0_pop, tp_pop, ts_pop, m1_pop, m2_pop, m3_pop, beta_t0, beta_tp, beta_ts, beta_m1, beta_m2, beta_m3, mu titre_type and a column for each covariate in the hierarchical model. See the data vignette for details: vignette("data", package = "epikinetics")


Method population_stationary_points()

Process the stan model results into a data.table.

Usage

biokinetics$population_stationary_points(n_draws = 2500)

Arguments

n_draws

Integer. Maximum number of samples to include. Default 2500.

Returns

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: vignette("data", package = "epikinetics")


Method simulate_individual_trajectories()

Simulate individual trajectories from the model. This is computationally expensive and may take a while to run if n_draws is large.

Usage

biokinetics$simulate_individual_trajectories(
  summarise = TRUE,
  n_draws = 2500,
  time_shift = 0
)

Arguments

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.

n_draws

Integer. Maximum number of samples to draw. Default 2500.

time_shift

Integer. Number of days to adjust the exposure day by. Default 0.

Returns

A data.table. If summarise = TRUE columns are calendar_date, titre_type, me, lo, hi, time_shift. If summarise = FALSE, columns are pid, draw, time_since_last_exp, mu, titre_type, exposure_day, calendar_day, time_shift and a column for each covariate in the regression model. See the data vignette for details: vignette("data", package = "epikinetics").