Simulation of hospital admission, discharge and disease transmission. Swab test results and genetic information are generated.

1 2 | ```
simulate_data(n, D, LOS = 7, p = 0.05, z = 0.8, b = 0.005, gamma = 0.3, gamma_gl = 0.03,
genpar = 0.8, testdays = 3, model = 2)
``` |

`n` |
Number of patient admissions to be generated. |

`D` |
Number of days over which patient admissions may be randomly distributed. |

`LOS` |
Mean length of hospital stay; lengths are drawn from a Poisson distribution. |

`p` |
Probability of carriage on admission. |

`z` |
Swab test sensitivity. |

`b` |
Transmission rate. |

`gamma` |
Within host/group genetic diversity (geometric distribution parameter). |

`gamma_gl` |
Between host/group genetic diversity (geometric distribution parameter). |

`genpar` |
Group clustering parameter (model 1), or transmission chain parameter (model 2). See details below. |

`testdays` |
Number of days between each carriage test/isolate collection. |

`model` |
Genetic diversity model (1: Importation clustering model, 2: Transmission chain model). See details below. |

We implement two different models of genetic diversification. Model 1 is the importation clustering model, in which each infected host belongs to a group. The probability that a new importation belongs to a new group is `genpar`

. All hosts within the same transmission chain belong to the same group. Pairwise genetic distances are sampled from geometric distributions with parameters `gamma`

and `gamma_gl`

for within-group and between-group pairs respectively. Model 2 is the transmission chain model, in which genetic distances increase as hosts are further separated in the transmission tree. Genetic distances between hosts separated by `k`

transmission links are drawn independently from the geometric distribution with parameter `gamma`

x `genpar`

^`k`

. Genetic distances between hosts in independent transmission chains are drawn from a geometric distribution with parameter `gamma_gl`

.

Returns a list of simulated data;

`epi` |
Matrix of epidemiological data, consisting of columns patient ID, day of admission, day of discharge, time of colonization, source of infection, and infection group. |

`resmat` |
Matrix of test results. Each row represents the corresponding patient in |

`distmat` |
Pairwise genetic distance data. Each row and column corresponds to patient ID in |

`patientseqIDs` |
Vector of patient IDs corresponding to the rows and columns of |

`simulate_data_dates`

to pre-specify admission and discharge dates.

1 | ```
Tsim <- simulate_data(n=100,D=50,p=0.1,b=0.01)
``` |

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.