add_layer: Builds the next generation of nodes in a tree.

Description Usage Arguments Value

View source: R/sim-functions.R

Description

Given a set of parent nodes and their properties, this function simulates the next generation of infected nodes.

Usage

1
add_layer(parent_layer, tmax, tbar, p, lambda, kappa, q, mbar, kappaq)

Arguments

parent_layer

A data.frame. Contains the properties of each parent node. The columns are: id (the index of the parent node), id_parent (the index of the parent's parent node), t_infect (the clock time at which that parent was infected), t_comm (the duration of the parent's communicable period).

tmax

A non-negative scalar. Cutoff time for the simulated branches.

tbar

A non-negative scalar. Average duration of the communicable windows of the new nodes. Together with kappa, it determines a shape parameter tbar * kappa for the the Gamma distribution from which we draw a communicable period for each new node.

p

A scalar greater than 0 and smaller than 1. Parameter for the logarithmic distribution that governs the number of new infections per infectious event.

lambda

A non-negative scalar. Rate parameter for the Poisson distribution that governs the number of infectious events per parent node.

kappa

A non-negative scalar (including Inf). Rate parameter for the Gamma distribution from which we draw a communicable period duration for each new node. If kappa = Inf, then the draw is deterministic, with all communicable periods exactly equal to tbar.

q

A scalar between 0 and 1. The probability that a parent node has a communicable period of the second kind (a Gamma distribution with mean mbar, and shape kappaq).

mbar

A non-negative scalar. The mean duration of communicable windows of the second kind. This parameter has no role if q == 0.

kappaq

A non-negative scalar. The shape parameter for communicable windows of the second kind. This parameter has no role if q == 0.

Value

A data.frame with one row for each new node, and four columns: id (the node's unique ID), id_parent (the parent ID), t_infect (the time at which the node became infectious), and t_comm (the duration of the communicable window).


pspc-data-science/branchsim documentation built on Jan. 19, 2021, 10:10 a.m.