--- a +++ b/docs/articles/Rcpp_API.html @@ -0,0 +1,281 @@ +<!DOCTYPE html> +<!-- Generated by pkgdown: do not edit by hand --><html lang="en"> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> +<meta charset="utf-8"> +<meta http-equiv="X-UA-Compatible" content="IE=edge"> +<meta name="viewport" content="width=device-width, initial-scale=1.0"> +<title>outbreaker2: Rcpp API • outbreaker2</title> +<!-- jquery --><script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script><!-- Bootstrap --><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha256-bZLfwXAP04zRMK2BjiO8iu9pf4FbLqX6zitd+tIvLhE=" crossorigin="anonymous"> +<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha256-nuL8/2cJ5NDSSwnKD8VqreErSWHtnEP9E7AySL+1ev4=" crossorigin="anonymous"></script><!-- bootstrap-toc --><link rel="stylesheet" href="../bootstrap-toc.css"> +<script src="../bootstrap-toc.js"></script><!-- Font Awesome icons --><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/css/all.min.css" integrity="sha256-mmgLkCYLUQbXn0B1SRqzHar6dCnv9oZFPEC1g1cwlkk=" crossorigin="anonymous"> +<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/css/v4-shims.min.css" integrity="sha256-wZjR52fzng1pJHwx4aV2AO3yyTOXrcDW7jBpJtTwVxw=" crossorigin="anonymous"> +<!-- clipboard.js --><script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.6/clipboard.min.js" integrity="sha256-inc5kl9MA1hkeYUt+EC3BhlIgyp/2jDIyBLS6k3UxPI=" crossorigin="anonymous"></script><!-- headroom.js --><script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.11.0/headroom.min.js" integrity="sha256-AsUX4SJE1+yuDu5+mAVzJbuYNPHj/WroHuZ8Ir/CkE0=" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.11.0/jQuery.headroom.min.js" integrity="sha256-ZX/yNShbjqsohH1k95liqY9Gd8uOiE1S4vZc+9KQ1K4=" crossorigin="anonymous"></script><!-- pkgdown --><link href="../pkgdown.css" rel="stylesheet"> +<script src="../pkgdown.js"></script><meta property="og:title" content="outbreaker2: Rcpp API"> +<meta property="og:description" content="outbreaker2"> +<!-- mathjax --><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js" integrity="sha256-nvJJv9wWKEm88qvoQl9ekL2J+k/RWIsaSScxxlsrv8k=" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/config/TeX-AMS-MML_HTMLorMML.js" integrity="sha256-84DKXVJXs0/F8OTMzX4UR909+jtl4G7SPypPavF+GfA=" crossorigin="anonymous"></script><!--[if lt IE 9]> +<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script> +<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> +<![endif]--> +</head> +<body data-spy="scroll" data-target="#toc"> + <div class="container template-article"> + <header><div class="navbar navbar-default navbar-fixed-top" role="navigation"> + <div class="container"> + <div class="navbar-header"> + <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false"> + <span class="sr-only">Toggle navigation</span> + <span class="icon-bar"></span> + <span class="icon-bar"></span> + <span class="icon-bar"></span> + </button> + <span class="navbar-brand"> + <a class="navbar-link" href="../index.html">outbreaker2</a> + <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">1.1.2</span> + </span> + </div> + + <div id="navbar" class="navbar-collapse collapse"> + <ul class="nav navbar-nav"> +<li> + <a href="../index.html"> + <span class="fas fa-home fa-lg"></span> + + </a> +</li> +<li> + <a href="../reference/index.html">Reference</a> +</li> +<li class="dropdown"> + <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"> + Articles + + <span class="caret"></span> + </a> + <ul class="dropdown-menu" role="menu"> +<li> + <a href="../articles/customisation.html">Using custom priors, likelihood, or movements in outbreaker2</a> + </li> + <li> + <a href="../articles/introduction.html">Introduction to outbreaker2</a> + </li> + <li> + <a href="../articles/overview.html">outbreaker2: package overview</a> + </li> + <li> + <a href="../articles/Rcpp_API.html">outbreaker2: Rcpp API</a> + </li> + </ul> +</li> +<li> + <a href="../news/index.html">Changelog</a> +</li> + </ul> +<ul class="nav navbar-nav navbar-right"></ul> +</div> +<!--/.nav-collapse --> + </div> +<!--/.container --> +</div> +<!--/.navbar --> + + + + </header><script src="Rcpp_API_files/header-attrs-2.6/header-attrs.js"></script><script src="Rcpp_API_files/accessible-code-block-0.0.1/empty-anchor.js"></script><div class="row"> + <div class="col-md-9 contents"> + <div class="page-header toc-ignore"> + <h1 data-toc-skip>outbreaker2: Rcpp API</h1> + <h4 class="author">Thibaut Jombart</h4> + + <h4 class="date">2021-02-09</h4> + + + <div class="hidden name"><code>Rcpp_API.Rmd</code></div> + + </div> + + + +<div id="list-of-available-functions" class="section level1"> +<h1 class="hasAnchor"> +<a href="#list-of-available-functions" class="anchor"></a>List of available functions</h1> +<p>The C++ functions bound to R via Rcpp used in <em>outbreaker2</em> for priors, likelihoods and movements are not visible to the user, as they are not exported by the package. However, advanced users can access these functions using <code><a href="../reference/get_cpp_api.html">get_cpp_api()</a></code>, which returns an environment with all relevant functions:</p> +<div class="sourceCode" id="cb1"><pre class="downlit sourceCode r"> +<code class="sourceCode R"><span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va">outbreaker2</span><span class="op">)</span> + +<span class="co">## get all functions in an environment</span> +<span class="va">x</span> <span class="op"><-</span> <span class="fu"><a href="../reference/get_cpp_api.html">get_cpp_api</a></span><span class="op">(</span><span class="op">)</span> +<span class="va">x</span></code></pre></div> +<pre><code>## <environment: 0x0000000022e6d350></code></pre> +<div class="sourceCode" id="cb3"><pre class="downlit sourceCode r"> +<code class="sourceCode R"><span class="co">## check content</span> +<span class="fu"><a href="https://rdrr.io/r/base/ls.html">ls</a></span><span class="op">(</span><span class="va">x</span><span class="op">)</span></code></pre></div> +<pre><code>## [1] "cpp_ll_all" "cpp_ll_contact" +## [3] "cpp_ll_genetic" "cpp_ll_reporting" +## [5] "cpp_ll_timing" "cpp_ll_timing_infections" +## [7] "cpp_ll_timing_sampling" "cpp_move_alpha" +## [9] "cpp_move_eps" "cpp_move_kappa" +## [11] "cpp_move_lambda" "cpp_move_mu" +## [13] "cpp_move_pi" "cpp_move_swap_cases" +## [15] "cpp_move_t_inf" "cpp_prior_all" +## [17] "cpp_prior_eps" "cpp_prior_lambda" +## [19] "cpp_prior_mu" "cpp_prior_pi"</code></pre> +<div class="sourceCode" id="cb5"><pre class="downlit sourceCode r"> +<code class="sourceCode R"><span class="co">## all functions are Rcpp bindings to a C++ function</span> +<span class="va">x</span><span class="op">$</span><span class="va">cpp_ll_all</span></code></pre></div> +<pre><code>## function (data, param, i = NULL, custom_functions = NULL) +## { +## .Call(`_outbreaker2_cpp_ll_all`, data, param, i, custom_functions) +## } +## <bytecode: 0x0000000022e6dd98> +## <environment: namespace:outbreaker2></code></pre> +</div> +<div id="function-signatures" class="section level1"> +<h1 class="hasAnchor"> +<a href="#function-signatures" class="anchor"></a>Function signatures</h1> +<p>These functions take the following arguments:</p> +<div class="sourceCode" id="cb7"><pre class="downlit sourceCode r"> +<code class="sourceCode R"><span class="va">list_args</span> <span class="op"><-</span> <span class="fu"><a href="https://rdrr.io/r/base/lapply.html">lapply</a></span><span class="op">(</span><span class="va">x</span>, <span class="va">args</span><span class="op">)</span><span class="op">[</span><span class="fu"><a href="https://rdrr.io/r/base/ls.html">ls</a></span><span class="op">(</span><span class="va">x</span><span class="op">)</span><span class="op">]</span> +<span class="va">list_args</span></code></pre></div> +<pre><code>## $cpp_ll_all +## function (data, param, i = NULL, custom_functions = NULL) +## NULL +## +## $cpp_ll_contact +## function (data, param, i = NULL, custom_function = NULL) +## NULL +## +## $cpp_ll_genetic +## function (data, param, i = NULL, custom_function = NULL) +## NULL +## +## $cpp_ll_reporting +## function (data, param, i = NULL, custom_function = NULL) +## NULL +## +## $cpp_ll_timing +## function (data, param, i = NULL, custom_functions = NULL) +## NULL +## +## $cpp_ll_timing_infections +## function (data, param, i = NULL, custom_function = NULL) +## NULL +## +## $cpp_ll_timing_sampling +## function (data, param, i = NULL, custom_function = NULL) +## NULL +## +## $cpp_move_alpha +## function (param, data, list_custom_ll = NULL) +## NULL +## +## $cpp_move_eps +## function (param, data, config, custom_ll = NULL, custom_prior = NULL) +## NULL +## +## $cpp_move_kappa +## function (param, data, config, list_custom_ll = NULL) +## NULL +## +## $cpp_move_lambda +## function (param, data, config, custom_ll = NULL, custom_prior = NULL) +## NULL +## +## $cpp_move_mu +## function (param, data, config, custom_ll = NULL, custom_prior = NULL) +## NULL +## +## $cpp_move_pi +## function (param, data, config, custom_ll = NULL, custom_prior = NULL) +## NULL +## +## $cpp_move_swap_cases +## function (param, data, list_custom_ll = NULL) +## NULL +## +## $cpp_move_t_inf +## function (param, data, list_custom_ll = NULL) +## NULL +## +## $cpp_prior_all +## function (param, config, custom_functions = NULL) +## NULL +## +## $cpp_prior_eps +## function (param, config, custom_function = NULL) +## NULL +## +## $cpp_prior_lambda +## function (param, config, custom_function = NULL) +## NULL +## +## $cpp_prior_mu +## function (param, config, custom_function = NULL) +## NULL +## +## $cpp_prior_pi +## function (param, config, custom_function = NULL) +## NULL</code></pre> +<p>Arguments are detailed in the next section.</p> +</div> +<div id="arguments" class="section level1"> +<h1 class="hasAnchor"> +<a href="#arguments" class="anchor"></a>Arguments</h1> +<p>Arguments of the Rcpp-bound C++ functions are:</p> +<div class="sourceCode" id="cb9"><pre class="downlit sourceCode r"> +<code class="sourceCode R"><span class="va">list_formals</span> <span class="op"><-</span> <span class="fu"><a href="https://rdrr.io/r/base/lapply.html">lapply</a></span><span class="op">(</span><span class="va">x</span>, <span class="va">formals</span><span class="op">)</span> +<span class="va">args</span> <span class="op"><-</span> <span class="fu"><a href="https://rdrr.io/r/base/sort.html">sort</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/unique.html">unique</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/unlist.html">unlist</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/lapply.html">lapply</a></span><span class="op">(</span><span class="va">list_formals</span>, <span class="va">names</span><span class="op">)</span><span class="op">)</span><span class="op">)</span><span class="op">)</span> +<span class="va">args</span></code></pre></div> +<pre><code>## [1] "config" "custom_function" "custom_functions" "custom_ll" +## [5] "custom_prior" "data" "i" "list_custom_ll" +## [9] "param"</code></pre> +<ul> +<li><p><strong><code>alpha</code></strong>: a vector of integers of length ‘N’ (number of cases), indicating infectors of each case, with values from 1 to N; missing values should be <code>NA</code></p></li> +<li><p><strong><code>config</code></strong>: a list containing configuration settings as returned by <code>create_config</code></p></li> +<li><p><strong><code>custom_function</code></strong>: a R function for a custom prior, with a single argument, which must be a list of parameters and augmented data with the class <code>outbreaker_param</code>; returned values must be <strong>on the log scale</strong></p></li> +<li><p><strong><code>custom_functions</code></strong>: a list of R functions obeying the rules of <code>custom_function</code>, named according to the priors; currently available names are:</p></li> +</ul> +<pre><code>## [1] "eps" "lambda" "mu" "pi"</code></pre> +<ul> +<li><p><strong><code>custom_ll</code></strong>: a R function for a custom likelihood, taking two arguments: <code>data</code> (see <code>data</code>), and <code>param</code> (see <code>param</code>)</p></li> +<li><p><strong><code>custom_prior</code></strong>: same as <code>custom_function</code></p></li> +<li><p><strong><code>data</code></strong>: a valid ‘outbreaker_data’ list</p></li> +<li><p><strong><code>i</code></strong>: an integer scalar indicating the index of a case, from 1 to N (number of cases)</p></li> +<li><p><strong><code>list_custom_ll</code></strong>: a list of R functions obeying the rules of <code>custom_ll</code>, named according to the computed likelihood component; available names are:</p></li> +</ul> +<pre><code>## [1] "contact" "genetic" "reporting" +## [4] "timing_infections" "timing_sampling"</code></pre> +<ul> +<li><p><strong><code>param</code></strong>: a list containing parameters and augmented data with the class <code>outbreaker_param</code></p></li> +<li><p><strong><code>t_inf</code></strong>: a vector of integers of length N (number of cases), indicating infection dates of each case; missing values should be <code>NA</code></p></li> +<li><p><strong><code>x</code></strong>: a vector of integers to be sampled from</p></li> +</ul> +</div> + </div> + + <div class="col-md-3 hidden-xs hidden-sm" id="pkgdown-sidebar"> + + <nav id="toc" data-toggle="toc"><h2 data-toc-skip>Contents</h2> + </nav> +</div> + +</div> + + + + <footer><div class="copyright"> + <p>Developed by Thibaut Jombart, Finlay Campbell, Rich Fitzjohn.</p> +</div> + +<div class="pkgdown"> + <p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.6.1.</p> +</div> + + </footer> +</div> + + + + + </body> +</html>