diff --git a/CODE_OF_CONDUCT.html b/CODE_OF_CONDUCT.html deleted file mode 100644 index 59609b0e..00000000 --- a/CODE_OF_CONDUCT.html +++ /dev/null @@ -1,95 +0,0 @@ - -Contributor Code of Conduct • bpmodels - - -
-
- - - -
-
- - -
- -

As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.

-

We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.

-

Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.

-

Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.

-

Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.

-

This Code of Conduct is adapted from the Contributor Covenant (http://contributor-covenant.org), version 1.0.0, available at http://contributor-covenant.org/version/1/0/0/

-
- -
- - - -
- - - -
- - - - - - - - diff --git a/articles/bpmodels.html b/articles/bpmodels.html index a93d0dc3..faf0efdc 100644 --- a/articles/bpmodels.html +++ b/articles/bpmodels.html @@ -154,8 +154,8 @@

Imperfect observationsll <- chain_ll(chain_sizes, "pois", "size", obs_prob = 0.3, lambda = 0.5, nsim_obs = 10) ll -#> [1] -36.98392 -27.21489 -25.67522 -23.90824 -25.85198 -25.53920 -25.62246 -#> [8] -32.96724 -30.82938 -19.56722 +#> [1] -25.15118 -24.07999 -19.83831 -25.65763 -24.55822 -26.39298 -22.18380 +#> [8] -19.13043 -24.77695 -25.94688

This returns 10 likelihood values (because nsim_obs = 10), which can be averaged to come up with an overall likelihood estimate.

To find out about the usage of the chain_ll() function, you can run ?chain_ll diff --git a/articles/introduction.html b/articles/introduction.html deleted file mode 100644 index b3be186f..00000000 --- a/articles/introduction.html +++ /dev/null @@ -1,187 +0,0 @@ - - - - - - - -Analysing chain statistics using branching process models • bpmodels - - - - - - - - - - - - -

-
- - - - -
-
- - - - -

bpmodels is an R package to simulate and analyse the size and length of branching processes with a given offspring distribution. These can be used, for example, to analyse the distribution of chain sizes or length of infectious disease outbreaks.

-
-

Quick start -

-

To load the package, use

-
Code -

At the heart of the package are the chains_ll() and chains_sim() functions.

-
-

Calculating log-likelihoods -

-

The chains_ll() function calculates the log-likelihood of a distribution of chain sizes or lengths given an offspring distribution and its associated parameters.

-

If we have observed a distribution of chains of sizes \(1, 1, 4, 7\), we can calculate the log-likelihood of this observed chain by assuming the offspring per generation is Poisson distributed with a mean number of 0.5.

-

To do this, we run

-
Code
-chain_sizes <- c(1, 1, 4, 7) # example of observed chain sizes
-chain_ll(chain_sizes, "pois", "size", lambda = 0.5)
-#> [1] -8.607196
-

The first argument of chain_ll() is the size (or length) distribution to analyse. The second argument (called offspring) specifies the offspring distribution. This is given as a function used to generate random offspring. It can be any probability distribution implemented in R, that is, one that has a corresponding function for generating random numbers beginning with the letter r. In the case of the example above, since random Poisson numbers are generated in R using a function called rpois(), the string to pass to the offspring argument is "pois".

-

The third argument (called stat) determines whether to analyse chain sizes ("size", the default if this argument is not specified) or lengths ("length"). Lastly, any named arguments not recognised by chain_ll() are interpreted as parameters of the corresponding probability distribution, here lambda = 0.5 as the mean of the Poisson distribution (see the R help page for the Poisson distribution for more information).

-

To find out about usage of the chains_ll() function, you can use the R help file

-
Code
-?chains_ll
-
-
-
-

Simulating branching processes -

-

To simulate a branching process, we use the chain_sim() function. This function follows the same syntax as chain_ll(), that is:

-
Code
-chain_sim(n = 5, "pois", "size", lambda = 0.5)
-#> [1] 2 1 1 1 5
-
-
-
-
-

Methodology -

-

If the probability distribution of chain sizes or lengths has an analytical solution, this will be used (size distribution: Poisson and negative binomial; length distribution: Poisson and geometric).

-

If an analytical solution does not exist, simulations are used to approximate this probability distributions (using a linear approximation to the cumulative distribution for unobserved sizes/lengths). The argument nsim_offspring is used to specify the number of simulations to be used for this approximation.

-

For example, to get offspring drawn from a binomial distribution with probability prob = 0.5, we run

-
Code
-chain_ll(chain_sizes, "binom", "size", size = 1, prob = 0.5, nsim_offspring = 100)
-#> [1] -8.477588
-
-
-
-

Imperfect observations -

-

If observations are imperfect, the chain_ll() function has an obs_prob argument that can be used to determine the likelihood. In that case, true chain sizes or lengths are simulated repeatedly (the number of times given by the nsim_obs argument), and the likelihood calculated for each of these simulations.

-

For example, if the probability of observing each case is \(30%\), we use

-
Code
-ll <- chain_ll(chain_sizes, "pois", "size", obs_prob = 0.3, lambda = 0.5, nsim_obs = 10)
-summary(ll)
-#>    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
-#>  -35.30  -25.68  -23.23  -24.19  -20.89  -18.91
-

This returns nsim_obs = 10 likelihood values which can be averaged to come up with an overall likelihood estimate.

-
- -
- - - -
- - - -
- -
-

-

Site built with pkgdown 2.0.7.

-
- -
-
- - - - - - - - diff --git a/articles/introduction_files/codefolding-lua-1.1/codefolding-lua.css b/articles/introduction_files/codefolding-lua-1.1/codefolding-lua.css deleted file mode 100644 index 183b19e1..00000000 --- a/articles/introduction_files/codefolding-lua-1.1/codefolding-lua.css +++ /dev/null @@ -1,9 +0,0 @@ -detaiks.chunk-details > summary.chunk-summary { - text-align: right; -} -details.chunk-details[open] > summary.chunk-summary::after { - content: "Hide"; -} -details.chunk-details[open] > summary.chunk-summary > span.chunk-summary-text { - display: none; -} diff --git a/bootstrap-toc.css b/bootstrap-toc.css deleted file mode 100644 index 5a859415..00000000 --- a/bootstrap-toc.css +++ /dev/null @@ -1,60 +0,0 @@ -/*! - * Bootstrap Table of Contents v0.4.1 (http://afeld.github.io/bootstrap-toc/) - * Copyright 2015 Aidan Feldman - * Licensed under MIT (https://github.com/afeld/bootstrap-toc/blob/gh-pages/LICENSE.md) */ - -/* modified from https://github.com/twbs/bootstrap/blob/94b4076dd2efba9af71f0b18d4ee4b163aa9e0dd/docs/assets/css/src/docs.css#L548-L601 */ - -/* All levels of nav */ -nav[data-toggle='toc'] .nav > li > a { - display: block; - padding: 4px 20px; - font-size: 13px; - font-weight: 500; - color: #767676; -} -nav[data-toggle='toc'] .nav > li > a:hover, -nav[data-toggle='toc'] .nav > li > a:focus { - padding-left: 19px; - color: #563d7c; - text-decoration: none; - background-color: transparent; - border-left: 1px solid #563d7c; -} -nav[data-toggle='toc'] .nav > .active > a, -nav[data-toggle='toc'] .nav > .active:hover > a, -nav[data-toggle='toc'] .nav > .active:focus > a { - padding-left: 18px; - font-weight: bold; - color: #563d7c; - background-color: transparent; - border-left: 2px solid #563d7c; -} - -/* Nav: second level (shown on .active) */ -nav[data-toggle='toc'] .nav .nav { - display: none; /* Hide by default, but at >768px, show it */ - padding-bottom: 10px; -} -nav[data-toggle='toc'] .nav .nav > li > a { - padding-top: 1px; - padding-bottom: 1px; - padding-left: 30px; - font-size: 12px; - font-weight: normal; -} -nav[data-toggle='toc'] .nav .nav > li > a:hover, -nav[data-toggle='toc'] .nav .nav > li > a:focus { - padding-left: 29px; -} -nav[data-toggle='toc'] .nav .nav > .active > a, -nav[data-toggle='toc'] .nav .nav > .active:hover > a, -nav[data-toggle='toc'] .nav .nav > .active:focus > a { - padding-left: 28px; - font-weight: 500; -} - -/* from https://github.com/twbs/bootstrap/blob/e38f066d8c203c3e032da0ff23cd2d6098ee2dd6/docs/assets/css/src/docs.css#L631-L634 */ -nav[data-toggle='toc'] .nav > .active > ul { - display: block; -} diff --git a/bootstrap-toc.js b/bootstrap-toc.js deleted file mode 100644 index 1cdd573b..00000000 --- a/bootstrap-toc.js +++ /dev/null @@ -1,159 +0,0 @@ -/*! - * Bootstrap Table of Contents v0.4.1 (http://afeld.github.io/bootstrap-toc/) - * Copyright 2015 Aidan Feldman - * Licensed under MIT (https://github.com/afeld/bootstrap-toc/blob/gh-pages/LICENSE.md) */ -(function() { - 'use strict'; - - window.Toc = { - helpers: { - // return all matching elements in the set, or their descendants - findOrFilter: function($el, selector) { - // http://danielnouri.org/notes/2011/03/14/a-jquery-find-that-also-finds-the-root-element/ - // http://stackoverflow.com/a/12731439/358804 - var $descendants = $el.find(selector); - return $el.filter(selector).add($descendants).filter(':not([data-toc-skip])'); - }, - - generateUniqueIdBase: function(el) { - var text = $(el).text(); - var anchor = text.trim().toLowerCase().replace(/[^A-Za-z0-9]+/g, '-'); - return anchor || el.tagName.toLowerCase(); - }, - - generateUniqueId: function(el) { - var anchorBase = this.generateUniqueIdBase(el); - for (var i = 0; ; i++) { - var anchor = anchorBase; - if (i > 0) { - // add suffix - anchor += '-' + i; - } - // check if ID already exists - if (!document.getElementById(anchor)) { - return anchor; - } - } - }, - - generateAnchor: function(el) { - if (el.id) { - return el.id; - } else { - var anchor = this.generateUniqueId(el); - el.id = anchor; - return anchor; - } - }, - - createNavList: function() { - return $(''); - }, - - createChildNavList: function($parent) { - var $childList = this.createNavList(); - $parent.append($childList); - return $childList; - }, - - generateNavEl: function(anchor, text) { - var $a = $(''); - $a.attr('href', '#' + anchor); - $a.text(text); - var $li = $('
  • '); - $li.append($a); - return $li; - }, - - generateNavItem: function(headingEl) { - var anchor = this.generateAnchor(headingEl); - var $heading = $(headingEl); - var text = $heading.data('toc-text') || $heading.text(); - return this.generateNavEl(anchor, text); - }, - - // Find the first heading level (`

    `, then `

    `, etc.) that has more than one element. Defaults to 1 (for `

    `). - getTopLevel: function($scope) { - for (var i = 1; i <= 6; i++) { - var $headings = this.findOrFilter($scope, 'h' + i); - if ($headings.length > 1) { - return i; - } - } - - return 1; - }, - - // returns the elements for the top level, and the next below it - getHeadings: function($scope, topLevel) { - var topSelector = 'h' + topLevel; - - var secondaryLevel = topLevel + 1; - var secondarySelector = 'h' + secondaryLevel; - - return this.findOrFilter($scope, topSelector + ',' + secondarySelector); - }, - - getNavLevel: function(el) { - return parseInt(el.tagName.charAt(1), 10); - }, - - populateNav: function($topContext, topLevel, $headings) { - var $context = $topContext; - var $prevNav; - - var helpers = this; - $headings.each(function(i, el) { - var $newNav = helpers.generateNavItem(el); - var navLevel = helpers.getNavLevel(el); - - // determine the proper $context - if (navLevel === topLevel) { - // use top level - $context = $topContext; - } else if ($prevNav && $context === $topContext) { - // create a new level of the tree and switch to it - $context = helpers.createChildNavList($prevNav); - } // else use the current $context - - $context.append($newNav); - - $prevNav = $newNav; - }); - }, - - parseOps: function(arg) { - var opts; - if (arg.jquery) { - opts = { - $nav: arg - }; - } else { - opts = arg; - } - opts.$scope = opts.$scope || $(document.body); - return opts; - } - }, - - // accepts a jQuery object, or an options object - init: function(opts) { - opts = this.helpers.parseOps(opts); - - // ensure that the data attribute is in place for styling - opts.$nav.attr('data-toggle', 'toc'); - - var $topContext = this.helpers.createChildNavList(opts.$nav); - var topLevel = this.helpers.getTopLevel(opts.$scope); - var $headings = this.helpers.getHeadings(opts.$scope, topLevel); - this.helpers.populateNav($topContext, topLevel, $headings); - } - }; - - $(function() { - $('nav[data-toggle="toc"]').each(function(i, el) { - var $nav = $(el); - Toc.init($nav); - }); - }); -})(); diff --git a/docsearch.css b/docsearch.css deleted file mode 100644 index e5f1fe1d..00000000 --- a/docsearch.css +++ /dev/null @@ -1,148 +0,0 @@ -/* Docsearch -------------------------------------------------------------- */ -/* - Source: https://github.com/algolia/docsearch/ - License: MIT -*/ - -.algolia-autocomplete { - display: block; - -webkit-box-flex: 1; - -ms-flex: 1; - flex: 1 -} - -.algolia-autocomplete .ds-dropdown-menu { - width: 100%; - min-width: none; - max-width: none; - padding: .75rem 0; - background-color: #fff; - background-clip: padding-box; - border: 1px solid rgba(0, 0, 0, .1); - box-shadow: 0 .5rem 1rem rgba(0, 0, 0, .175); -} - -@media (min-width:768px) { - .algolia-autocomplete .ds-dropdown-menu { - width: 175% - } -} - -.algolia-autocomplete .ds-dropdown-menu::before { - display: none -} - -.algolia-autocomplete .ds-dropdown-menu [class^=ds-dataset-] { - padding: 0; - background-color: rgb(255,255,255); - border: 0; - max-height: 80vh; -} - -.algolia-autocomplete .ds-dropdown-menu .ds-suggestions { - margin-top: 0 -} - -.algolia-autocomplete .algolia-docsearch-suggestion { - padding: 0; - overflow: visible -} - -.algolia-autocomplete .algolia-docsearch-suggestion--category-header { - padding: .125rem 1rem; - margin-top: 0; - font-size: 1.3em; - font-weight: 500; - color: #00008B; - border-bottom: 0 -} - -.algolia-autocomplete .algolia-docsearch-suggestion--wrapper { - float: none; - padding-top: 0 -} - -.algolia-autocomplete .algolia-docsearch-suggestion--subcategory-column { - float: none; - width: auto; - padding: 0; - text-align: left -} - -.algolia-autocomplete .algolia-docsearch-suggestion--content { - float: none; - width: auto; - padding: 0 -} - -.algolia-autocomplete .algolia-docsearch-suggestion--content::before { - display: none -} - -.algolia-autocomplete .ds-suggestion:not(:first-child) .algolia-docsearch-suggestion--category-header { - padding-top: .75rem; - margin-top: .75rem; - border-top: 1px solid rgba(0, 0, 0, .1) -} - -.algolia-autocomplete .ds-suggestion .algolia-docsearch-suggestion--subcategory-column { - display: block; - padding: .1rem 1rem; - margin-bottom: 0.1; - font-size: 1.0em; - font-weight: 400 - /* display: none */ -} - -.algolia-autocomplete .algolia-docsearch-suggestion--title { - display: block; - padding: .25rem 1rem; - margin-bottom: 0; - font-size: 0.9em; - font-weight: 400 -} - -.algolia-autocomplete .algolia-docsearch-suggestion--text { - padding: 0 1rem .5rem; - margin-top: -.25rem; - font-size: 0.8em; - font-weight: 400; - line-height: 1.25 -} - -.algolia-autocomplete .algolia-docsearch-footer { - width: 110px; - height: 20px; - z-index: 3; - margin-top: 10.66667px; - float: right; - font-size: 0; - line-height: 0; -} - -.algolia-autocomplete .algolia-docsearch-footer--logo { - background-image: url("data:image/svg+xml;utf8,"); - background-repeat: no-repeat; - background-position: 50%; - background-size: 100%; - overflow: hidden; - text-indent: -9000px; - width: 100%; - height: 100%; - display: block; - transform: translate(-8px); -} - -.algolia-autocomplete .algolia-docsearch-suggestion--highlight { - color: #FF8C00; - background: rgba(232, 189, 54, 0.1) -} - - -.algolia-autocomplete .algolia-docsearch-suggestion--text .algolia-docsearch-suggestion--highlight { - box-shadow: inset 0 -2px 0 0 rgba(105, 105, 105, .5) -} - -.algolia-autocomplete .ds-suggestion.ds-cursor .algolia-docsearch-suggestion--content { - background-color: rgba(192, 192, 192, .15) -} diff --git a/docsearch.js b/docsearch.js deleted file mode 100644 index b35504cd..00000000 --- a/docsearch.js +++ /dev/null @@ -1,85 +0,0 @@ -$(function() { - - // register a handler to move the focus to the search bar - // upon pressing shift + "/" (i.e. "?") - $(document).on('keydown', function(e) { - if (e.shiftKey && e.keyCode == 191) { - e.preventDefault(); - $("#search-input").focus(); - } - }); - - $(document).ready(function() { - // do keyword highlighting - /* modified from https://jsfiddle.net/julmot/bL6bb5oo/ */ - var mark = function() { - - var referrer = document.URL ; - var paramKey = "q" ; - - if (referrer.indexOf("?") !== -1) { - var qs = referrer.substr(referrer.indexOf('?') + 1); - var qs_noanchor = qs.split('#')[0]; - var qsa = qs_noanchor.split('&'); - var keyword = ""; - - for (var i = 0; i < qsa.length; i++) { - var currentParam = qsa[i].split('='); - - if (currentParam.length !== 2) { - continue; - } - - if (currentParam[0] == paramKey) { - keyword = decodeURIComponent(currentParam[1].replace(/\+/g, "%20")); - } - } - - if (keyword !== "") { - $(".contents").unmark({ - done: function() { - $(".contents").mark(keyword); - } - }); - } - } - }; - - mark(); - }); -}); - -/* Search term highlighting ------------------------------*/ - -function matchedWords(hit) { - var words = []; - - var hierarchy = hit._highlightResult.hierarchy; - // loop to fetch from lvl0, lvl1, etc. - for (var idx in hierarchy) { - words = words.concat(hierarchy[idx].matchedWords); - } - - var content = hit._highlightResult.content; - if (content) { - words = words.concat(content.matchedWords); - } - - // return unique words - var words_uniq = [...new Set(words)]; - return words_uniq; -} - -function updateHitURL(hit) { - - var words = matchedWords(hit); - var url = ""; - - if (hit.anchor) { - url = hit.url_without_anchor + '?q=' + escape(words.join(" ")) + '#' + hit.anchor; - } else { - url = hit.url + '?q=' + escape(words.join(" ")); - } - - return url; -} diff --git a/pkgdown.css b/pkgdown.css deleted file mode 100644 index 80ea5b83..00000000 --- a/pkgdown.css +++ /dev/null @@ -1,384 +0,0 @@ -/* Sticky footer */ - -/** - * Basic idea: https://philipwalton.github.io/solved-by-flexbox/demos/sticky-footer/ - * Details: https://github.com/philipwalton/solved-by-flexbox/blob/master/assets/css/components/site.css - * - * .Site -> body > .container - * .Site-content -> body > .container .row - * .footer -> footer - * - * Key idea seems to be to ensure that .container and __all its parents__ - * have height set to 100% - * - */ - -html, body { - height: 100%; -} - -body { - position: relative; -} - -body > .container { - display: flex; - height: 100%; - flex-direction: column; -} - -body > .container .row { - flex: 1 0 auto; -} - -footer { - margin-top: 45px; - padding: 35px 0 36px; - border-top: 1px solid #e5e5e5; - color: #666; - display: flex; - flex-shrink: 0; -} -footer p { - margin-bottom: 0; -} -footer div { - flex: 1; -} -footer .pkgdown { - text-align: right; -} -footer p { - margin-bottom: 0; -} - -img.icon { - float: right; -} - -/* Ensure in-page images don't run outside their container */ -.contents img { - max-width: 100%; - height: auto; -} - -/* Fix bug in bootstrap (only seen in firefox) */ -summary { - display: list-item; -} - -/* Typographic tweaking ---------------------------------*/ - -.contents .page-header { - margin-top: calc(-60px + 1em); -} - -dd { - margin-left: 3em; -} - -/* Section anchors ---------------------------------*/ - -a.anchor { - display: none; - margin-left: 5px; - width: 20px; - height: 20px; - - background-image: url(./link.svg); - background-repeat: no-repeat; - background-size: 20px 20px; - background-position: center center; -} - -h1:hover .anchor, -h2:hover .anchor, -h3:hover .anchor, -h4:hover .anchor, -h5:hover .anchor, -h6:hover .anchor { - display: inline-block; -} - -/* Fixes for fixed navbar --------------------------*/ - -.contents h1, .contents h2, .contents h3, .contents h4 { - padding-top: 60px; - margin-top: -40px; -} - -/* Navbar submenu --------------------------*/ - -.dropdown-submenu { - position: relative; -} - -.dropdown-submenu>.dropdown-menu { - top: 0; - left: 100%; - margin-top: -6px; - margin-left: -1px; - border-radius: 0 6px 6px 6px; -} - -.dropdown-submenu:hover>.dropdown-menu { - display: block; -} - -.dropdown-submenu>a:after { - display: block; - content: " "; - float: right; - width: 0; - height: 0; - border-color: transparent; - border-style: solid; - border-width: 5px 0 5px 5px; - border-left-color: #cccccc; - margin-top: 5px; - margin-right: -10px; -} - -.dropdown-submenu:hover>a:after { - border-left-color: #ffffff; -} - -.dropdown-submenu.pull-left { - float: none; -} - -.dropdown-submenu.pull-left>.dropdown-menu { - left: -100%; - margin-left: 10px; - border-radius: 6px 0 6px 6px; -} - -/* Sidebar --------------------------*/ - -#pkgdown-sidebar { - margin-top: 30px; - position: -webkit-sticky; - position: sticky; - top: 70px; -} - -#pkgdown-sidebar h2 { - font-size: 1.5em; - margin-top: 1em; -} - -#pkgdown-sidebar h2:first-child { - margin-top: 0; -} - -#pkgdown-sidebar .list-unstyled li { - margin-bottom: 0.5em; -} - -/* bootstrap-toc tweaks ------------------------------------------------------*/ - -/* All levels of nav */ - -nav[data-toggle='toc'] .nav > li > a { - padding: 4px 20px 4px 6px; - font-size: 1.5rem; - font-weight: 400; - color: inherit; -} - -nav[data-toggle='toc'] .nav > li > a:hover, -nav[data-toggle='toc'] .nav > li > a:focus { - padding-left: 5px; - color: inherit; - border-left: 1px solid #878787; -} - -nav[data-toggle='toc'] .nav > .active > a, -nav[data-toggle='toc'] .nav > .active:hover > a, -nav[data-toggle='toc'] .nav > .active:focus > a { - padding-left: 5px; - font-size: 1.5rem; - font-weight: 400; - color: inherit; - border-left: 2px solid #878787; -} - -/* Nav: second level (shown on .active) */ - -nav[data-toggle='toc'] .nav .nav { - display: none; /* Hide by default, but at >768px, show it */ - padding-bottom: 10px; -} - -nav[data-toggle='toc'] .nav .nav > li > a { - padding-left: 16px; - font-size: 1.35rem; -} - -nav[data-toggle='toc'] .nav .nav > li > a:hover, -nav[data-toggle='toc'] .nav .nav > li > a:focus { - padding-left: 15px; -} - -nav[data-toggle='toc'] .nav .nav > .active > a, -nav[data-toggle='toc'] .nav .nav > .active:hover > a, -nav[data-toggle='toc'] .nav .nav > .active:focus > a { - padding-left: 15px; - font-weight: 500; - font-size: 1.35rem; -} - -/* orcid ------------------------------------------------------------------- */ - -.orcid { - font-size: 16px; - color: #A6CE39; - /* margins are required by official ORCID trademark and display guidelines */ - margin-left:4px; - margin-right:4px; - vertical-align: middle; -} - -/* Reference index & topics ----------------------------------------------- */ - -.ref-index th {font-weight: normal;} - -.ref-index td {vertical-align: top; min-width: 100px} -.ref-index .icon {width: 40px;} -.ref-index .alias {width: 40%;} -.ref-index-icons .alias {width: calc(40% - 40px);} -.ref-index .title {width: 60%;} - -.ref-arguments th {text-align: right; padding-right: 10px;} -.ref-arguments th, .ref-arguments td {vertical-align: top; min-width: 100px} -.ref-arguments .name {width: 20%;} -.ref-arguments .desc {width: 80%;} - -/* Nice scrolling for wide elements --------------------------------------- */ - -table { - display: block; - overflow: auto; -} - -/* Syntax highlighting ---------------------------------------------------- */ - -pre, code, pre code { - background-color: #f8f8f8; - color: #333; -} -pre, pre code { - white-space: pre-wrap; - word-break: break-all; - overflow-wrap: break-word; -} - -pre { - border: 1px solid #eee; -} - -pre .img, pre .r-plt { - margin: 5px 0; -} - -pre .img img, pre .r-plt img { - background-color: #fff; -} - -code a, pre a { - color: #375f84; -} - -a.sourceLine:hover { - text-decoration: none; -} - -.fl {color: #1514b5;} -.fu {color: #000000;} /* function */ -.ch,.st {color: #036a07;} /* string */ -.kw {color: #264D66;} /* keyword */ -.co {color: #888888;} /* comment */ - -.error {font-weight: bolder;} -.warning {font-weight: bolder;} - -/* Clipboard --------------------------*/ - -.hasCopyButton { - position: relative; -} - -.btn-copy-ex { - position: absolute; - right: 0; - top: 0; - visibility: hidden; -} - -.hasCopyButton:hover button.btn-copy-ex { - visibility: visible; -} - -/* headroom.js ------------------------ */ - -.headroom { - will-change: transform; - transition: transform 200ms linear; -} -.headroom--pinned { - transform: translateY(0%); -} -.headroom--unpinned { - transform: translateY(-100%); -} - -/* mark.js ----------------------------*/ - -mark { - background-color: rgba(255, 255, 51, 0.5); - border-bottom: 2px solid rgba(255, 153, 51, 0.3); - padding: 1px; -} - -/* vertical spacing after htmlwidgets */ -.html-widget { - margin-bottom: 10px; -} - -/* fontawesome ------------------------ */ - -.fab { - font-family: "Font Awesome 5 Brands" !important; -} - -/* don't display links in code chunks when printing */ -/* source: https://stackoverflow.com/a/10781533 */ -@media print { - code a:link:after, code a:visited:after { - content: ""; - } -} - -/* Section anchors --------------------------------- - Added in pandoc 2.11: https://github.com/jgm/pandoc-templates/commit/9904bf71 -*/ - -div.csl-bib-body { } -div.csl-entry { - clear: both; -} -.hanging-indent div.csl-entry { - margin-left:2em; - text-indent:-2em; -} -div.csl-left-margin { - min-width:2em; - float:left; -} -div.csl-right-inline { - margin-left:2em; - padding-left:1em; -} -div.csl-indent { - margin-left: 2em; -} diff --git a/pkgdown.yml b/pkgdown.yml index 4a4f8228..0251c885 100644 --- a/pkgdown.yml +++ b/pkgdown.yml @@ -5,7 +5,7 @@ articles: bpmodels: bpmodels.html branching_process_literature: branching_process_literature.html projecting_incidence: projecting_incidence.html -last_built: 2023-07-20T14:38Z +last_built: 2023-07-20T15:24Z urls: reference: https://epiverse-trace.github.io/bpmodels/reference article: https://epiverse-trace.github.io/bpmodels/articles diff --git a/reference/find_function_name.html b/reference/find_function_name.html deleted file mode 100644 index 8b60b880..00000000 --- a/reference/find_function_name.html +++ /dev/null @@ -1,118 +0,0 @@ - -Finds the name of a function passed as an argument — find_function_name • bpmodels - Skip to contents - - -
    -
    -
    - -
    -

    This works even when a function is passed multiple times (e.g., when used -inside an optim call). -See https://stackoverflow.com/a/46740314/10886760

    -
    - -
    -

    Usage

    -
    find_function_name(fun)
    -
    - -
    -

    Arguments

    -
    fun
    -

    function of which the name is to be determined

    - -
    -
    -

    Value

    - - -

    function name

    -
    -
    -

    Author

    -

    Sebastian Funk

    -
    - -
    - - -
    - - - -
    - - - - - - - diff --git a/search.json b/search.json index 250f3b66..90453bea 100644 --- a/search.json +++ b/search.json @@ -1 +1 @@ -[{"path":"https://epiverse-trace.github.io/bpmodels/CONTRIBUTING.html","id":null,"dir":"","previous_headings":"","what":"Contributing to bpmodels","title":"Contributing to bpmodels","text":"outlines propose change bpmodels.","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/CONTRIBUTING.html","id":"making-changes","dir":"","previous_headings":"","what":"Making changes","title":"Contributing to bpmodels","text":"want make change, ’s good idea first file issue make sure someone team agrees ’s needed. ’ve found bug, please file issue illustrates bug minimal reprex (also help write unit test, needed). See bug report template. feature request see feature request.","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/CONTRIBUTING.html","id":"pull-request-process","dir":"","previous_headings":"Making changes","what":"Pull request process","title":"Contributing to bpmodels","text":"See pull request template Fork package clone onto computer. haven’t done , recommend using usethis::create_from_github(\"epiverse-trace/bpmodels\", fork = TRUE). Install development dependencies devtools::install_dev_deps(), make sure package passes R CMD check running devtools::check(). R CMD check doesn’t pass cleanly, ’s good idea ask help continuing. Create Git branch pull request (PR). recommend using usethis::pr_init(\"brief-description--change\"). Make changes, commit git, create PR running usethis::pr_push(), following prompts browser. title PR briefly describe change. body PR contain Fixes #issue-number. user-facing changes, add bullet top NEWS.md (.e. just first header). Follow style described https://style.tidyverse.org/news.html.","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/CONTRIBUTING.html","id":"code-style","dir":"","previous_headings":"Making changes","what":"Code style","title":"Contributing to bpmodels","text":"New code follow tidyverse style guide. can use styler package apply styles, please don’t restyle code nothing PR. use roxygen2, Markdown syntax, documentation. use testthat unit tests. Contributions test cases included easier accept.","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/CONTRIBUTING.html","id":"code-of-conduct","dir":"","previous_headings":"","what":"Code of Conduct","title":"Contributing to bpmodels","text":"Please note bpmodels released Contributor Code Conduct. contributing project agree abide terms.","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/LICENSE.html","id":null,"dir":"","previous_headings":"","what":"MIT License","title":"MIT License","text":"Copyright (c) 2023 bpmodels authors Permission hereby granted, free charge, person obtaining copy software associated documentation files (“Software”), deal Software without restriction, including without limitation rights use, copy, modify, merge, publish, distribute, sublicense, /sell copies Software, permit persons Software furnished , subject following conditions: copyright notice permission notice shall included copies substantial portions Software. SOFTWARE PROVIDED “”, WITHOUT WARRANTY KIND, EXPRESS IMPLIED, INCLUDING LIMITED WARRANTIES MERCHANTABILITY, FITNESS PARTICULAR PURPOSE NONINFRINGEMENT. EVENT SHALL AUTHORS COPYRIGHT HOLDERS LIABLE CLAIM, DAMAGES LIABILITY, WHETHER ACTION CONTRACT, TORT OTHERWISE, ARISING , CONNECTION SOFTWARE USE DEALINGS SOFTWARE.","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/articles/bpmodels.html","id":"quick-start","dir":"Articles","previous_headings":"","what":"Quick start","title":"Analysing infectious disease transmission chains with bpmodels","text":"","code":"library(\"bpmodels\")"},{"path":"https://epiverse-trace.github.io/bpmodels/articles/bpmodels.html","id":"chain_ll-calculate-log-likelihoods","dir":"Articles","previous_headings":"Quick start","what":"chain_ll(): calculate log-likelihoods","title":"Analysing infectious disease transmission chains with bpmodels","text":"chain_ll() function calculates log-likelihood distribution chain sizes lengths given offspring distribution associated parameters. example, observed distribution chains sizes \\(1, 1, 4, 7\\), can calculate log-likelihood observed chain assuming offspring per generation Poisson distributed mean number (can interpreted reproduction number, \\(R_0\\)) \\(0.5\\). , run first argument chain_ll() chain size (length, number generations chain lasted) distribution analyse. second argument, offspring, specifies offspring distribution. specified string name function used generate random offspring. can probability distribution implemented R, , one corresponding function generating random numbers beginning letter r. case example , since random Poisson numbers generated R using function called rpois(), string pass offspring argument \"pois\". third argument, stat, determines whether analyse chain sizes (\"size\", default argument specified) lengths (\"length\"). Lastly, named arguments recognised chain_ll() interpreted parameters corresponding probability distribution, lambda = 0.5 mean Poisson distribution (see R help page Poisson distribution information).","code":"chain_sizes <- c(1, 1, 4, 7) # example of observed chain sizes chain_ll(x = chain_sizes, offspring = \"pois\", stat = \"size\", lambda = 0.5) #> [1] -8.607196"},{"path":"https://epiverse-trace.github.io/bpmodels/articles/bpmodels.html","id":"imperfect-observations","dir":"Articles","previous_headings":"Quick start > chain_ll(): calculate log-likelihoods","what":"Imperfect observations","title":"Analysing infectious disease transmission chains with bpmodels","text":"default, chain_ll() assumes perfect observation, obs_prob = 1 (See ?chain_ll), meaning transmission events observed recorded data. observations imperfect, chain_ll() provides argument, obs_prob, specifying probability observation. probability used determine likelihood observing specified chain sizes lengths. case imperfect observation, true chain sizes lengths simulated repeatedly (number times given nsim_obs argument), likelihood calculated simulations. example, probability observing case obs_prob = 0.30, use returns 10 likelihood values (nsim_obs = 10), can averaged come overall likelihood estimate. find usage chain_ll() function, can run ?chain_ll access R help file.","code":"chain_sizes <- c(1, 1, 4, 7) # example of observed chain sizes ll <- chain_ll(chain_sizes, \"pois\", \"size\", obs_prob = 0.3, lambda = 0.5, nsim_obs = 10) ll #> [1] -36.98392 -27.21489 -25.67522 -23.90824 -25.85198 -25.53920 -25.62246 #> [8] -32.96724 -30.82938 -19.56722"},{"path":"https://epiverse-trace.github.io/bpmodels/articles/bpmodels.html","id":"how-chain_ll-works","dir":"Articles","previous_headings":"Quick start > chain_ll(): calculate log-likelihoods","what":"How chain_ll() works","title":"Analysing infectious disease transmission chains with bpmodels","text":"probability distribution chain sizes lengths analytical solution, used. chain_ll() currently supports Poisson negative binomial size distribution Poisson geometric length distribution. analytical solution exist, simulations used approximate probability distributions (using linear approximation cumulative distribution unobserved sizes/lengths). case, extra argument nsim_offspring must passed chain_ll() specify number simulations used approximation. example, get offspring drawn binomial distribution probability prob = 0.5, run","code":"set.seed(12) chain_sizes <- c(1, 1, 4, 7) # example of observed chain sizes chain_ll(chain_sizes, \"binom\", \"size\", size = 1, prob = 0.5, nsim_offspring = 100) #> [1] -8.496803"},{"path":"https://epiverse-trace.github.io/bpmodels/articles/bpmodels.html","id":"chain_sim-simulate-transmission-chains-with-branching-processes","dir":"Articles","previous_headings":"Quick start","what":"chain_sim(): simulate transmission chains with branching processes","title":"Analysing infectious disease transmission chains with bpmodels","text":"simulate branching process, use chain_sim() function. function follows syntax chain_ll(). Note chain_sim() stochastic, seed needs set ensure results can reproduced. , simulating \\(5\\) chains, assuming offspring generated using Poisson distribution mean, lambda = 0.5. default, chain_sim() returns vector chain sizes/lengths. instead want return tree infectees infectors, need specify function serial interval set tree = TRUE (see next section).","code":"set.seed(12) chain_sim(n = 5, offspring = \"pois\", stat = \"size\", lambda = 0.5) #> [1] 1 2 4 1 1"},{"path":"https://epiverse-trace.github.io/bpmodels/articles/bpmodels.html","id":"simulating-trees","dir":"Articles","previous_headings":"Quick start > chain_sim(): simulate transmission chains with branching processes","what":"Simulating trees","title":"Analysing infectious disease transmission chains with bpmodels","text":"simulate tree transmission chains, specify serial interval generation function (serial_interval()) set tree = TRUE follows:","code":"set.seed(12) serial_interval <- function(n) { rlnorm(n, meanlog = 0.58, sdlog = 1.58) } chains_df <- chain_sim( n = 5, offspring = \"pois\", lambda = 0.5, stat = \"length\", infinite = 100, serial = serial_interval, tree = TRUE ) head(chains_df) #> n id ancestor generation time #> 1 1 1 NA 1 0.00000000 #> 2 2 1 NA 1 0.00000000 #> 3 3 1 NA 1 0.00000000 #> 4 4 1 NA 1 0.00000000 #> 5 5 1 NA 1 0.00000000 #> 6 2 2 1 2 0.09968906"},{"path":[]},{"path":[]},{"path":"https://epiverse-trace.github.io/bpmodels/articles/projecting_incidence.html","id":"overview","dir":"Articles","previous_headings":"","what":"Overview","title":"Projecting infectious disease incidence: a COVID-19 example","text":"Branching processes can used project infectious disease trends time provided can characterize distribution times successive cases (serial interval), distribution secondary cases produced single individual (offspring distribution). simulations can achieved bpmodels chain_sim() function Pearson et al. (2020), Abbott et al. (2020) illustrate application COVID-19. purpose vignette use early data COVID-19 South Africa (Marivate Combrink 2020) illustrate bpmodels can used forecast outbreak. Let’s load required packages","code":"library(\"bpmodels\") library(\"dplyr\") library(\"ggplot2\") library(\"lubridate\")"},{"path":"https://epiverse-trace.github.io/bpmodels/articles/projecting_incidence.html","id":"data","dir":"Articles","previous_headings":"","what":"Data","title":"Projecting infectious disease incidence: a COVID-19 example","text":"Included bpmodels cleaned time series first 15 days COVID-19 outbreak South Africa. can loaded memory follows: Let us examine first 6 entries dataset.","code":"data(\"covid19_sa\", package = \"bpmodels\") head(covid19_sa) #> # A tibble: 6 × 2 #> date cases #> #> 1 2020-03-05 1 #> 2 2020-03-07 1 #> 3 2020-03-08 1 #> 4 2020-03-09 4 #> 5 2020-03-11 6 #> 6 2020-03-12 3"},{"path":[]},{"path":"https://epiverse-trace.github.io/bpmodels/articles/projecting_incidence.html","id":"onset-times","dir":"Articles","previous_headings":"Setting up the inputs","what":"Onset times","title":"Projecting infectious disease incidence: a COVID-19 example","text":"chain_sim() requires vector onset times, t0, chain/individual/simulation. covid19_sa dataset aggregated, disaggregate linelist row representing case onset time. achieve , first use date index case reference find difference date reference. Using vector start times time series, create linelist disaggregating time series case corresponding start time.","code":"days_since_index <- as.integer(covid19_sa$date - min(covid19_sa$date)) days_since_index #> [1] 0 2 3 4 6 7 8 9 10 11 12 13 14 15 start_times <- unlist(mapply( function(x, y) rep(x, times = ifelse(y == 0, 1, y)), days_since_index, covid19_sa$cases )) start_times #> [1] 0 2 3 4 4 4 4 6 6 6 6 6 6 7 7 7 8 8 8 8 8 8 8 8 9 #> [26] 9 9 9 9 9 9 9 9 9 9 9 9 9 10 10 10 10 10 10 10 10 10 10 10 10 #> [51] 10 11 11 11 11 11 11 11 11 11 11 11 12 12 12 12 12 12 12 12 12 12 12 12 12 #> [76] 12 12 12 12 12 12 12 12 12 12 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 #> [101] 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 14 14 14 14 14 14 14 14 14 #> [126] 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 #> [151] 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 #> [176] 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 #> [201] 15 15"},{"path":"https://epiverse-trace.github.io/bpmodels/articles/projecting_incidence.html","id":"serial-interval","dir":"Articles","previous_headings":"Setting up the inputs","what":"Serial interval","title":"Projecting infectious disease incidence: a COVID-19 example","text":"log-normal distribution commonly used epidemiology characterise quantities serial interval large variance can positive-valued (Nishiura 2007; Limpert, Stahel, Abbt 2001). example, assume based COVID-19 literature serial interval, S, log-normal distributed parameters, \\(\\mu = 4.7\\) \\(\\sigma = 2.9\\) (Pearson et al. 2020). Note distribution described way, means \\(\\mu\\) \\(\\sigma\\) expected value standard deviation natural logarithm serial interval. Hence, order sample “back-transformed” measured serial interval expectation/mean, \\(E[S]\\) standard deviation, \\(SD [S]\\), can use following parametrisation: \\[\\begin{align} E[S] &= \\ln \\left( \\dfrac{\\mu^2}{(\\sqrt{\\mu^2 + \\sigma^2}} \\right) \\\\ SD [S] &= \\sqrt {\\ln \\left(1 + \\dfrac{\\sigma^2}{\\mu^2} \\right)} \\end{align}\\] See “log-normal_distribution” Wikipedia detailed explanation parametrisation. now set serial interval function appropriate inputs. adopt R’s random lognormal distribution generator (rlnorm()) takes meanlog sdlog arguments, define parametrisation log_mean() log_sd() respectively wrap serial_interval() function. Moreover, serial_interval() takes one argument sample_size required bpmodels (See ?bpmodels::chain_sim), passed rlnorm() first argument determine number observations sample (See ?rlnorm).","code":"mu <- 4.7 sgma <- 2.9 log_mean <- log((mu^2) / (sqrt(sgma^2 + mu^2))) # log mean log_sd <- sqrt(log(1 + (sgma / mu)^2)) # log sd #' serial interval function serial_interval <- function(sample_size) { si <- rlnorm(sample_size, meanlog = log_mean, sdlog = log_sd) return(si) }"},{"path":"https://epiverse-trace.github.io/bpmodels/articles/projecting_incidence.html","id":"offspring-distribution","dir":"Articles","previous_headings":"Setting up the inputs","what":"Offspring distribution","title":"Projecting infectious disease incidence: a COVID-19 example","text":"negative binomial distribution commonly used epidemiology account individual variation transmissibility, also known superspreading (Lloyd-Smith et al. 2005). example, assume offspring distribution characterised negative binomial \\(R = 2.5\\) (Abbott et al. 2020) \\(k = 0.58\\) (Wang et al. 2020). parameterization, \\(R\\) represents \\(R_0\\), defined average number cases produced single individual entirely susceptible population. parameter \\(k\\) represents superspreading, , degree heterogeneity transmission single individuals.","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/articles/projecting_incidence.html","id":"simulation-controls","dir":"Articles","previous_headings":"Setting up the inputs","what":"Simulation controls","title":"Projecting infectious disease incidence: a COVID-19 example","text":"chain_sim() also requires end time simulations. example, simulate outbreaks end 14 days last date observations covid19_sa. chain_sim() stochastic, meaning results different every time run set parameters, run simulations many times summarise results. , therefore, run simulation \\(100\\) times. Lastly, chain_sim() requires maximum size chain. value, simulation cut . value specified, assumes value infinity. , assume maximum chain size \\(1000\\). call chain_threhold.","code":"#' Date to end simulation (14 day projection in this case) projection_window <- 14 # 14 days/ 2-week ahead projection projection_end_day <- max(days_since_index) + projection_window projection_end_day #> [1] 29 #' Number of simulations sim_rep <- 100 #' Maximum chain size allowed chain_threshold <- 1000"},{"path":"https://epiverse-trace.github.io/bpmodels/articles/projecting_incidence.html","id":"modelling-assumptions","dir":"Articles","previous_headings":"","what":"Modelling assumptions","title":"Projecting infectious disease incidence: a COVID-19 example","text":"chain_sim() makes following simplifying assumptions: cases observed reporting delay Reporting rate constant course epidemic interventions implemented Population homogeneous well-mixed summarise whole set far, going simulate chain 100 times, projecting COVID-19 cases 14 days first \\(15\\) days, assuming outbreak size exceeds 1000 cases.","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/articles/projecting_incidence.html","id":"running-the-simulations","dir":"Articles","previous_headings":"","what":"Running the simulations","title":"Projecting infectious disease incidence: a COVID-19 example","text":"use function lapply() run simulations bind rows dplyr::bind_rows(). Let us view first rows simulation results.","code":"set.seed(1234) sim_chain_sizes <- lapply( seq_len(sim_rep), function(sim) { chain_sim( n = length(start_times), offspring = \"nbinom\", mu = 2.5, size = 0.58, stat = \"size\", infinite = chain_threshold, serial = serial_interval, t0 = start_times, tf = projection_end_day, tree = TRUE ) %>% mutate(sim = sim) } ) sim_output <- bind_rows(sim_chain_sizes) head(sim_output) #> n id ancestor generation time sim #> 1 1 1 NA 1 0 1 #> 2 2 1 NA 1 2 1 #> 3 3 1 NA 1 3 1 #> 4 4 1 NA 1 4 1 #> 5 5 1 NA 1 4 1 #> 6 6 1 NA 1 4 1"},{"path":"https://epiverse-trace.github.io/bpmodels/articles/projecting_incidence.html","id":"post-processing","dir":"Articles","previous_headings":"","what":"Post-processing","title":"Projecting infectious disease incidence: a COVID-19 example","text":"Now, summarise simulation results. want plot individual simulated daily time series show median cases per day aggregated simulations. First, create daily time series per simulation aggregating number cases per day simulation. Next, add date column results simulation set. use date first case observed data reference start date. Now aggregate simulations day evaluate median daily cases across simulations. done individual simulations, add date column manner.","code":"# Daily number of cases for each simulation incidence_ts <- sim_output %>% mutate(day = ceiling(time)) %>% group_by(sim, day) %>% summarise(cases = n()) %>% ungroup() head(incidence_ts) #> # A tibble: 6 × 3 #> sim day cases #> #> 1 1 0 1 #> 2 1 2 1 #> 3 1 3 1 #> 4 1 4 4 #> 5 1 6 6 #> 6 1 7 4 # Get start date from the observed data index_date <- min(covid19_sa$date) index_date #> [1] \"2020-03-05\" # Add a dates column to each simulation result incidence_ts_by_date <- incidence_ts %>% group_by(sim) %>% mutate(date = index_date + days(seq(0, n() - 1))) %>% ungroup() head(incidence_ts_by_date) #> # A tibble: 6 × 4 #> sim day cases date #> #> 1 1 0 1 2020-03-05 #> 2 1 2 1 2020-03-06 #> 3 1 3 1 2020-03-07 #> 4 1 4 4 2020-03-08 #> 5 1 6 6 2020-03-09 #> 6 1 7 4 2020-03-10 # Median daily number of cases aggregated across all simulations median_daily_cases <- incidence_ts %>% group_by(day) %>% summarise(median_cases = median(cases)) %>% ungroup() %>% arrange(day) head(median_daily_cases) #> # A tibble: 6 × 2 #> day median_cases #> #> 1 0 1 #> 2 1 1 #> 3 2 1 #> 4 3 1 #> 5 4 4 #> 6 5 1 # Add dates median_daily_cases <- median_daily_cases %>% mutate(date = index_date + days(seq(0, projection_end_day))) %>% ungroup() head(median_daily_cases) #> # A tibble: 6 × 3 #> day median_cases date #> #> 1 0 1 2020-03-05 #> 2 1 1 2020-03-06 #> 3 2 1 2020-03-07 #> 4 3 1 2020-03-08 #> 5 4 4 2020-03-09 #> 6 5 1 2020-03-10"},{"path":"https://epiverse-trace.github.io/bpmodels/articles/projecting_incidence.html","id":"visualization","dir":"Articles","previous_headings":"","what":"Visualization","title":"Projecting infectious disease incidence: a COVID-19 example","text":"now plot individual simulation results alongside median aggregated results. Figure 1: COVID-19 incidence projected two week window. gray lines represent individual simulations, red connected dots represent median daily cases across simulations, black triangles represent observed data.","code":"ggplot(data = incidence_ts_by_date) + geom_line( aes( x = date, y = cases, group = sim ), color = \"grey\", linewidth = 0.2, alpha = 0.25 ) + geom_line( data = median_daily_cases, aes( x = date, y = median_cases ), color = \"tomato3\", linewidth = 1.8 ) + geom_point( data = covid19_sa, aes( x = date, y = cases ), color = \"black\", size = 1.75, shape = 21 ) + geom_line( data = covid19_sa, aes( x = date, y = cases ), color = \"black\", size = 1.75, shape = 21 ) + scale_x_continuous( breaks = seq( min(incidence_ts_by_date$date), max(incidence_ts_by_date$date), 10 ), labels = seq( min(incidence_ts_by_date$date), max(incidence_ts_by_date$date), 10 ) ) + scale_y_continuous( breaks = seq( 0, max(incidence_ts_by_date$cases) + 200, 250 ), labels = seq( 0, max(incidence_ts_by_date$cases) + 200, 250 ) ) + labs(x = \"Date\", y = \"Daily cases (median)\")"},{"path":[]},{"path":"https://epiverse-trace.github.io/bpmodels/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"James M. Azam. Author, maintainer. Zhian N. Kamvar. Contributor. Flavio Finger. Author. Sebastian Funk. Author, copyright holder.","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Sebastian Funk, Flavio Finger, James M. Azam (2023). bpmodels: Analysing transmission chain statistics using branching process models, website: https://github.com/epiverse-trace/bpmodels/","code":"@Manual{, title = {bpmodels: Analysing transmission chain statistics using branching process models}, author = {{Sebastian Funk} and {Flavio Finger} and {James M. Azam}}, year = {2023}, url = {https://github.com/epiverse-trace/bpmodels/}, }"},{"path":"https://epiverse-trace.github.io/bpmodels/index.html","id":"bpmodels-methods-for-simulating-and-analysing-the-size-and-length-of-transmission-chains-from-branching-process-models","dir":"","previous_headings":"","what":"Simulating and Analysing Transmission Chain Statistics using Branching Process\n Models","title":"Simulating and Analysing Transmission Chain Statistics using Branching Process\n Models","text":"bpmodels R package simulate analyse size length branching processes given offspring distribution. models often used infectious disease epidemiology, chains represent chains transmission, offspring distribution represents distribution secondary infections caused infected individual.","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/index.html","id":"installation","dir":"","previous_headings":"","what":"Installation","title":"Simulating and Analysing Transmission Chain Statistics using Branching Process\n Models","text":"package can installed CRAN using latest development version bpmodels package can installed via load package, use","code":"install.packages(\"bpmodels\") # check whether {pak} is installed if (!require(\"pak\")) install.packages(\"pak\") pak::pkg_install(\"epiverse-trace/bpmodels\") library(\"bpmodels\")"},{"path":"https://epiverse-trace.github.io/bpmodels/index.html","id":"core-functionality","dir":"","previous_headings":"","what":"Core functionality","title":"Simulating and Analysing Transmission Chain Statistics using Branching Process\n Models","text":"bpmodels provides three main functions: chain_ll(): calculates likelihoods observing vector chains given sizes lengths. quick example estimating loglikelihood observed chain: chain_sim(): simulates transmission chains chains stop producing offspring. quick example simulate chain sizes 5 chains poisson offspring mean, lambda = 0.5: chain_sim_susc(): simulates transmission chains specified population size pre-existing immunity susceptible pool runs . quick example simulate chains poisson offspring mean, lambda = 0.5, serial interval 3: See “Get started vignette” detailed illustration function.","code":"# example of observed chain sizes chain_sizes <- c(1, 2, 3, 4) # estimate loglikelihood of the observed chain sizes chain_ll_eg <- chain_ll(x = chain_sizes, offspring = \"pois\", stat = \"size\", lambda = 0.5) chain_ll_eg #> [1] -7.772589 set.seed(123) chain_sim_eg <- chain_sim(n = 5, offspring = \"pois\", stat = \"size\", lambda = 0.5, tree = TRUE) head(chain_sim_eg) #> n id ancestor generation #> 1 1 1 NA 1 #> 2 2 1 NA 1 #> 3 3 1 NA 1 #> 4 4 1 NA 1 #> 5 5 1 NA 1 #> 6 2 2 1 2 set.seed(1234) chain_sim_susc_eg <- chain_sim_susc(pop = 1000, offspring = \"pois\", mn_offspring = 0.5, serial = function(x) {3} ) head(chain_sim_susc_eg) #> id ancestor generation time #> 1 1 NA 1 0"},{"path":"https://epiverse-trace.github.io/bpmodels/index.html","id":"package-vignettes","dir":"","previous_headings":"","what":"Package vignettes","title":"Simulating and Analysing Transmission Chain Statistics using Branching Process\n Models","text":"Specific use cases bpmodels can found online documentation package vignettes, “Articles”.","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/index.html","id":"reporting-bugs","dir":"","previous_headings":"","what":"Reporting bugs","title":"Simulating and Analysing Transmission Chain Statistics using Branching Process\n Models","text":"report bug please open issue.","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/index.html","id":"contribute","dir":"","previous_headings":"","what":"Contribute","title":"Simulating and Analysing Transmission Chain Statistics using Branching Process\n Models","text":"welcome contributions enhance package’s functionalities. wish , please follow package contributing guide.","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/index.html","id":"code-of-conduct","dir":"","previous_headings":"","what":"Code of conduct","title":"Simulating and Analysing Transmission Chain Statistics using Branching Process\n Models","text":"Please note bpmodels project released Contributor Code Conduct. contributing project, agree abide terms.","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/index.html","id":"citing-this-package","dir":"","previous_headings":"","what":"Citing this package","title":"Simulating and Analysing Transmission Chain Statistics using Branching Process\n Models","text":"","code":"citation(\"bpmodels\") #> To cite package bpmodels in publications use: #> #> Sebastian Funk, Flavio Finger, and James M. Azam (2023). bpmodels: #> Analysing transmission chain statistics using branching process #> models, website: https://github.com/epiverse-trace/bpmodels/ #> #> A BibTeX entry for LaTeX users is #> #> @Manual{, #> title = {bpmodels: Analysing transmission chain statistics using branching process models}, #> author = {{Sebastian Funk} and {Flavio Finger} and {James M. Azam}}, #> year = {2023}, #> url = {https://github.com/epiverse-trace/bpmodels/}, #> }"},{"path":"https://epiverse-trace.github.io/bpmodels/reference/bpmodels-package.html","id":null,"dir":"Reference","previous_headings":"","what":"bpmodels: Simulating and Analysing Transmission Chain Statistics using Branching Process Models — bpmodels-package","title":"bpmodels: Simulating and Analysing Transmission Chain Statistics using Branching Process Models — bpmodels-package","text":"Provides methods simulate analyse size length branching processes arbitrary offspring distribution. can used, example, analyse distribution chain sizes length infectious disease outbreaks, discussed Farrington et al. (2003) doi:10.1093/biostatistics/4.2.279 .","code":""},{"path":[]},{"path":"https://epiverse-trace.github.io/bpmodels/reference/bpmodels-package.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"bpmodels: Simulating and Analysing Transmission Chain Statistics using Branching Process Models — bpmodels-package","text":"Maintainer: James M. Azam james.azam@lshtm.ac.uk (ORCID) Authors: Flavio Finger flavio.finger@epicentre.msf.org (ORCID) Sebastian Funk sebastian.funk@lshtm.ac.uk (ORCID) [copyright holder] contributors: Zhian N. Kamvar zkamvar@gmail.com (ORCID) [contributor]","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/chain_ll.html","id":null,"dir":"Reference","previous_headings":"","what":"Calculate the log-likelihood for the outcome of a branching process — chain_ll","title":"Calculate the log-likelihood for the outcome of a branching process — chain_ll","text":"Calculate log-likelihood outcome branching process","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/chain_ll.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Calculate the log-likelihood for the outcome of a branching process — chain_ll","text":"","code":"chain_ll( x, offspring, stat = c(\"size\", \"length\"), obs_prob = 1, infinite = Inf, exclude = NULL, individual = FALSE, nsim_obs, ... )"},{"path":"https://epiverse-trace.github.io/bpmodels/reference/chain_ll.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Calculate the log-likelihood for the outcome of a branching process — chain_ll","text":"x vector sizes lengths transmission chains offspring Offspring distribution: character string corresponding R distribution function (e.g., \"pois\" Poisson, rpois R function generate Poisson random numbers) stat statistic given x (\"size\" \"length\" chains) obs_prob observation probability (assumed constant) infinite chains size/length treated infinite exclude sizes/lengths exclude log-likelihood calculation individual TRUE, vector individual log-likelihood contributions returned rather sum nsim_obs number simulations log-likelihood approximated imperfect observations ... parameters offspring distribution","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/chain_ll.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Calculate the log-likelihood for the outcome of a branching process — chain_ll","text":"log-likelihood, vector log-likelihoods (obs_prob < 1), list individual log-likelihood contributions (individual=TRUE)","code":""},{"path":[]},{"path":"https://epiverse-trace.github.io/bpmodels/reference/chain_ll.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Calculate the log-likelihood for the outcome of a branching process — chain_ll","text":"Sebastian Funk","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/chain_ll.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Calculate the log-likelihood for the outcome of a branching process — chain_ll","text":"","code":"chain_sizes <- c(1, 1, 4, 7) # example of observed chain sizes chain_ll(chain_sizes, \"pois\", \"size\", lambda = 0.5) #> [1] -8.607196"},{"path":"https://epiverse-trace.github.io/bpmodels/reference/chain_sim.html","id":null,"dir":"Reference","previous_headings":"","what":"Simulate transmission chains using a branching process — chain_sim","title":"Simulate transmission chains using a branching process — chain_sim","text":"chain_sim() stochastic simulator generating transmission chain data key inputs offspring distribution serial interval distribution.","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/chain_sim.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Simulate transmission chains using a branching process — chain_sim","text":"","code":"chain_sim( n, offspring, stat = c(\"size\", \"length\"), infinite = Inf, tree = FALSE, serial, t0 = 0, tf = Inf, ... )"},{"path":"https://epiverse-trace.github.io/bpmodels/reference/chain_sim.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Simulate transmission chains using a branching process — chain_sim","text":"n Number simulations run. offspring Offspring distribution: character string corresponding R distribution function (e.g., \"pois\" Poisson, rpois R function generate Poisson random numbers) stat String; Statistic calculate. Can one : \"size\": total number offspring. \"length\": total number ancestors. infinite size length simulation results set Inf. Defaults Inf, resulting results ever set Inf tree Logical. transmission tree returned? Defaults FALSE. serial serial interval generator function; name user-defined named anonymous function one argument n, representing number serial intervals generate. t0 Start time (serial interval given); either single value vector length n (number simulations) initial times. Defaults 0. tf End time (serial interval given). ... Parameters offspring distribution required R.","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/chain_sim.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Simulate transmission chains using a branching process — chain_sim","text":"Either: vector sizes/lengths (tree == FALSE serial interval function specified, since implies tree == FALSE), data frame columns n (simulation ID), time (serial interval given) (tree == TRUE), id (unique ID within simulation individual element chain), ancestor (ID ancestor element), generation.","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/chain_sim.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Simulate transmission chains using a branching process — chain_sim","text":"chain_sim() either returns vector data.frame. output either vector serial provided, automatically sets tree = FALSE, data.frame, means serial provided function. serial provided, means tree = TRUE automatically. However, setting tree = TRUE require providing function serial.","code":""},{"path":[]},{"path":"https://epiverse-trace.github.io/bpmodels/reference/chain_sim.html","id":"assumptions-disambiguation","dir":"Reference","previous_headings":"","what":"Assumptions/disambiguation","title":"Simulate transmission chains using a branching process — chain_sim","text":"epidemiology, generation interval duration successive infectious events chain transmission. Similarly, serial interval duration observed symptom onset times successive cases transmission chain. generation interval often hard observe exact times infection hard measure hence, serial interval often used instead. , use serial interval represent normally called generation interval, , time successive cases.","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/chain_sim.html","id":"specifying-serial-in-chain-sim-","dir":"Reference","previous_headings":"","what":"Specifying serial in chain_sim()","title":"Simulate transmission chains using a branching process — chain_sim","text":"serial must specified named anonymous/inline/unnamed function # nolint one argument. serial specified, chain_sim() returns times infection column output. Moreover, specifying function serial implies tree = TRUE tree infectors (ancestor) infectees (id) generated output. example, assuming want specify serial interval generator random log-normally distributed variable meanlog = 0.58 sdlog = 1.58, define named function, call \"serial_interval\", one argument representing number serial intervals sample: serial_interval <- function(n){rlnorm(n, 0.58, 1.38)}, assign name function serial chain_sim() like chain_sim(..., serial = serial_interval), ... arguments chain_sim(). Alternatively, assign anonymous function serial chain_sim() call like chain_sim(..., serial = function(n){rlnorm(n, 0.58, 1.38)}), ... arguments chain_sim().","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/chain_sim.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Simulate transmission chains using a branching process — chain_sim","text":"Sebastian Funk, James M. Azam","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/chain_sim.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Simulate transmission chains using a branching process — chain_sim","text":"","code":"# Specifying no `serial` and `tree == FALSE` (default) returns a vector set.seed(123) chain_sim(n = 5, offspring = \"pois\", stat = \"size\", lambda = 0.5, tree = FALSE) #> [1] 1 2 1 2 4 # Specifying `serial` without specifying `tree` will set `tree = TRUE` # internally. # We'll first define the serial function set.seed(123) serial_interval <- function(n) { rlnorm(n, meanlog = 0.58, sdlog = 1.58) } chain_sim( n = 5, offspring = \"pois\", lambda = 0.5, stat = \"length\", infinite = 100, serial = serial_interval ) #> n id ancestor generation time #> 1 1 1 NA 1 0.0000000 #> 2 2 1 NA 1 0.0000000 #> 3 3 1 NA 1 0.0000000 #> 4 4 1 NA 1 0.0000000 #> 5 5 1 NA 1 0.0000000 #> 6 2 2 1 2 0.1237492 #> 7 4 2 1 2 12.6594440 #> 8 5 2 1 2 1.5035572 #> 9 5 3 1 2 1.4840246 #> 10 5 4 2 3 1.6201477 #> 11 5 5 4 4 13.9750044 #> 12 5 6 4 4 4.7736253 #> 13 5 7 5 5 16.1023578 #> 14 5 8 6 5 5.5157567 #> 15 5 9 7 6 20.0243658 #> 16 5 10 7 6 16.1822358 #> 17 5 11 8 6 10.9251791 # Specifying `serial` and `tree = FALSE` will throw a warning saying that # `tree` was set to `TRUE` internally. set.seed(123) if (FALSE) { try(chain_sim( n = 10, serial = function(x) 3, offspring = \"pois\", lambda = 2, infinite = 10, tree = FALSE )) }"},{"path":"https://epiverse-trace.github.io/bpmodels/reference/chain_sim_susc.html","id":null,"dir":"Reference","previous_headings":"","what":"Simulate a single chain using a branching process while accounting\nfor depletion of susceptibles. — chain_sim_susc","title":"Simulate a single chain using a branching process while accounting\nfor depletion of susceptibles. — chain_sim_susc","text":"Simulate single chain using branching process accounting depletion susceptibles.","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/chain_sim_susc.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Simulate a single chain using a branching process while accounting\nfor depletion of susceptibles. — chain_sim_susc","text":"","code":"chain_sim_susc( offspring = c(\"pois\", \"nbinom\"), mn_offspring, disp_offspring, serial, t0 = 0, tf = Inf, pop, initial_immune = 0 )"},{"path":"https://epiverse-trace.github.io/bpmodels/reference/chain_sim_susc.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Simulate a single chain using a branching process while accounting\nfor depletion of susceptibles. — chain_sim_susc","text":"offspring offspring distribution: character string corresponding R distribution function. Currently \"pois\" & \"nbinom\" supported. Internally truncated distributions used avoid infecting people susceptibles available. mn_offspring average number secondary cases case disp_offspring dispersion coefficient (var/mean) number secondary cases. Ignored offspring == \"pois\". Must > 1. serial serial interval. function takes one parameter (n), number serial intervals randomly sample. Value must >= 0. t0 start time tf end time pop population initial_immune number initial immunes population","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/chain_sim_susc.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Simulate a single chain using a branching process while accounting\nfor depletion of susceptibles. — chain_sim_susc","text":"data frame columns time, id (unique ID individual element chain), ancestor (ID ancestor element), generation.","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/chain_sim_susc.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Simulate a single chain using a branching process while accounting\nfor depletion of susceptibles. — chain_sim_susc","text":"function couple key differences chain_sim: can simulate one chain time, can handle implemented offspring distributions (\"pois\" \"nbinom\"), always tracks returns data frame containing entire tree, maximal length chains limited pop instead infinite.","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/chain_sim_susc.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Simulate a single chain using a branching process while accounting\nfor depletion of susceptibles. — chain_sim_susc","text":"Flavio Finger","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/chain_sim_susc.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Simulate a single chain using a branching process while accounting\nfor depletion of susceptibles. — chain_sim_susc","text":"","code":"chain_sim_susc(\"pois\", mn_offspring = 0.5, serial = function(x) 3, pop = 100) #> id ancestor generation time #> 1 1 NA 1 0"},{"path":"https://epiverse-trace.github.io/bpmodels/reference/complementary_logprob.html","id":null,"dir":"Reference","previous_headings":"","what":"Calculates the complementary log-probability — complementary_logprob","title":"Calculates the complementary log-probability — complementary_logprob","text":"Given x norm, calculates log(1-sum(exp(x)))","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/complementary_logprob.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Calculates the complementary log-probability — complementary_logprob","text":"","code":"complementary_logprob(x)"},{"path":"https://epiverse-trace.github.io/bpmodels/reference/complementary_logprob.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Calculates the complementary log-probability — complementary_logprob","text":"x log-probabilities","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/complementary_logprob.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Calculates the complementary log-probability — complementary_logprob","text":"value","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/complementary_logprob.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Calculates the complementary log-probability — complementary_logprob","text":"Sebastian Funk","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/covid19_sa.html","id":null,"dir":"Reference","previous_headings":"","what":"COVID-19 Data Repository for South Africa — covid19_sa","title":"COVID-19 Data Repository for South Africa — covid19_sa","text":"aggregated subset COVID-19 Data Repository South Africa created, maintained hosted Data Science Social Impact research group, led Dr. Vukosi Marivate.","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/covid19_sa.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"COVID-19 Data Repository for South Africa — covid19_sa","text":"","code":"covid19_sa"},{"path":[]},{"path":"https://epiverse-trace.github.io/bpmodels/reference/covid19_sa.html","id":"covid-sa","dir":"Reference","previous_headings":"","what":"covid19_sa","title":"COVID-19 Data Repository for South Africa — covid19_sa","text":"data frame 19 rows 2 columns: date Date case reported cases Number cases","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/covid19_sa.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"COVID-19 Data Repository for South Africa — covid19_sa","text":"https://github.com/dsfsi/covid19za details data-raw/covid19_sa.R.","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/covid19_sa.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"COVID-19 Data Repository for South Africa — covid19_sa","text":"data originally provided linelist subsetted cleaned data-raw/covid19_sa.R.","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/dborel.html","id":null,"dir":"Reference","previous_headings":"","what":"Density of the Borel distribution — dborel","title":"Density of the Borel distribution — dborel","text":"Density Borel distribution","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/dborel.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Density of the Borel distribution — dborel","text":"","code":"dborel(x, mu, log = FALSE)"},{"path":"https://epiverse-trace.github.io/bpmodels/reference/dborel.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Density of the Borel distribution — dborel","text":"x vector integers. mu mu parameter. log logical; TRUE, probabilities p given log(p).","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/dborel.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Density of the Borel distribution — dborel","text":"probability mass.","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/dborel.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Density of the Borel distribution — dborel","text":"Sebastian Funk","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/gborel_size_ll.html","id":null,"dir":"Reference","previous_headings":"","what":"Log-likelihood of the size of chains with gamma-Borel offspring distribution — gborel_size_ll","title":"Log-likelihood of the size of chains with gamma-Borel offspring distribution — gborel_size_ll","text":"Log-likelihood size chains gamma-Borel offspring distribution","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/gborel_size_ll.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Log-likelihood of the size of chains with gamma-Borel offspring distribution — gborel_size_ll","text":"","code":"gborel_size_ll(x, size, prob, mu)"},{"path":"https://epiverse-trace.github.io/bpmodels/reference/gborel_size_ll.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Log-likelihood of the size of chains with gamma-Borel offspring distribution — gborel_size_ll","text":"x vector sizes size dispersion parameter (often called k ecological applications) prob probability success (parameterisation prob, see also NegBinomial) mu mean parameter","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/gborel_size_ll.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Log-likelihood of the size of chains with gamma-Borel offspring distribution — gborel_size_ll","text":"log-likelihood values","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/gborel_size_ll.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Log-likelihood of the size of chains with gamma-Borel offspring distribution — gborel_size_ll","text":"Sebastian Funk","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/geom_length_ll.html","id":null,"dir":"Reference","previous_headings":"","what":"Log-likelihood of the length of chains with geometric offspring distribution — geom_length_ll","title":"Log-likelihood of the length of chains with geometric offspring distribution — geom_length_ll","text":"Log-likelihood length chains geometric offspring distribution","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/geom_length_ll.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Log-likelihood of the length of chains with geometric offspring distribution — geom_length_ll","text":"","code":"geom_length_ll(x, prob)"},{"path":"https://epiverse-trace.github.io/bpmodels/reference/geom_length_ll.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Log-likelihood of the length of chains with geometric offspring distribution — geom_length_ll","text":"x vector sizes prob probability geometric distribution mean 1/prob","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/geom_length_ll.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Log-likelihood of the length of chains with geometric offspring distribution — geom_length_ll","text":"log-likelihood values","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/geom_length_ll.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Log-likelihood of the length of chains with geometric offspring distribution — geom_length_ll","text":"Sebastian Funk","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/nbinom_size_ll.html","id":null,"dir":"Reference","previous_headings":"","what":"Log-likelihood of the size of chains with Negative-Binomial offspring\ndistribution — nbinom_size_ll","title":"Log-likelihood of the size of chains with Negative-Binomial offspring\ndistribution — nbinom_size_ll","text":"Log-likelihood size chains Negative-Binomial offspring distribution","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/nbinom_size_ll.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Log-likelihood of the size of chains with Negative-Binomial offspring\ndistribution — nbinom_size_ll","text":"","code":"nbinom_size_ll(x, size, prob, mu)"},{"path":"https://epiverse-trace.github.io/bpmodels/reference/nbinom_size_ll.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Log-likelihood of the size of chains with Negative-Binomial offspring\ndistribution — nbinom_size_ll","text":"x vector sizes size dispersion parameter (often called k ecological applications) prob probability success (parameterisation prob, see also NegBinomial) mu mean parameter","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/nbinom_size_ll.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Log-likelihood of the size of chains with Negative-Binomial offspring\ndistribution — nbinom_size_ll","text":"log-likelihood values","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/nbinom_size_ll.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Log-likelihood of the size of chains with Negative-Binomial offspring\ndistribution — nbinom_size_ll","text":"Sebastian Funk","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/offspring_ll.html","id":null,"dir":"Reference","previous_headings":"","what":"Log-likelihood of the length of chains with generic offspring distribution — offspring_ll","title":"Log-likelihood of the length of chains with generic offspring distribution — offspring_ll","text":"likelihoods calculated crude approximation using simulated chains linearly approximating missing values empirical cumulative distribution function (ecdf).","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/offspring_ll.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Log-likelihood of the length of chains with generic offspring distribution — offspring_ll","text":"","code":"offspring_ll(x, offspring, stat, nsim_offspring = 100, ...)"},{"path":"https://epiverse-trace.github.io/bpmodels/reference/offspring_ll.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Log-likelihood of the length of chains with generic offspring distribution — offspring_ll","text":"x vector sizes offspring Offspring distribution: character string corresponding R distribution function (e.g., \"pois\" Poisson, rpois R function generate Poisson random numbers) stat statistic given x (\"size\" \"length\" chains) nsim_offspring number simulations offspring distribution approximation size/length distribution ... parameters pass chain_sim","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/offspring_ll.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Log-likelihood of the length of chains with generic offspring distribution — offspring_ll","text":"log-likelihood values","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/offspring_ll.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Log-likelihood of the length of chains with generic offspring distribution — offspring_ll","text":"Sebastian Funk","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/pois_length_ll.html","id":null,"dir":"Reference","previous_headings":"","what":"Log-likelihood of the length of chains with Poisson offspring distribution — pois_length_ll","title":"Log-likelihood of the length of chains with Poisson offspring distribution — pois_length_ll","text":"Log-likelihood length chains Poisson offspring distribution","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/pois_length_ll.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Log-likelihood of the length of chains with Poisson offspring distribution — pois_length_ll","text":"","code":"pois_length_ll(x, lambda)"},{"path":"https://epiverse-trace.github.io/bpmodels/reference/pois_length_ll.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Log-likelihood of the length of chains with Poisson offspring distribution — pois_length_ll","text":"x vector sizes lambda rate Poisson distribution","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/pois_length_ll.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Log-likelihood of the length of chains with Poisson offspring distribution — pois_length_ll","text":"log-likelihood values","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/pois_length_ll.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Log-likelihood of the length of chains with Poisson offspring distribution — pois_length_ll","text":"Sebastian Funk","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/pois_size_ll.html","id":null,"dir":"Reference","previous_headings":"","what":"Log-likelihood of the size of chains with Poisson offspring distribution — pois_size_ll","title":"Log-likelihood of the size of chains with Poisson offspring distribution — pois_size_ll","text":"Log-likelihood size chains Poisson offspring distribution","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/pois_size_ll.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Log-likelihood of the size of chains with Poisson offspring distribution — pois_size_ll","text":"","code":"pois_size_ll(x, lambda)"},{"path":"https://epiverse-trace.github.io/bpmodels/reference/pois_size_ll.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Log-likelihood of the size of chains with Poisson offspring distribution — pois_size_ll","text":"x vector sizes lambda rate Poisson distribution","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/pois_size_ll.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Log-likelihood of the size of chains with Poisson offspring distribution — pois_size_ll","text":"log-likelihood values","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/pois_size_ll.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Log-likelihood of the size of chains with Poisson offspring distribution — pois_size_ll","text":"Sebastian Funk","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/rbinom_size.html","id":null,"dir":"Reference","previous_headings":"","what":"Samples size (the number of trials) of a binomial distribution — rbinom_size","title":"Samples size (the number of trials) of a binomial distribution — rbinom_size","text":"Samples size parameter binomial distribution fixed x (number successes) p (success probability)","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/rbinom_size.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Samples size (the number of trials) of a binomial distribution — rbinom_size","text":"","code":"rbinom_size(n, x, prob)"},{"path":"https://epiverse-trace.github.io/bpmodels/reference/rbinom_size.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Samples size (the number of trials) of a binomial distribution — rbinom_size","text":"n number samples generate x number successes prob probability success","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/rbinom_size.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Samples size (the number of trials) of a binomial distribution — rbinom_size","text":"sampled sizes","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/rbinom_size.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Samples size (the number of trials) of a binomial distribution — rbinom_size","text":"Sebastian Funk","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/rborel.html","id":null,"dir":"Reference","previous_headings":"","what":"Random number generator from the Borel distribution — rborel","title":"Random number generator from the Borel distribution — rborel","text":"Random numbers generated simulating Poisson branching process","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/rborel.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Random number generator from the Borel distribution — rborel","text":"","code":"rborel(n, mu, infinite = Inf)"},{"path":"https://epiverse-trace.github.io/bpmodels/reference/rborel.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Random number generator from the Borel distribution — rborel","text":"n number random variates generate. mu mu parameter. infinite number treat infinite; simulations stopped number reached","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/rborel.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Random number generator from the Borel distribution — rborel","text":"vector random numbers","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/rborel.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Random number generator from the Borel distribution — rborel","text":"Sebastian Funk","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/rgen_length.html","id":null,"dir":"Reference","previous_headings":"","what":"Samples chain lengths with given observation probabilities — rgen_length","title":"Samples chain lengths with given observation probabilities — rgen_length","text":"Samples length transmission chain individual element observed binomial probability parameters n (number successes) p (success probability)","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/rgen_length.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Samples chain lengths with given observation probabilities — rgen_length","text":"","code":"rgen_length(n, x, prob)"},{"path":"https://epiverse-trace.github.io/bpmodels/reference/rgen_length.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Samples chain lengths with given observation probabilities — rgen_length","text":"n number samples generate x observed chain lengths prob probability observation","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/rgen_length.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Samples chain lengths with given observation probabilities — rgen_length","text":"sampled lengths","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/rgen_length.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Samples chain lengths with given observation probabilities — rgen_length","text":"Sebastian Funk","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/rnbinom_mean_disp.html","id":null,"dir":"Reference","previous_headings":"","what":"Negative binomial random numbers parametrized\nin terms of mean and dispersion coefficient — rnbinom_mean_disp","title":"Negative binomial random numbers parametrized\nin terms of mean and dispersion coefficient — rnbinom_mean_disp","text":"Negative binomial random numbers parametrized terms mean dispersion coefficient","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/rnbinom_mean_disp.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Negative binomial random numbers parametrized\nin terms of mean and dispersion coefficient — rnbinom_mean_disp","text":"","code":"rnbinom_mean_disp(n, mn, disp)"},{"path":"https://epiverse-trace.github.io/bpmodels/reference/rnbinom_mean_disp.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Negative binomial random numbers parametrized\nin terms of mean and dispersion coefficient — rnbinom_mean_disp","text":"n number samples draw mn mean distribution disp dispersion coefficient (var/mean)","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/rnbinom_mean_disp.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Negative binomial random numbers parametrized\nin terms of mean and dispersion coefficient — rnbinom_mean_disp","text":"vector containing random numbers","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/rnbinom_mean_disp.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Negative binomial random numbers parametrized\nin terms of mean and dispersion coefficient — rnbinom_mean_disp","text":"Flavio Finger","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/rnbinom_mean_disp.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Negative binomial random numbers parametrized\nin terms of mean and dispersion coefficient — rnbinom_mean_disp","text":"","code":"rnbinom_mean_disp(n = 5, mn = 4, disp = 2) #> [1] 8 7 6 9 6"},{"path":[]},{"path":"https://epiverse-trace.github.io/bpmodels/news/index.html","id":"website-0-3-0","dir":"Changelog","previous_headings":"","what":"Website","title":"bpmodels 0.3.0","text":"website updated use bootstrap 5. means slightly new look. Exported functions “references” grouped topics.","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/news/index.html","id":"vignettes-0-3-0","dir":"Changelog","previous_headings":"","what":"Vignettes","title":"bpmodels 0.3.0","text":"new vignette added compile bibliography papers apply branching processes infectious disease epidemiology. “quickstart” section README moved “Getting started” section website. README now provides quick description core functions package users referred website quick start.","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/news/index.html","id":"readme-0-3-0","dir":"Changelog","previous_headings":"","what":"README","title":"bpmodels 0.3.0","text":"README longer quickstart section moved website. give README minimalistic look.","code":""},{"path":[]},{"path":"https://epiverse-trace.github.io/bpmodels/news/index.html","id":"minor-functionality-change-0-2-1","dir":"Changelog","previous_headings":"","what":"Minor functionality change","title":"bpmodels 0.2.1","text":"chain_sim() now throws warning, instead error, tree set FALSE serial also specified. assume providing serial interval means want tree transmissions simulated, chain_sim() internally sets tree = TRUE throws warning explaining happened. behaviour break simulations previous versions bpmodels, , please submit issue. remove warning, user explicitly set tree = TRUE specify serial.","code":""},{"path":[]},{"path":"https://epiverse-trace.github.io/bpmodels/news/index.html","id":"documentation-0-2-0","dir":"Changelog","previous_headings":"","what":"Documentation","title":"bpmodels 0.2.0","text":"chain_sim()’s help file updated details. particular, describe detail specify serial argument function. also added examples. new vignette describing project COVID-19 incidence chain_sim() added can accessed bpmodels website “Articles”. README’s “quick start” section updated previously introduction vignette.","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/news/index.html","id":"bpmodels-019999","dir":"Changelog","previous_headings":"","what":"bpmodels 0.1.9999","title":"bpmodels 0.1.9999","text":"faster, vectorised chain simulations","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/news/index.html","id":"bpmodels-010","dir":"Changelog","previous_headings":"","what":"bpmodels 0.1.0","title":"bpmodels 0.1.0","text":"initial release","code":""}] +[{"path":"https://epiverse-trace.github.io/bpmodels/CONTRIBUTING.html","id":null,"dir":"","previous_headings":"","what":"Contributing to bpmodels","title":"Contributing to bpmodels","text":"outlines propose change bpmodels.","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/CONTRIBUTING.html","id":"making-changes","dir":"","previous_headings":"","what":"Making changes","title":"Contributing to bpmodels","text":"want make change, ’s good idea first file issue make sure someone team agrees ’s needed. ’ve found bug, please file issue illustrates bug minimal reprex (also help write unit test, needed). See bug report template. feature request see feature request.","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/CONTRIBUTING.html","id":"pull-request-process","dir":"","previous_headings":"Making changes","what":"Pull request process","title":"Contributing to bpmodels","text":"See pull request template Fork package clone onto computer. haven’t done , recommend using usethis::create_from_github(\"epiverse-trace/bpmodels\", fork = TRUE). Install development dependencies devtools::install_dev_deps(), make sure package passes R CMD check running devtools::check(). R CMD check doesn’t pass cleanly, ’s good idea ask help continuing. Create Git branch pull request (PR). recommend using usethis::pr_init(\"brief-description--change\"). Make changes, commit git, create PR running usethis::pr_push(), following prompts browser. title PR briefly describe change. body PR contain Fixes #issue-number. user-facing changes, add bullet top NEWS.md (.e. just first header). Follow style described https://style.tidyverse.org/news.html.","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/CONTRIBUTING.html","id":"code-style","dir":"","previous_headings":"Making changes","what":"Code style","title":"Contributing to bpmodels","text":"New code follow tidyverse style guide. can use styler package apply styles, please don’t restyle code nothing PR. use roxygen2, Markdown syntax, documentation. use testthat unit tests. Contributions test cases included easier accept.","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/CONTRIBUTING.html","id":"code-of-conduct","dir":"","previous_headings":"","what":"Code of Conduct","title":"Contributing to bpmodels","text":"Please note bpmodels released Contributor Code Conduct. contributing project agree abide terms.","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/LICENSE.html","id":null,"dir":"","previous_headings":"","what":"MIT License","title":"MIT License","text":"Copyright (c) 2023 bpmodels authors Permission hereby granted, free charge, person obtaining copy software associated documentation files (“Software”), deal Software without restriction, including without limitation rights use, copy, modify, merge, publish, distribute, sublicense, /sell copies Software, permit persons Software furnished , subject following conditions: copyright notice permission notice shall included copies substantial portions Software. SOFTWARE PROVIDED “”, WITHOUT WARRANTY KIND, EXPRESS IMPLIED, INCLUDING LIMITED WARRANTIES MERCHANTABILITY, FITNESS PARTICULAR PURPOSE NONINFRINGEMENT. EVENT SHALL AUTHORS COPYRIGHT HOLDERS LIABLE CLAIM, DAMAGES LIABILITY, WHETHER ACTION CONTRACT, TORT OTHERWISE, ARISING , CONNECTION SOFTWARE USE DEALINGS SOFTWARE.","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/articles/bpmodels.html","id":"quick-start","dir":"Articles","previous_headings":"","what":"Quick start","title":"Analysing infectious disease transmission chains with bpmodels","text":"","code":"library(\"bpmodels\")"},{"path":"https://epiverse-trace.github.io/bpmodels/articles/bpmodels.html","id":"chain_ll-calculate-log-likelihoods","dir":"Articles","previous_headings":"Quick start","what":"chain_ll(): calculate log-likelihoods","title":"Analysing infectious disease transmission chains with bpmodels","text":"chain_ll() function calculates log-likelihood distribution chain sizes lengths given offspring distribution associated parameters. example, observed distribution chains sizes \\(1, 1, 4, 7\\), can calculate log-likelihood observed chain assuming offspring per generation Poisson distributed mean number (can interpreted reproduction number, \\(R_0\\)) \\(0.5\\). , run first argument chain_ll() chain size (length, number generations chain lasted) distribution analyse. second argument, offspring, specifies offspring distribution. specified string name function used generate random offspring. can probability distribution implemented R, , one corresponding function generating random numbers beginning letter r. case example , since random Poisson numbers generated R using function called rpois(), string pass offspring argument \"pois\". third argument, stat, determines whether analyse chain sizes (\"size\", default argument specified) lengths (\"length\"). Lastly, named arguments recognised chain_ll() interpreted parameters corresponding probability distribution, lambda = 0.5 mean Poisson distribution (see R help page Poisson distribution information).","code":"chain_sizes <- c(1, 1, 4, 7) # example of observed chain sizes chain_ll(x = chain_sizes, offspring = \"pois\", stat = \"size\", lambda = 0.5) #> [1] -8.607196"},{"path":"https://epiverse-trace.github.io/bpmodels/articles/bpmodels.html","id":"imperfect-observations","dir":"Articles","previous_headings":"Quick start > chain_ll(): calculate log-likelihoods","what":"Imperfect observations","title":"Analysing infectious disease transmission chains with bpmodels","text":"default, chain_ll() assumes perfect observation, obs_prob = 1 (See ?chain_ll), meaning transmission events observed recorded data. observations imperfect, chain_ll() provides argument, obs_prob, specifying probability observation. probability used determine likelihood observing specified chain sizes lengths. case imperfect observation, true chain sizes lengths simulated repeatedly (number times given nsim_obs argument), likelihood calculated simulations. example, probability observing case obs_prob = 0.30, use returns 10 likelihood values (nsim_obs = 10), can averaged come overall likelihood estimate. find usage chain_ll() function, can run ?chain_ll access R help file.","code":"chain_sizes <- c(1, 1, 4, 7) # example of observed chain sizes ll <- chain_ll(chain_sizes, \"pois\", \"size\", obs_prob = 0.3, lambda = 0.5, nsim_obs = 10) ll #> [1] -25.15118 -24.07999 -19.83831 -25.65763 -24.55822 -26.39298 -22.18380 #> [8] -19.13043 -24.77695 -25.94688"},{"path":"https://epiverse-trace.github.io/bpmodels/articles/bpmodels.html","id":"how-chain_ll-works","dir":"Articles","previous_headings":"Quick start > chain_ll(): calculate log-likelihoods","what":"How chain_ll() works","title":"Analysing infectious disease transmission chains with bpmodels","text":"probability distribution chain sizes lengths analytical solution, used. chain_ll() currently supports Poisson negative binomial size distribution Poisson geometric length distribution. analytical solution exist, simulations used approximate probability distributions (using linear approximation cumulative distribution unobserved sizes/lengths). case, extra argument nsim_offspring must passed chain_ll() specify number simulations used approximation. example, get offspring drawn binomial distribution probability prob = 0.5, run","code":"set.seed(12) chain_sizes <- c(1, 1, 4, 7) # example of observed chain sizes chain_ll(chain_sizes, \"binom\", \"size\", size = 1, prob = 0.5, nsim_offspring = 100) #> [1] -8.496803"},{"path":"https://epiverse-trace.github.io/bpmodels/articles/bpmodels.html","id":"chain_sim-simulate-transmission-chains-with-branching-processes","dir":"Articles","previous_headings":"Quick start","what":"chain_sim(): simulate transmission chains with branching processes","title":"Analysing infectious disease transmission chains with bpmodels","text":"simulate branching process, use chain_sim() function. function follows syntax chain_ll(). Note chain_sim() stochastic, seed needs set ensure results can reproduced. , simulating \\(5\\) chains, assuming offspring generated using Poisson distribution mean, lambda = 0.5. default, chain_sim() returns vector chain sizes/lengths. instead want return tree infectees infectors, need specify function serial interval set tree = TRUE (see next section).","code":"set.seed(12) chain_sim(n = 5, offspring = \"pois\", stat = \"size\", lambda = 0.5) #> [1] 1 2 4 1 1"},{"path":"https://epiverse-trace.github.io/bpmodels/articles/bpmodels.html","id":"simulating-trees","dir":"Articles","previous_headings":"Quick start > chain_sim(): simulate transmission chains with branching processes","what":"Simulating trees","title":"Analysing infectious disease transmission chains with bpmodels","text":"simulate tree transmission chains, specify serial interval generation function (serial_interval()) set tree = TRUE follows:","code":"set.seed(12) serial_interval <- function(n) { rlnorm(n, meanlog = 0.58, sdlog = 1.58) } chains_df <- chain_sim( n = 5, offspring = \"pois\", lambda = 0.5, stat = \"length\", infinite = 100, serial = serial_interval, tree = TRUE ) head(chains_df) #> n id ancestor generation time #> 1 1 1 NA 1 0.00000000 #> 2 2 1 NA 1 0.00000000 #> 3 3 1 NA 1 0.00000000 #> 4 4 1 NA 1 0.00000000 #> 5 5 1 NA 1 0.00000000 #> 6 2 2 1 2 0.09968906"},{"path":[]},{"path":[]},{"path":"https://epiverse-trace.github.io/bpmodels/articles/projecting_incidence.html","id":"overview","dir":"Articles","previous_headings":"","what":"Overview","title":"Projecting infectious disease incidence: a COVID-19 example","text":"Branching processes can used project infectious disease trends time provided can characterize distribution times successive cases (serial interval), distribution secondary cases produced single individual (offspring distribution). simulations can achieved bpmodels chain_sim() function Pearson et al. (2020), Abbott et al. (2020) illustrate application COVID-19. purpose vignette use early data COVID-19 South Africa (Marivate Combrink 2020) illustrate bpmodels can used forecast outbreak. Let’s load required packages","code":"library(\"bpmodels\") library(\"dplyr\") library(\"ggplot2\") library(\"lubridate\")"},{"path":"https://epiverse-trace.github.io/bpmodels/articles/projecting_incidence.html","id":"data","dir":"Articles","previous_headings":"","what":"Data","title":"Projecting infectious disease incidence: a COVID-19 example","text":"Included bpmodels cleaned time series first 15 days COVID-19 outbreak South Africa. can loaded memory follows: Let us examine first 6 entries dataset.","code":"data(\"covid19_sa\", package = \"bpmodels\") head(covid19_sa) #> # A tibble: 6 × 2 #> date cases #> #> 1 2020-03-05 1 #> 2 2020-03-07 1 #> 3 2020-03-08 1 #> 4 2020-03-09 4 #> 5 2020-03-11 6 #> 6 2020-03-12 3"},{"path":[]},{"path":"https://epiverse-trace.github.io/bpmodels/articles/projecting_incidence.html","id":"onset-times","dir":"Articles","previous_headings":"Setting up the inputs","what":"Onset times","title":"Projecting infectious disease incidence: a COVID-19 example","text":"chain_sim() requires vector onset times, t0, chain/individual/simulation. covid19_sa dataset aggregated, disaggregate linelist row representing case onset time. achieve , first use date index case reference find difference date reference. Using vector start times time series, create linelist disaggregating time series case corresponding start time.","code":"days_since_index <- as.integer(covid19_sa$date - min(covid19_sa$date)) days_since_index #> [1] 0 2 3 4 6 7 8 9 10 11 12 13 14 15 start_times <- unlist(mapply( function(x, y) rep(x, times = ifelse(y == 0, 1, y)), days_since_index, covid19_sa$cases )) start_times #> [1] 0 2 3 4 4 4 4 6 6 6 6 6 6 7 7 7 8 8 8 8 8 8 8 8 9 #> [26] 9 9 9 9 9 9 9 9 9 9 9 9 9 10 10 10 10 10 10 10 10 10 10 10 10 #> [51] 10 11 11 11 11 11 11 11 11 11 11 11 12 12 12 12 12 12 12 12 12 12 12 12 12 #> [76] 12 12 12 12 12 12 12 12 12 12 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 #> [101] 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 14 14 14 14 14 14 14 14 14 #> [126] 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 #> [151] 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 #> [176] 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 #> [201] 15 15"},{"path":"https://epiverse-trace.github.io/bpmodels/articles/projecting_incidence.html","id":"serial-interval","dir":"Articles","previous_headings":"Setting up the inputs","what":"Serial interval","title":"Projecting infectious disease incidence: a COVID-19 example","text":"log-normal distribution commonly used epidemiology characterise quantities serial interval large variance can positive-valued (Nishiura 2007; Limpert, Stahel, Abbt 2001). example, assume based COVID-19 literature serial interval, S, log-normal distributed parameters, \\(\\mu = 4.7\\) \\(\\sigma = 2.9\\) (Pearson et al. 2020). Note distribution described way, means \\(\\mu\\) \\(\\sigma\\) expected value standard deviation natural logarithm serial interval. Hence, order sample “back-transformed” measured serial interval expectation/mean, \\(E[S]\\) standard deviation, \\(SD [S]\\), can use following parametrisation: \\[\\begin{align} E[S] &= \\ln \\left( \\dfrac{\\mu^2}{(\\sqrt{\\mu^2 + \\sigma^2}} \\right) \\\\ SD [S] &= \\sqrt {\\ln \\left(1 + \\dfrac{\\sigma^2}{\\mu^2} \\right)} \\end{align}\\] See “log-normal_distribution” Wikipedia detailed explanation parametrisation. now set serial interval function appropriate inputs. adopt R’s random lognormal distribution generator (rlnorm()) takes meanlog sdlog arguments, define parametrisation log_mean() log_sd() respectively wrap serial_interval() function. Moreover, serial_interval() takes one argument sample_size required bpmodels (See ?bpmodels::chain_sim), passed rlnorm() first argument determine number observations sample (See ?rlnorm).","code":"mu <- 4.7 sgma <- 2.9 log_mean <- log((mu^2) / (sqrt(sgma^2 + mu^2))) # log mean log_sd <- sqrt(log(1 + (sgma / mu)^2)) # log sd #' serial interval function serial_interval <- function(sample_size) { si <- rlnorm(sample_size, meanlog = log_mean, sdlog = log_sd) return(si) }"},{"path":"https://epiverse-trace.github.io/bpmodels/articles/projecting_incidence.html","id":"offspring-distribution","dir":"Articles","previous_headings":"Setting up the inputs","what":"Offspring distribution","title":"Projecting infectious disease incidence: a COVID-19 example","text":"negative binomial distribution commonly used epidemiology account individual variation transmissibility, also known superspreading (Lloyd-Smith et al. 2005). example, assume offspring distribution characterised negative binomial \\(R = 2.5\\) (Abbott et al. 2020) \\(k = 0.58\\) (Wang et al. 2020). parameterization, \\(R\\) represents \\(R_0\\), defined average number cases produced single individual entirely susceptible population. parameter \\(k\\) represents superspreading, , degree heterogeneity transmission single individuals.","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/articles/projecting_incidence.html","id":"simulation-controls","dir":"Articles","previous_headings":"Setting up the inputs","what":"Simulation controls","title":"Projecting infectious disease incidence: a COVID-19 example","text":"chain_sim() also requires end time simulations. example, simulate outbreaks end 14 days last date observations covid19_sa. chain_sim() stochastic, meaning results different every time run set parameters, run simulations many times summarise results. , therefore, run simulation \\(100\\) times. Lastly, chain_sim() requires maximum size chain. value, simulation cut . value specified, assumes value infinity. , assume maximum chain size \\(1000\\). call chain_threhold.","code":"#' Date to end simulation (14 day projection in this case) projection_window <- 14 # 14 days/ 2-week ahead projection projection_end_day <- max(days_since_index) + projection_window projection_end_day #> [1] 29 #' Number of simulations sim_rep <- 100 #' Maximum chain size allowed chain_threshold <- 1000"},{"path":"https://epiverse-trace.github.io/bpmodels/articles/projecting_incidence.html","id":"modelling-assumptions","dir":"Articles","previous_headings":"","what":"Modelling assumptions","title":"Projecting infectious disease incidence: a COVID-19 example","text":"chain_sim() makes following simplifying assumptions: cases observed reporting delay Reporting rate constant course epidemic interventions implemented Population homogeneous well-mixed summarise whole set far, going simulate chain 100 times, projecting COVID-19 cases 14 days first \\(15\\) days, assuming outbreak size exceeds 1000 cases.","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/articles/projecting_incidence.html","id":"running-the-simulations","dir":"Articles","previous_headings":"","what":"Running the simulations","title":"Projecting infectious disease incidence: a COVID-19 example","text":"use function lapply() run simulations bind rows dplyr::bind_rows(). Let us view first rows simulation results.","code":"set.seed(1234) sim_chain_sizes <- lapply( seq_len(sim_rep), function(sim) { chain_sim( n = length(start_times), offspring = \"nbinom\", mu = 2.5, size = 0.58, stat = \"size\", infinite = chain_threshold, serial = serial_interval, t0 = start_times, tf = projection_end_day, tree = TRUE ) %>% mutate(sim = sim) } ) sim_output <- bind_rows(sim_chain_sizes) head(sim_output) #> n id ancestor generation time sim #> 1 1 1 NA 1 0 1 #> 2 2 1 NA 1 2 1 #> 3 3 1 NA 1 3 1 #> 4 4 1 NA 1 4 1 #> 5 5 1 NA 1 4 1 #> 6 6 1 NA 1 4 1"},{"path":"https://epiverse-trace.github.io/bpmodels/articles/projecting_incidence.html","id":"post-processing","dir":"Articles","previous_headings":"","what":"Post-processing","title":"Projecting infectious disease incidence: a COVID-19 example","text":"Now, summarise simulation results. want plot individual simulated daily time series show median cases per day aggregated simulations. First, create daily time series per simulation aggregating number cases per day simulation. Next, add date column results simulation set. use date first case observed data reference start date. Now aggregate simulations day evaluate median daily cases across simulations. done individual simulations, add date column manner.","code":"# Daily number of cases for each simulation incidence_ts <- sim_output %>% mutate(day = ceiling(time)) %>% group_by(sim, day) %>% summarise(cases = n()) %>% ungroup() head(incidence_ts) #> # A tibble: 6 × 3 #> sim day cases #> #> 1 1 0 1 #> 2 1 2 1 #> 3 1 3 1 #> 4 1 4 4 #> 5 1 6 6 #> 6 1 7 4 # Get start date from the observed data index_date <- min(covid19_sa$date) index_date #> [1] \"2020-03-05\" # Add a dates column to each simulation result incidence_ts_by_date <- incidence_ts %>% group_by(sim) %>% mutate(date = index_date + days(seq(0, n() - 1))) %>% ungroup() head(incidence_ts_by_date) #> # A tibble: 6 × 4 #> sim day cases date #> #> 1 1 0 1 2020-03-05 #> 2 1 2 1 2020-03-06 #> 3 1 3 1 2020-03-07 #> 4 1 4 4 2020-03-08 #> 5 1 6 6 2020-03-09 #> 6 1 7 4 2020-03-10 # Median daily number of cases aggregated across all simulations median_daily_cases <- incidence_ts %>% group_by(day) %>% summarise(median_cases = median(cases)) %>% ungroup() %>% arrange(day) head(median_daily_cases) #> # A tibble: 6 × 2 #> day median_cases #> #> 1 0 1 #> 2 1 1 #> 3 2 1 #> 4 3 1 #> 5 4 4 #> 6 5 1 # Add dates median_daily_cases <- median_daily_cases %>% mutate(date = index_date + days(seq(0, projection_end_day))) %>% ungroup() head(median_daily_cases) #> # A tibble: 6 × 3 #> day median_cases date #> #> 1 0 1 2020-03-05 #> 2 1 1 2020-03-06 #> 3 2 1 2020-03-07 #> 4 3 1 2020-03-08 #> 5 4 4 2020-03-09 #> 6 5 1 2020-03-10"},{"path":"https://epiverse-trace.github.io/bpmodels/articles/projecting_incidence.html","id":"visualization","dir":"Articles","previous_headings":"","what":"Visualization","title":"Projecting infectious disease incidence: a COVID-19 example","text":"now plot individual simulation results alongside median aggregated results. Figure 1: COVID-19 incidence projected two week window. gray lines represent individual simulations, red connected dots represent median daily cases across simulations, black triangles represent observed data.","code":"ggplot(data = incidence_ts_by_date) + geom_line( aes( x = date, y = cases, group = sim ), color = \"grey\", linewidth = 0.2, alpha = 0.25 ) + geom_line( data = median_daily_cases, aes( x = date, y = median_cases ), color = \"tomato3\", linewidth = 1.8 ) + geom_point( data = covid19_sa, aes( x = date, y = cases ), color = \"black\", size = 1.75, shape = 21 ) + geom_line( data = covid19_sa, aes( x = date, y = cases ), color = \"black\", size = 1.75, shape = 21 ) + scale_x_continuous( breaks = seq( min(incidence_ts_by_date$date), max(incidence_ts_by_date$date), 10 ), labels = seq( min(incidence_ts_by_date$date), max(incidence_ts_by_date$date), 10 ) ) + scale_y_continuous( breaks = seq( 0, max(incidence_ts_by_date$cases) + 200, 250 ), labels = seq( 0, max(incidence_ts_by_date$cases) + 200, 250 ) ) + labs(x = \"Date\", y = \"Daily cases (median)\")"},{"path":[]},{"path":"https://epiverse-trace.github.io/bpmodels/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"James M. Azam. Author, maintainer. Zhian N. Kamvar. Contributor. Flavio Finger. Author. Sebastian Funk. Author, copyright holder.","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Sebastian Funk, Flavio Finger, James M. Azam (2023). bpmodels: Analysing transmission chain statistics using branching process models, website: https://github.com/epiverse-trace/bpmodels/","code":"@Manual{, title = {bpmodels: Analysing transmission chain statistics using branching process models}, author = {{Sebastian Funk} and {Flavio Finger} and {James M. Azam}}, year = {2023}, url = {https://github.com/epiverse-trace/bpmodels/}, }"},{"path":"https://epiverse-trace.github.io/bpmodels/index.html","id":"bpmodels-methods-for-simulating-and-analysing-the-size-and-length-of-transmission-chains-from-branching-process-models","dir":"","previous_headings":"","what":"Simulating and Analysing Transmission Chain Statistics using Branching Process\n Models","title":"Simulating and Analysing Transmission Chain Statistics using Branching Process\n Models","text":"bpmodels R package simulate analyse size length branching processes given offspring distribution. models often used infectious disease epidemiology, chains represent chains transmission, offspring distribution represents distribution secondary infections caused infected individual.","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/index.html","id":"installation","dir":"","previous_headings":"","what":"Installation","title":"Simulating and Analysing Transmission Chain Statistics using Branching Process\n Models","text":"package can installed CRAN using latest development version bpmodels package can installed via load package, use","code":"install.packages(\"bpmodels\") # check whether {pak} is installed if (!require(\"pak\")) install.packages(\"pak\") pak::pkg_install(\"epiverse-trace/bpmodels\") library(\"bpmodels\")"},{"path":"https://epiverse-trace.github.io/bpmodels/index.html","id":"core-functionality","dir":"","previous_headings":"","what":"Core functionality","title":"Simulating and Analysing Transmission Chain Statistics using Branching Process\n Models","text":"bpmodels provides three main functions: chain_ll(): calculates likelihoods observing vector chains given sizes lengths. quick example estimating loglikelihood observed chain: chain_sim(): simulates transmission chains chains stop producing offspring. quick example simulate chain sizes 5 chains poisson offspring mean, lambda = 0.5: chain_sim_susc(): simulates transmission chains specified population size pre-existing immunity susceptible pool runs . quick example simulate chains poisson offspring mean, lambda = 0.5, serial interval 3: See “Get started vignette” detailed illustration function.","code":"# example of observed chain sizes chain_sizes <- c(1, 2, 3, 4) # estimate loglikelihood of the observed chain sizes chain_ll_eg <- chain_ll(x = chain_sizes, offspring = \"pois\", stat = \"size\", lambda = 0.5) chain_ll_eg #> [1] -7.772589 set.seed(123) chain_sim_eg <- chain_sim(n = 5, offspring = \"pois\", stat = \"size\", lambda = 0.5, tree = TRUE) head(chain_sim_eg) #> n id ancestor generation #> 1 1 1 NA 1 #> 2 2 1 NA 1 #> 3 3 1 NA 1 #> 4 4 1 NA 1 #> 5 5 1 NA 1 #> 6 2 2 1 2 set.seed(1234) chain_sim_susc_eg <- chain_sim_susc(pop = 1000, offspring = \"pois\", mn_offspring = 0.5, serial = function(x) {3} ) head(chain_sim_susc_eg) #> id ancestor generation time #> 1 1 NA 1 0"},{"path":"https://epiverse-trace.github.io/bpmodels/index.html","id":"package-vignettes","dir":"","previous_headings":"","what":"Package vignettes","title":"Simulating and Analysing Transmission Chain Statistics using Branching Process\n Models","text":"Specific use cases bpmodels can found online documentation package vignettes, “Articles”.","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/index.html","id":"reporting-bugs","dir":"","previous_headings":"","what":"Reporting bugs","title":"Simulating and Analysing Transmission Chain Statistics using Branching Process\n Models","text":"report bug please open issue.","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/index.html","id":"contribute","dir":"","previous_headings":"","what":"Contribute","title":"Simulating and Analysing Transmission Chain Statistics using Branching Process\n Models","text":"welcome contributions enhance package’s functionalities. wish , please follow package contributing guide.","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/index.html","id":"code-of-conduct","dir":"","previous_headings":"","what":"Code of conduct","title":"Simulating and Analysing Transmission Chain Statistics using Branching Process\n Models","text":"Please note bpmodels project released Contributor Code Conduct. contributing project, agree abide terms.","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/index.html","id":"citing-this-package","dir":"","previous_headings":"","what":"Citing this package","title":"Simulating and Analysing Transmission Chain Statistics using Branching Process\n Models","text":"","code":"citation(\"bpmodels\") #> To cite package bpmodels in publications use: #> #> Sebastian Funk, Flavio Finger, and James M. Azam (2023). bpmodels: #> Analysing transmission chain statistics using branching process #> models, website: https://github.com/epiverse-trace/bpmodels/ #> #> A BibTeX entry for LaTeX users is #> #> @Manual{, #> title = {bpmodels: Analysing transmission chain statistics using branching process models}, #> author = {{Sebastian Funk} and {Flavio Finger} and {James M. Azam}}, #> year = {2023}, #> url = {https://github.com/epiverse-trace/bpmodels/}, #> }"},{"path":"https://epiverse-trace.github.io/bpmodels/reference/bpmodels-package.html","id":null,"dir":"Reference","previous_headings":"","what":"bpmodels: Simulating and Analysing Transmission Chain Statistics using Branching Process Models — bpmodels-package","title":"bpmodels: Simulating and Analysing Transmission Chain Statistics using Branching Process Models — bpmodels-package","text":"Provides methods simulate analyse size length branching processes arbitrary offspring distribution. can used, example, analyse distribution chain sizes length infectious disease outbreaks, discussed Farrington et al. (2003) doi:10.1093/biostatistics/4.2.279 .","code":""},{"path":[]},{"path":"https://epiverse-trace.github.io/bpmodels/reference/bpmodels-package.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"bpmodels: Simulating and Analysing Transmission Chain Statistics using Branching Process Models — bpmodels-package","text":"Maintainer: James M. Azam james.azam@lshtm.ac.uk (ORCID) Authors: Flavio Finger flavio.finger@epicentre.msf.org (ORCID) Sebastian Funk sebastian.funk@lshtm.ac.uk (ORCID) [copyright holder] contributors: Zhian N. Kamvar zkamvar@gmail.com (ORCID) [contributor]","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/chain_ll.html","id":null,"dir":"Reference","previous_headings":"","what":"Calculate the log-likelihood for the outcome of a branching process — chain_ll","title":"Calculate the log-likelihood for the outcome of a branching process — chain_ll","text":"Calculate log-likelihood outcome branching process","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/chain_ll.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Calculate the log-likelihood for the outcome of a branching process — chain_ll","text":"","code":"chain_ll( x, offspring, stat = c(\"size\", \"length\"), obs_prob = 1, infinite = Inf, exclude = NULL, individual = FALSE, nsim_obs, ... )"},{"path":"https://epiverse-trace.github.io/bpmodels/reference/chain_ll.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Calculate the log-likelihood for the outcome of a branching process — chain_ll","text":"x vector sizes lengths transmission chains offspring Offspring distribution: character string corresponding R distribution function (e.g., \"pois\" Poisson, rpois R function generate Poisson random numbers) stat statistic given x (\"size\" \"length\" chains) obs_prob observation probability (assumed constant) infinite chains size/length treated infinite exclude sizes/lengths exclude log-likelihood calculation individual TRUE, vector individual log-likelihood contributions returned rather sum nsim_obs number simulations log-likelihood approximated imperfect observations ... parameters offspring distribution","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/chain_ll.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Calculate the log-likelihood for the outcome of a branching process — chain_ll","text":"log-likelihood, vector log-likelihoods (obs_prob < 1), list individual log-likelihood contributions (individual=TRUE)","code":""},{"path":[]},{"path":"https://epiverse-trace.github.io/bpmodels/reference/chain_ll.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Calculate the log-likelihood for the outcome of a branching process — chain_ll","text":"Sebastian Funk","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/chain_ll.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Calculate the log-likelihood for the outcome of a branching process — chain_ll","text":"","code":"chain_sizes <- c(1, 1, 4, 7) # example of observed chain sizes chain_ll(chain_sizes, \"pois\", \"size\", lambda = 0.5) #> [1] -8.607196"},{"path":"https://epiverse-trace.github.io/bpmodels/reference/chain_sim.html","id":null,"dir":"Reference","previous_headings":"","what":"Simulate transmission chains using a branching process — chain_sim","title":"Simulate transmission chains using a branching process — chain_sim","text":"chain_sim() stochastic simulator generating transmission chain data key inputs offspring distribution serial interval distribution.","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/chain_sim.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Simulate transmission chains using a branching process — chain_sim","text":"","code":"chain_sim( n, offspring, stat = c(\"size\", \"length\"), infinite = Inf, tree = FALSE, serial, t0 = 0, tf = Inf, ... )"},{"path":"https://epiverse-trace.github.io/bpmodels/reference/chain_sim.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Simulate transmission chains using a branching process — chain_sim","text":"n Number simulations run. offspring Offspring distribution: character string corresponding R distribution function (e.g., \"pois\" Poisson, rpois R function generate Poisson random numbers) stat String; Statistic calculate. Can one : \"size\": total number offspring. \"length\": total number ancestors. infinite size length simulation results set Inf. Defaults Inf, resulting results ever set Inf tree Logical. transmission tree returned? Defaults FALSE. serial serial interval generator function; name user-defined named anonymous function one argument n, representing number serial intervals generate. t0 Start time (serial interval given); either single value vector length n (number simulations) initial times. Defaults 0. tf End time (serial interval given). ... Parameters offspring distribution required R.","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/chain_sim.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Simulate transmission chains using a branching process — chain_sim","text":"Either: vector sizes/lengths (tree == FALSE serial interval function specified, since implies tree == FALSE), data frame columns n (simulation ID), time (serial interval given) (tree == TRUE), id (unique ID within simulation individual element chain), ancestor (ID ancestor element), generation.","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/chain_sim.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Simulate transmission chains using a branching process — chain_sim","text":"chain_sim() either returns vector data.frame. output either vector serial provided, automatically sets tree = FALSE, data.frame, means serial provided function. serial provided, means tree = TRUE automatically. However, setting tree = TRUE require providing function serial.","code":""},{"path":[]},{"path":"https://epiverse-trace.github.io/bpmodels/reference/chain_sim.html","id":"assumptions-disambiguation","dir":"Reference","previous_headings":"","what":"Assumptions/disambiguation","title":"Simulate transmission chains using a branching process — chain_sim","text":"epidemiology, generation interval duration successive infectious events chain transmission. Similarly, serial interval duration observed symptom onset times successive cases transmission chain. generation interval often hard observe exact times infection hard measure hence, serial interval often used instead. , use serial interval represent normally called generation interval, , time successive cases.","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/chain_sim.html","id":"specifying-serial-in-chain-sim-","dir":"Reference","previous_headings":"","what":"Specifying serial in chain_sim()","title":"Simulate transmission chains using a branching process — chain_sim","text":"serial must specified named anonymous/inline/unnamed function # nolint one argument. serial specified, chain_sim() returns times infection column output. Moreover, specifying function serial implies tree = TRUE tree infectors (ancestor) infectees (id) generated output. example, assuming want specify serial interval generator random log-normally distributed variable meanlog = 0.58 sdlog = 1.58, define named function, call \"serial_interval\", one argument representing number serial intervals sample: serial_interval <- function(n){rlnorm(n, 0.58, 1.38)}, assign name function serial chain_sim() like chain_sim(..., serial = serial_interval), ... arguments chain_sim(). Alternatively, assign anonymous function serial chain_sim() call like chain_sim(..., serial = function(n){rlnorm(n, 0.58, 1.38)}), ... arguments chain_sim().","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/chain_sim.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Simulate transmission chains using a branching process — chain_sim","text":"Sebastian Funk, James M. Azam","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/chain_sim.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Simulate transmission chains using a branching process — chain_sim","text":"","code":"# Specifying no `serial` and `tree == FALSE` (default) returns a vector set.seed(123) chain_sim(n = 5, offspring = \"pois\", stat = \"size\", lambda = 0.5, tree = FALSE) #> [1] 1 2 1 2 4 # Specifying `serial` without specifying `tree` will set `tree = TRUE` # internally. # We'll first define the serial function set.seed(123) serial_interval <- function(n) { rlnorm(n, meanlog = 0.58, sdlog = 1.58) } chain_sim( n = 5, offspring = \"pois\", lambda = 0.5, stat = \"length\", infinite = 100, serial = serial_interval ) #> n id ancestor generation time #> 1 1 1 NA 1 0.0000000 #> 2 2 1 NA 1 0.0000000 #> 3 3 1 NA 1 0.0000000 #> 4 4 1 NA 1 0.0000000 #> 5 5 1 NA 1 0.0000000 #> 6 2 2 1 2 0.1237492 #> 7 4 2 1 2 12.6594440 #> 8 5 2 1 2 1.5035572 #> 9 5 3 1 2 1.4840246 #> 10 5 4 2 3 1.6201477 #> 11 5 5 4 4 13.9750044 #> 12 5 6 4 4 4.7736253 #> 13 5 7 5 5 16.1023578 #> 14 5 8 6 5 5.5157567 #> 15 5 9 7 6 20.0243658 #> 16 5 10 7 6 16.1822358 #> 17 5 11 8 6 10.9251791 # Specifying `serial` and `tree = FALSE` will throw a warning saying that # `tree` was set to `TRUE` internally. set.seed(123) if (FALSE) { try(chain_sim( n = 10, serial = function(x) 3, offspring = \"pois\", lambda = 2, infinite = 10, tree = FALSE )) }"},{"path":"https://epiverse-trace.github.io/bpmodels/reference/chain_sim_susc.html","id":null,"dir":"Reference","previous_headings":"","what":"Simulate a single chain using a branching process while accounting\nfor depletion of susceptibles. — chain_sim_susc","title":"Simulate a single chain using a branching process while accounting\nfor depletion of susceptibles. — chain_sim_susc","text":"Simulate single chain using branching process accounting depletion susceptibles.","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/chain_sim_susc.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Simulate a single chain using a branching process while accounting\nfor depletion of susceptibles. — chain_sim_susc","text":"","code":"chain_sim_susc( offspring = c(\"pois\", \"nbinom\"), mn_offspring, disp_offspring, serial, t0 = 0, tf = Inf, pop, initial_immune = 0 )"},{"path":"https://epiverse-trace.github.io/bpmodels/reference/chain_sim_susc.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Simulate a single chain using a branching process while accounting\nfor depletion of susceptibles. — chain_sim_susc","text":"offspring offspring distribution: character string corresponding R distribution function. Currently \"pois\" & \"nbinom\" supported. Internally truncated distributions used avoid infecting people susceptibles available. mn_offspring average number secondary cases case disp_offspring dispersion coefficient (var/mean) number secondary cases. Ignored offspring == \"pois\". Must > 1. serial serial interval. function takes one parameter (n), number serial intervals randomly sample. Value must >= 0. t0 start time tf end time pop population initial_immune number initial immunes population","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/chain_sim_susc.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Simulate a single chain using a branching process while accounting\nfor depletion of susceptibles. — chain_sim_susc","text":"data frame columns time, id (unique ID individual element chain), ancestor (ID ancestor element), generation.","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/chain_sim_susc.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Simulate a single chain using a branching process while accounting\nfor depletion of susceptibles. — chain_sim_susc","text":"function couple key differences chain_sim: can simulate one chain time, can handle implemented offspring distributions (\"pois\" \"nbinom\"), always tracks returns data frame containing entire tree, maximal length chains limited pop instead infinite.","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/chain_sim_susc.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Simulate a single chain using a branching process while accounting\nfor depletion of susceptibles. — chain_sim_susc","text":"Flavio Finger","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/chain_sim_susc.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Simulate a single chain using a branching process while accounting\nfor depletion of susceptibles. — chain_sim_susc","text":"","code":"chain_sim_susc(\"pois\", mn_offspring = 0.5, serial = function(x) 3, pop = 100) #> id ancestor generation time #> 1 1 NA 1 0"},{"path":"https://epiverse-trace.github.io/bpmodels/reference/complementary_logprob.html","id":null,"dir":"Reference","previous_headings":"","what":"Calculates the complementary log-probability — complementary_logprob","title":"Calculates the complementary log-probability — complementary_logprob","text":"Given x norm, calculates log(1-sum(exp(x)))","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/complementary_logprob.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Calculates the complementary log-probability — complementary_logprob","text":"","code":"complementary_logprob(x)"},{"path":"https://epiverse-trace.github.io/bpmodels/reference/complementary_logprob.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Calculates the complementary log-probability — complementary_logprob","text":"x log-probabilities","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/complementary_logprob.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Calculates the complementary log-probability — complementary_logprob","text":"value","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/complementary_logprob.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Calculates the complementary log-probability — complementary_logprob","text":"Sebastian Funk","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/covid19_sa.html","id":null,"dir":"Reference","previous_headings":"","what":"COVID-19 Data Repository for South Africa — covid19_sa","title":"COVID-19 Data Repository for South Africa — covid19_sa","text":"aggregated subset COVID-19 Data Repository South Africa created, maintained hosted Data Science Social Impact research group, led Dr. Vukosi Marivate.","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/covid19_sa.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"COVID-19 Data Repository for South Africa — covid19_sa","text":"","code":"covid19_sa"},{"path":[]},{"path":"https://epiverse-trace.github.io/bpmodels/reference/covid19_sa.html","id":"covid-sa","dir":"Reference","previous_headings":"","what":"covid19_sa","title":"COVID-19 Data Repository for South Africa — covid19_sa","text":"data frame 19 rows 2 columns: date Date case reported cases Number cases","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/covid19_sa.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"COVID-19 Data Repository for South Africa — covid19_sa","text":"https://github.com/dsfsi/covid19za details data-raw/covid19_sa.R.","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/covid19_sa.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"COVID-19 Data Repository for South Africa — covid19_sa","text":"data originally provided linelist subsetted cleaned data-raw/covid19_sa.R.","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/dborel.html","id":null,"dir":"Reference","previous_headings":"","what":"Density of the Borel distribution — dborel","title":"Density of the Borel distribution — dborel","text":"Density Borel distribution","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/dborel.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Density of the Borel distribution — dborel","text":"","code":"dborel(x, mu, log = FALSE)"},{"path":"https://epiverse-trace.github.io/bpmodels/reference/dborel.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Density of the Borel distribution — dborel","text":"x vector integers. mu mu parameter. log logical; TRUE, probabilities p given log(p).","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/dborel.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Density of the Borel distribution — dborel","text":"probability mass.","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/dborel.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Density of the Borel distribution — dborel","text":"Sebastian Funk","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/gborel_size_ll.html","id":null,"dir":"Reference","previous_headings":"","what":"Log-likelihood of the size of chains with gamma-Borel offspring distribution — gborel_size_ll","title":"Log-likelihood of the size of chains with gamma-Borel offspring distribution — gborel_size_ll","text":"Log-likelihood size chains gamma-Borel offspring distribution","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/gborel_size_ll.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Log-likelihood of the size of chains with gamma-Borel offspring distribution — gborel_size_ll","text":"","code":"gborel_size_ll(x, size, prob, mu)"},{"path":"https://epiverse-trace.github.io/bpmodels/reference/gborel_size_ll.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Log-likelihood of the size of chains with gamma-Borel offspring distribution — gborel_size_ll","text":"x vector sizes size dispersion parameter (often called k ecological applications) prob probability success (parameterisation prob, see also NegBinomial) mu mean parameter","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/gborel_size_ll.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Log-likelihood of the size of chains with gamma-Borel offspring distribution — gborel_size_ll","text":"log-likelihood values","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/gborel_size_ll.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Log-likelihood of the size of chains with gamma-Borel offspring distribution — gborel_size_ll","text":"Sebastian Funk","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/geom_length_ll.html","id":null,"dir":"Reference","previous_headings":"","what":"Log-likelihood of the length of chains with geometric offspring distribution — geom_length_ll","title":"Log-likelihood of the length of chains with geometric offspring distribution — geom_length_ll","text":"Log-likelihood length chains geometric offspring distribution","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/geom_length_ll.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Log-likelihood of the length of chains with geometric offspring distribution — geom_length_ll","text":"","code":"geom_length_ll(x, prob)"},{"path":"https://epiverse-trace.github.io/bpmodels/reference/geom_length_ll.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Log-likelihood of the length of chains with geometric offspring distribution — geom_length_ll","text":"x vector sizes prob probability geometric distribution mean 1/prob","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/geom_length_ll.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Log-likelihood of the length of chains with geometric offspring distribution — geom_length_ll","text":"log-likelihood values","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/geom_length_ll.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Log-likelihood of the length of chains with geometric offspring distribution — geom_length_ll","text":"Sebastian Funk","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/nbinom_size_ll.html","id":null,"dir":"Reference","previous_headings":"","what":"Log-likelihood of the size of chains with Negative-Binomial offspring\ndistribution — nbinom_size_ll","title":"Log-likelihood of the size of chains with Negative-Binomial offspring\ndistribution — nbinom_size_ll","text":"Log-likelihood size chains Negative-Binomial offspring distribution","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/nbinom_size_ll.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Log-likelihood of the size of chains with Negative-Binomial offspring\ndistribution — nbinom_size_ll","text":"","code":"nbinom_size_ll(x, size, prob, mu)"},{"path":"https://epiverse-trace.github.io/bpmodels/reference/nbinom_size_ll.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Log-likelihood of the size of chains with Negative-Binomial offspring\ndistribution — nbinom_size_ll","text":"x vector sizes size dispersion parameter (often called k ecological applications) prob probability success (parameterisation prob, see also NegBinomial) mu mean parameter","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/nbinom_size_ll.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Log-likelihood of the size of chains with Negative-Binomial offspring\ndistribution — nbinom_size_ll","text":"log-likelihood values","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/nbinom_size_ll.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Log-likelihood of the size of chains with Negative-Binomial offspring\ndistribution — nbinom_size_ll","text":"Sebastian Funk","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/offspring_ll.html","id":null,"dir":"Reference","previous_headings":"","what":"Log-likelihood of the length of chains with generic offspring distribution — offspring_ll","title":"Log-likelihood of the length of chains with generic offspring distribution — offspring_ll","text":"likelihoods calculated crude approximation using simulated chains linearly approximating missing values empirical cumulative distribution function (ecdf).","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/offspring_ll.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Log-likelihood of the length of chains with generic offspring distribution — offspring_ll","text":"","code":"offspring_ll(x, offspring, stat, nsim_offspring = 100, ...)"},{"path":"https://epiverse-trace.github.io/bpmodels/reference/offspring_ll.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Log-likelihood of the length of chains with generic offspring distribution — offspring_ll","text":"x vector sizes offspring Offspring distribution: character string corresponding R distribution function (e.g., \"pois\" Poisson, rpois R function generate Poisson random numbers) stat statistic given x (\"size\" \"length\" chains) nsim_offspring number simulations offspring distribution approximation size/length distribution ... parameters pass chain_sim","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/offspring_ll.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Log-likelihood of the length of chains with generic offspring distribution — offspring_ll","text":"log-likelihood values","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/offspring_ll.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Log-likelihood of the length of chains with generic offspring distribution — offspring_ll","text":"Sebastian Funk","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/pois_length_ll.html","id":null,"dir":"Reference","previous_headings":"","what":"Log-likelihood of the length of chains with Poisson offspring distribution — pois_length_ll","title":"Log-likelihood of the length of chains with Poisson offspring distribution — pois_length_ll","text":"Log-likelihood length chains Poisson offspring distribution","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/pois_length_ll.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Log-likelihood of the length of chains with Poisson offspring distribution — pois_length_ll","text":"","code":"pois_length_ll(x, lambda)"},{"path":"https://epiverse-trace.github.io/bpmodels/reference/pois_length_ll.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Log-likelihood of the length of chains with Poisson offspring distribution — pois_length_ll","text":"x vector sizes lambda rate Poisson distribution","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/pois_length_ll.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Log-likelihood of the length of chains with Poisson offspring distribution — pois_length_ll","text":"log-likelihood values","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/pois_length_ll.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Log-likelihood of the length of chains with Poisson offspring distribution — pois_length_ll","text":"Sebastian Funk","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/pois_size_ll.html","id":null,"dir":"Reference","previous_headings":"","what":"Log-likelihood of the size of chains with Poisson offspring distribution — pois_size_ll","title":"Log-likelihood of the size of chains with Poisson offspring distribution — pois_size_ll","text":"Log-likelihood size chains Poisson offspring distribution","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/pois_size_ll.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Log-likelihood of the size of chains with Poisson offspring distribution — pois_size_ll","text":"","code":"pois_size_ll(x, lambda)"},{"path":"https://epiverse-trace.github.io/bpmodels/reference/pois_size_ll.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Log-likelihood of the size of chains with Poisson offspring distribution — pois_size_ll","text":"x vector sizes lambda rate Poisson distribution","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/pois_size_ll.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Log-likelihood of the size of chains with Poisson offspring distribution — pois_size_ll","text":"log-likelihood values","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/pois_size_ll.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Log-likelihood of the size of chains with Poisson offspring distribution — pois_size_ll","text":"Sebastian Funk","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/rbinom_size.html","id":null,"dir":"Reference","previous_headings":"","what":"Samples size (the number of trials) of a binomial distribution — rbinom_size","title":"Samples size (the number of trials) of a binomial distribution — rbinom_size","text":"Samples size parameter binomial distribution fixed x (number successes) p (success probability)","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/rbinom_size.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Samples size (the number of trials) of a binomial distribution — rbinom_size","text":"","code":"rbinom_size(n, x, prob)"},{"path":"https://epiverse-trace.github.io/bpmodels/reference/rbinom_size.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Samples size (the number of trials) of a binomial distribution — rbinom_size","text":"n number samples generate x number successes prob probability success","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/rbinom_size.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Samples size (the number of trials) of a binomial distribution — rbinom_size","text":"sampled sizes","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/rbinom_size.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Samples size (the number of trials) of a binomial distribution — rbinom_size","text":"Sebastian Funk","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/rborel.html","id":null,"dir":"Reference","previous_headings":"","what":"Random number generator from the Borel distribution — rborel","title":"Random number generator from the Borel distribution — rborel","text":"Random numbers generated simulating Poisson branching process","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/rborel.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Random number generator from the Borel distribution — rborel","text":"","code":"rborel(n, mu, infinite = Inf)"},{"path":"https://epiverse-trace.github.io/bpmodels/reference/rborel.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Random number generator from the Borel distribution — rborel","text":"n number random variates generate. mu mu parameter. infinite number treat infinite; simulations stopped number reached","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/rborel.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Random number generator from the Borel distribution — rborel","text":"vector random numbers","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/rborel.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Random number generator from the Borel distribution — rborel","text":"Sebastian Funk","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/rgen_length.html","id":null,"dir":"Reference","previous_headings":"","what":"Samples chain lengths with given observation probabilities — rgen_length","title":"Samples chain lengths with given observation probabilities — rgen_length","text":"Samples length transmission chain individual element observed binomial probability parameters n (number successes) p (success probability)","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/rgen_length.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Samples chain lengths with given observation probabilities — rgen_length","text":"","code":"rgen_length(n, x, prob)"},{"path":"https://epiverse-trace.github.io/bpmodels/reference/rgen_length.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Samples chain lengths with given observation probabilities — rgen_length","text":"n number samples generate x observed chain lengths prob probability observation","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/rgen_length.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Samples chain lengths with given observation probabilities — rgen_length","text":"sampled lengths","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/rgen_length.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Samples chain lengths with given observation probabilities — rgen_length","text":"Sebastian Funk","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/rnbinom_mean_disp.html","id":null,"dir":"Reference","previous_headings":"","what":"Negative binomial random numbers parametrized\nin terms of mean and dispersion coefficient — rnbinom_mean_disp","title":"Negative binomial random numbers parametrized\nin terms of mean and dispersion coefficient — rnbinom_mean_disp","text":"Negative binomial random numbers parametrized terms mean dispersion coefficient","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/rnbinom_mean_disp.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Negative binomial random numbers parametrized\nin terms of mean and dispersion coefficient — rnbinom_mean_disp","text":"","code":"rnbinom_mean_disp(n, mn, disp)"},{"path":"https://epiverse-trace.github.io/bpmodels/reference/rnbinom_mean_disp.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Negative binomial random numbers parametrized\nin terms of mean and dispersion coefficient — rnbinom_mean_disp","text":"n number samples draw mn mean distribution disp dispersion coefficient (var/mean)","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/rnbinom_mean_disp.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Negative binomial random numbers parametrized\nin terms of mean and dispersion coefficient — rnbinom_mean_disp","text":"vector containing random numbers","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/rnbinom_mean_disp.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Negative binomial random numbers parametrized\nin terms of mean and dispersion coefficient — rnbinom_mean_disp","text":"Flavio Finger","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/reference/rnbinom_mean_disp.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Negative binomial random numbers parametrized\nin terms of mean and dispersion coefficient — rnbinom_mean_disp","text":"","code":"rnbinom_mean_disp(n = 5, mn = 4, disp = 2) #> [1] 8 7 6 9 6"},{"path":[]},{"path":"https://epiverse-trace.github.io/bpmodels/news/index.html","id":"website-0-3-0","dir":"Changelog","previous_headings":"","what":"Website","title":"bpmodels 0.3.0","text":"website updated use bootstrap 5. means slightly new look. Exported functions “references” grouped topics.","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/news/index.html","id":"vignettes-0-3-0","dir":"Changelog","previous_headings":"","what":"Vignettes","title":"bpmodels 0.3.0","text":"new vignette added compile bibliography papers apply branching processes infectious disease epidemiology. “quickstart” section README moved “Getting started” section website. README now provides quick description core functions package users referred website quick start.","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/news/index.html","id":"readme-0-3-0","dir":"Changelog","previous_headings":"","what":"README","title":"bpmodels 0.3.0","text":"README longer quickstart section moved website. give README minimalistic look.","code":""},{"path":[]},{"path":"https://epiverse-trace.github.io/bpmodels/news/index.html","id":"minor-functionality-change-0-2-1","dir":"Changelog","previous_headings":"","what":"Minor functionality change","title":"bpmodels 0.2.1","text":"chain_sim() now throws warning, instead error, tree set FALSE serial also specified. assume providing serial interval means want tree transmissions simulated, chain_sim() internally sets tree = TRUE throws warning explaining happened. behaviour break simulations previous versions bpmodels, , please submit issue. remove warning, user explicitly set tree = TRUE specify serial.","code":""},{"path":[]},{"path":"https://epiverse-trace.github.io/bpmodels/news/index.html","id":"documentation-0-2-0","dir":"Changelog","previous_headings":"","what":"Documentation","title":"bpmodels 0.2.0","text":"chain_sim()’s help file updated details. particular, describe detail specify serial argument function. also added examples. new vignette describing project COVID-19 incidence chain_sim() added can accessed bpmodels website “Articles”. README’s “quick start” section updated previously introduction vignette.","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/news/index.html","id":"bpmodels-019999","dir":"Changelog","previous_headings":"","what":"bpmodels 0.1.9999","title":"bpmodels 0.1.9999","text":"faster, vectorised chain simulations","code":""},{"path":"https://epiverse-trace.github.io/bpmodels/news/index.html","id":"bpmodels-010","dir":"Changelog","previous_headings":"","what":"bpmodels 0.1.0","title":"bpmodels 0.1.0","text":"initial release","code":""}]