Skip to contents

The $create_model() method creates a new MRPModel object with Stan code generated from the model specification list. CmdStanR objects are used internally to interface with Stan to compile the code and run its MCMC algorithm. Check out the More examples of R6 classes vignette for usage examples.

Usage

create_model(
  intercept_prior = NULL,
  fixed = NULL,
  varying = NULL,
  interaction = NULL,
  sens = 1,
  spec = 1
)

Arguments

intercept_prior

Character string specifying the prior distribution for the overall intercept. Check Details for more information about prior specification.

fixed

List of the fixed effects in the model and their prior distributions. Check Details for more information about prior specification.

varying

List of the varying effects in the model and the prior distributions of their standard deviations. Check Details for more information about prior specification.

interaction

List of the interactions in the model and their prior distributions. Interaction names are created by concatenating the names of the interacting variables with a colon (e.g., "sex:age"). Currently, only two-way interactions are supported. Check Details for more information about prior specification.

sens

Sensitivity adjustment in the COVID-19 test results. Check Details for more information.

spec

Specificity adjustment in the COVID-19 test results. Check Details for more information.

Value

A new MRPModel object.

Details

Prior specification

The syntax for the prior distributions is similar to that of Stan. The following are currently supported:

  • normal(mu, sigma)

  • student_t(nu, mu, sigma)

  • structured*

The last one is a custom prior syntax for the structured prior distribution developed by Si et al. (2020).

The following default prior distributions are assigned to effects with empty strings ("") in the model specification list:

  • Overall intercept: normal(0,5)

  • Coefficient: normal(0,3)

The model assumes varying effects follow a normal distribution with an unknown standard deviation, which will be assigned with priors.

  • Standard deviation (main effect): normal+(0,3)

  • Standard deviation (interaction): normal+(0,1)

Testing sensitivity and specificity

For COVID data, we allow users to specify the PCR testing sensitivity and specificity. Let \(p_k\) be the probability that person \(i\) in group \(k\) tests positive. The analytic incidence \(p_k\) is a function of the test sensitivity \(\delta\), specificity \(\gamma\), and the true incidence \(\pi_k\) for individuals in group \(k\): $$p_k=(1-\gamma)(1-\pi_k )+\delta \pi_k.$$