Skip to contents

Specify the cycle threshold adjustment model formula

Usage

adjustment_formula(formula = ~1, obs, beta_default = c(0, 0.1))

Arguments

formula

A model formula defaulting to ~1.

obs

A data.frame with the following variables:

  • id: An integer vector uniquely identifying eahc infection.

  • test_id: An integer vector uniquely identiying each test

  • ct_value: Numeric cycle threshold value.

  • t: Relative (to a baseline) time of the test yielding a Ct value.

  • t_rel_uncensored: Time of test relative to the first uncensored Ct value for that id.

  • onset_t: Relative (to a baseline) time of onset for each infection

  • onset_t_rel_uncensored: Time of onset relative to the first uncensored Ct value for that id. (optional). NA if unavailable/asymptomatic.

  • censored: Logical, indicating if the Ct has been censored.

beta_default

A vector of length two containing the default mean and standard deviation to use as the prior for all covariate effect sizes.

Value

A named list including the design matrix ("design") and a data.table of priors for covariate effects ("beta").

Author

Sam Abbott

Examples

obs <- data.frame(
 age = c(1, 2, 3), cats = c(1, 2, 1), status = c("h", "l", "h")
)
adjustment_formula(~ cats + age + status, obs)
#> $design
#>   (Intercept) cats age statusl
#> 1           1    1   1       0
#> 2           1    2   2       1
#> 3           1    1   3       0
#> attr(,"assign")
#> [1] 0 1 2 3
#> attr(,"contrasts")
#> attr(,"contrasts")$status
#> [1] "contr.treatment"
#> 
#> 
#> $beta
#>    parameter  effect mean  sd
#> 1:  ct_scale     age    0 0.1
#> 2:  ct_scale    cats    0 0.1
#> 3:  ct_scale statusl    0 0.1
#> 4:  ct_shift     age    0 0.1
#> 5:  ct_shift    cats    0 0.1
#> 6:  ct_shift statusl    0 0.1
#>