simulate_outbreak: Simulate the process of flipping until failure for K clusters

Description Usage Arguments Details Value Examples

View source: R/simulate_outbreak.R

Description

Simulate the process of flipping until failure for K clusters

Usage

1
2
3
4
5
6
7
8
9
simulate_outbreak(
  K,
  inf_params,
  smear_pos_prob,
  max_size = 50,
  start_at_outsider = FALSE,
  keep_zero_clusters = FALSE,
  sample_covariates = NULL
)

Arguments

K

number of total clusters to simulate

inf_params

vector with beta_0 and beta_1

smear_pos_prob

probability of a smear positsive

max_size

maximum size a cluster can be

start_at_outsider

if TRUE, we start at an unobserved outsider instead of a single index case

keep_zero_clusters

Do I keep track of the the cluster consisting only of the unobserved root node? Default is FALSE.

sample_covariates

used for multi-variate people

Details

breadth not depth. Generate generation by generation as opposed to going up the branch til termination.

Value

data frame with the following columns

cluster_id

unique cluster ID

person_id

order of infection in the cluster

smear

- 1 (negative) / + 1 (positive)

gen

generation number (>=0)

inf_id

ID of the infector

n_inf

number of people infected by person

cluster_pos

number of positive smears in the cluster

cluster_size

number in cluster

censored

whether the cluster end was censored or not

Examples

1
2
3
4
5
6
7
8
inf_params <- c("beta_0" = -2, "beta_1" = 1)
smear_pos_prob <- .8
max_size <- 30
K <- 5
out <- simulate_outbreak(K = K,
                                inf_params = inf_params,
                                smear_pos_prob = smear_pos_prob,
                                max_size = max_size)

skgallagher/TBornotTB documentation built on April 21, 2020, 1:19 p.m.