create_posterior_func: Creates the posterior function to be used in the MCMC...

View source: R/create_posterior_func.R

create_posterior_funcR Documentation

Creates the posterior function to be used in the MCMC framework.

Description

Creates a new function which calculates the posterior probability of a set of parameter values conditional on the Ct data.

Usage

create_posterior_func(
  parTab,
  data,
  PRIOR_FUNC = NULL,
  INCIDENCE_FUNC = NULL,
  solve_ver = "likelihood",
  solve_likelihood = TRUE,
  use_pos = FALSE,
  ...
)

Arguments

parTab

A vector of model parameters with names corresponding to the parameter control table.

data

A tibble containing two columns: t for sample time and ct for the Ct values.

PRIOR_FUNC

A function for the prior distribution. NULL by default.

INCIDENCE_FUNC

A function that returns a vector of daily infection probabilities/ incidence. NULL by default.

solve_likelihood

Solves the likelihood. TRUE by default.

use_pos

To fit the model using ALL PCR results (i.e. including samples testing negative), set this to FALSE. If the data only include positive Ct values (i.e. only Ct values < the LOD), then this should be set to TRUE. FALSE by default.

solver_ver

Can be set to 'model' or 'likelihood.' 'model' returns the predicted Ct distribution rather than the posterior probability. Set to 'likelihood' by default.

Value

Returns a single log posterior probability or the predicted Ct distribution.

Author(s)

James Hay, jhay@hsph.harvard.edu

See Also

Other create posterior functions: create_post_func_seeirr_combined(), create_post_func_seeirr(), create_posterior_func_detectable()

Examples

incidence_function <- solveSEIRModel_lsoda_wrapper
data(example_seir_partab)
posterior_func <- create_posterior_func(parTab=example_seir_partab,
                                       data=example_ct_data,
                                       PRIOR_FUNC=prior_func_seir,
                                       INCIDENCE_FUNC=incidence_function,
                                       use_pos=FALSE) ## Important argument, see text
posterior_func(example_seir_partab$values)


jameshay218/virosolver documentation built on April 17, 2025, 2:57 p.m.