1
0
mirror of https://github.com/msberends/AMR.git synced 2024-12-27 06:46:12 +01:00
AMR/docs/articles/resistance_predict.html

387 lines
25 KiB
HTML
Raw Normal View History

2019-02-11 10:27:10 +01:00
<!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>How to predict antimicrobial resistance • AMR (for R)</title>
2019-02-11 10:27:10 +01:00
<!-- favicons --><link rel="icon" type="image/png" sizes="16x16" href="../favicon-16x16.png">
<link rel="icon" type="image/png" sizes="32x32" href="../favicon-32x32.png">
<link rel="apple-touch-icon" type="image/png" sizes="180x180" href="../apple-touch-icon.png">
<link rel="apple-touch-icon" type="image/png" sizes="120x120" href="../apple-touch-icon-120x120.png">
<link rel="apple-touch-icon" type="image/png" sizes="76x76" href="../apple-touch-icon-76x76.png">
<link rel="apple-touch-icon" type="image/png" sizes="60x60" href="../apple-touch-icon-60x60.png">
2020-12-27 00:07:00 +01:00
<!-- jquery --><script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script><!-- Bootstrap --><link href="https://cdnjs.cloudflare.com/ajax/libs/bootswatch/3.4.0/flatly/bootstrap.min.css" rel="stylesheet" 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">
2020-04-17 19:16:30 +02:00
<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">
2020-02-23 20:56:11 +01:00
<script src="../pkgdown.js"></script><link href="../extra.css" rel="stylesheet">
2019-02-11 10:27:10 +01:00
<script src="../extra.js"></script><meta property="og:title" content="How to predict antimicrobial resistance">
2020-04-13 21:09:56 +02:00
<meta property="og:description" content="AMR">
2020-10-04 19:26:43 +02:00
<meta property="og:image" content="https://msberends.github.io/AMR/logo.png">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:creator" content="@msberends">
<meta name="twitter:site" content="@univgroningen">
2019-02-11 10:27:10 +01:00
<!-- 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>
2020-04-17 19:16:30 +02:00
<body data-spy="scroll" data-target="#toc">
2019-02-11 10:27:10 +01:00
<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">AMR (for R)</a>
2021-08-29 23:50:45 +02:00
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.7.1.9030</span>
2019-02-11 10:27:10 +01:00
</span>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li>
<a href="../index.html">
<span class="fa fa-home"></span>
2019-02-11 10:27:10 +01:00
Home
</a>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
<span class="fa fa-question-circle"></span>
2019-02-11 10:27:10 +01:00
How to
<span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li>
<a href="../articles/AMR.html">
<span class="fa fa-directions"></span>
2019-02-11 10:27:10 +01:00
Conduct AMR analysis
</a>
</li>
<li>
<a href="../articles/resistance_predict.html">
<span class="fa fa-dice"></span>
2019-02-11 10:27:10 +01:00
Predict antimicrobial resistance
</a>
</li>
2020-08-17 21:49:58 +02:00
<li>
<a href="../articles/datasets.html">
<span class="fa fa-database"></span>
2020-08-17 21:49:58 +02:00
Data sets for download / own use
2020-08-17 21:49:58 +02:00
</a>
</li>
2020-04-13 21:09:56 +02:00
<li>
<a href="../articles/PCA.html">
<span class="fa fa-compress"></span>
2020-04-13 21:09:56 +02:00
Conduct principal component analysis for AMR
</a>
</li>
2019-05-23 16:58:59 +02:00
<li>
<a href="../articles/MDR.html">
<span class="fa fa-skull-crossbones"></span>
2019-05-23 16:58:59 +02:00
Determine multi-drug resistance (MDR)
</a>
</li>
2019-02-11 10:27:10 +01:00
<li>
<a href="../articles/WHONET.html">
<span class="fa fa-globe-americas"></span>
2019-02-11 10:27:10 +01:00
Work with WHONET data
</a>
</li>
2019-02-14 15:18:17 +01:00
<li>
<a href="../articles/SPSS.html">
<span class="fa fa-file-upload"></span>
2019-02-14 15:18:17 +01:00
Import data from SPSS/SAS/Stata
</a>
</li>
2019-02-11 10:27:10 +01:00
<li>
<a href="../articles/EUCAST.html">
<span class="fa fa-exchange-alt"></span>
2019-02-11 10:27:10 +01:00
Apply EUCAST rules
</a>
</li>
<li>
<a href="../reference/mo_property.html">
<span class="fa fa-bug"></span>
2019-02-11 10:27:10 +01:00
Get properties of a microorganism
</a>
</li>
<li>
2019-05-10 16:44:59 +02:00
<a href="../reference/ab_property.html">
<span class="fa fa-capsules"></span>
2019-02-11 10:27:10 +01:00
Get properties of an antibiotic
</a>
</li>
<li>
<a href="../articles/benchmarks.html">
<span class="fa fa-shipping-fast"></span>
2019-02-11 10:27:10 +01:00
Other: benchmarks
</a>
</li>
</ul>
</li>
<li>
2020-07-28 18:39:57 +02:00
<a href="../reference/index.html">
<span class="fa fa-book-open"></span>
2019-02-11 10:27:10 +01:00
Manual
</a>
</li>
<li>
<a href="../authors.html">
<span class="fa fa-users"></span>
2019-02-11 10:27:10 +01:00
Authors
</a>
</li>
<li>
2020-07-28 18:39:57 +02:00
<a href="../news/index.html">
2021-05-24 15:29:17 +02:00
<span class="far fa-newspaper"></span>
2019-02-11 10:27:10 +01:00
Changelog
</a>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li>
<a href="https://github.com/msberends/AMR" class="external-link">
2021-05-24 15:29:17 +02:00
<span class="fab fa-github"></span>
2019-02-11 10:27:10 +01:00
Source Code
</a>
</li>
</ul>
</div>
<!--/.nav-collapse -->
</div>
<!--/.container -->
</div>
<!--/.navbar -->
2019-10-13 09:31:58 +02:00
</header><script src="resistance_predict_files/header-attrs-2.9/header-attrs.js"></script><div class="row">
2019-02-11 10:27:10 +01:00
<div class="col-md-9 contents">
<div class="page-header toc-ignore">
2020-04-17 19:16:30 +02:00
<h1 data-toc-skip>How to predict antimicrobial resistance</h1>
2019-02-11 10:27:10 +01:00
<small class="dont-index">Source: <a href="https://github.com/msberends/AMR/blob/master/vignettes/resistance_predict.Rmd" class="external-link"><code>vignettes/resistance_predict.Rmd</code></a></small>
2019-02-11 10:27:10 +01:00
<div class="hidden name"><code>resistance_predict.Rmd</code></div>
</div>
<div id="needed-r-packages" class="section level2">
<h2 class="hasAnchor">
<a href="#needed-r-packages" class="anchor" aria-hidden="true"></a>Needed R packages</h2>
<p>As with many uses in R, we need some additional packages for AMR data analysis. Our package works closely together with the <a href="https://www.tidyverse.org" class="external-link">tidyverse packages</a> <a href="https://dplyr.tidyverse.org/" class="external-link"><code>dplyr</code></a> and <a href="https://ggplot2.tidyverse.org" class="external-link"><code>ggplot2</code></a> by Dr Hadley Wickham. The tidyverse tremendously improves the way we conduct data science - it allows for a very natural way of writing syntaxes and creating beautiful plots in R.</p>
2019-02-11 10:27:10 +01:00
<p>Our <code>AMR</code> package depends on these packages and even extends their use and functions.</p>
2021-05-24 15:29:17 +02:00
<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" class="external-link">library</a></span><span class="op">(</span><span class="va"><a href="https://dplyr.tidyverse.org" class="external-link">dplyr</a></span><span class="op">)</span>
<span class="kw"><a href="https://rdrr.io/r/base/library.html" class="external-link">library</a></span><span class="op">(</span><span class="va"><a href="https://ggplot2.tidyverse.org" class="external-link">ggplot2</a></span><span class="op">)</span>
<span class="kw"><a href="https://rdrr.io/r/base/library.html" class="external-link">library</a></span><span class="op">(</span><span class="va"><a href="https://github.com/msberends/AMR" class="external-link">AMR</a></span><span class="op">)</span>
2020-04-17 19:16:30 +02:00
<span class="co"># (if not yet installed, install with:)</span>
2021-05-24 15:29:17 +02:00
<span class="co"># install.packages(c("tidyverse", "AMR"))</span></code></pre></div>
2019-02-11 10:27:10 +01:00
</div>
<div id="prediction-analysis" class="section level2">
<h2 class="hasAnchor">
<a href="#prediction-analysis" class="anchor" aria-hidden="true"></a>Prediction analysis</h2>
<p>Our package contains a function <code><a href="../reference/resistance_predict.html">resistance_predict()</a></code>, which takes the same input as functions for <a href="./AMR.html">other AMR data analysis</a>. Based on a date column, it calculates cases per year and uses a regression model to predict antimicrobial resistance.</p>
2019-02-11 10:27:10 +01:00
<p>It is basically as easy as:</p>
2021-05-24 15:29:17 +02:00
<div class="sourceCode" id="cb2"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="co"># resistance prediction of piperacillin/tazobactam (TZP):</span></span>
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a><span class="fu">resistance_predict</span>(<span class="at">tbl =</span> example_isolates, <span class="at">col_date =</span> <span class="st">"date"</span>, <span class="at">col_ab =</span> <span class="st">"TZP"</span>, <span class="at">model =</span> <span class="st">"binomial"</span>)</span>
<span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-4"><a href="#cb2-4" aria-hidden="true" tabindex="-1"></a><span class="co"># or:</span></span>
<span id="cb2-5"><a href="#cb2-5" aria-hidden="true" tabindex="-1"></a>example_isolates <span class="sc">%&gt;%</span> </span>
<span id="cb2-6"><a href="#cb2-6" aria-hidden="true" tabindex="-1"></a> <span class="fu">resistance_predict</span>(<span class="at">col_ab =</span> <span class="st">"TZP"</span>,</span>
<span id="cb2-7"><a href="#cb2-7" aria-hidden="true" tabindex="-1"></a> model <span class="st">"binomial"</span>)</span>
<span id="cb2-8"><a href="#cb2-8" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-9"><a href="#cb2-9" aria-hidden="true" tabindex="-1"></a><span class="co"># to bind it to object 'predict_TZP' for example:</span></span>
<span id="cb2-10"><a href="#cb2-10" aria-hidden="true" tabindex="-1"></a>predict_TZP <span class="ot">&lt;-</span> example_isolates <span class="sc">%&gt;%</span> </span>
<span id="cb2-11"><a href="#cb2-11" aria-hidden="true" tabindex="-1"></a> <span class="fu">resistance_predict</span>(<span class="at">col_ab =</span> <span class="st">"TZP"</span>,</span>
<span id="cb2-12"><a href="#cb2-12" aria-hidden="true" tabindex="-1"></a> <span class="at">model =</span> <span class="st">"binomial"</span>)</span></code></pre></div>
2019-02-11 10:27:10 +01:00
<p>The function will look for a date column itself if <code>col_date</code> is not set.</p>
<p>When running any of these commands, a summary of the regression model will be printed unless using <code><a href="../reference/resistance_predict.html">resistance_predict(..., info = FALSE)</a></code>.</p>
2021-04-27 10:27:13 +02:00
<pre><code># Using column 'date' as input for `col_date`.</code></pre>
2019-02-11 10:27:10 +01:00
<p>This text is only a printed summary - the actual result (output) of the function is a <code>data.frame</code> containing for each year: the number of observations, the actual observed resistance, the estimated resistance and the standard error below and above the estimation:</p>
2021-05-24 15:29:17 +02:00
<div class="sourceCode" id="cb4"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">predict_TZP</span>
2020-04-17 19:16:30 +02:00
<span class="co"># year value se_min se_max observations observed estimated</span>
2020-05-25 01:01:14 +02:00
<span class="co"># 1 2002 0.20000000 NA NA 15 0.20000000 0.05616378</span>
<span class="co"># 2 2003 0.06250000 NA NA 32 0.06250000 0.06163839</span>
<span class="co"># 3 2004 0.08536585 NA NA 82 0.08536585 0.06760841</span>
<span class="co"># 4 2005 0.05000000 NA NA 60 0.05000000 0.07411100</span>
<span class="co"># 5 2006 0.05084746 NA NA 59 0.05084746 0.08118454</span>
<span class="co"># 6 2007 0.12121212 NA NA 66 0.12121212 0.08886843</span>
<span class="co"># 7 2008 0.04166667 NA NA 72 0.04166667 0.09720264</span>
<span class="co"># 8 2009 0.01639344 NA NA 61 0.01639344 0.10622731</span>
<span class="co"># 9 2010 0.05660377 NA NA 53 0.05660377 0.11598223</span>
<span class="co"># 10 2011 0.18279570 NA NA 93 0.18279570 0.12650615</span>
<span class="co"># 11 2012 0.30769231 NA NA 65 0.30769231 0.13783610</span>
<span class="co"># 12 2013 0.06896552 NA NA 58 0.06896552 0.15000651</span>
<span class="co"># 13 2014 0.10000000 NA NA 60 0.10000000 0.16304829</span>
<span class="co"># 14 2015 0.23636364 NA NA 55 0.23636364 0.17698785</span>
<span class="co"># 15 2016 0.22619048 NA NA 84 0.22619048 0.19184597</span>
<span class="co"># 16 2017 0.16279070 NA NA 86 0.16279070 0.20763675</span>
<span class="co"># 17 2018 0.22436641 0.1938710 0.2548618 NA NA 0.22436641</span>
<span class="co"># 18 2019 0.24203228 0.2062911 0.2777735 NA NA 0.24203228</span>
<span class="co"># 19 2020 0.26062172 0.2191758 0.3020676 NA NA 0.26062172</span>
<span class="co"># 20 2021 0.28011130 0.2325557 0.3276669 NA NA 0.28011130</span>
<span class="co"># 21 2022 0.30046606 0.2464567 0.3544755 NA NA 0.30046606</span>
<span class="co"># 22 2023 0.32163907 0.2609011 0.3823771 NA NA 0.32163907</span>
<span class="co"># 23 2024 0.34357130 0.2759081 0.4112345 NA NA 0.34357130</span>
<span class="co"># 24 2025 0.36619175 0.2914934 0.4408901 NA NA 0.36619175</span>
<span class="co"># 25 2026 0.38941799 0.3076686 0.4711674 NA NA 0.38941799</span>
<span class="co"># 26 2027 0.41315710 0.3244399 0.5018743 NA NA 0.41315710</span>
<span class="co"># 27 2028 0.43730688 0.3418075 0.5328063 NA NA 0.43730688</span>
<span class="co"># 28 2029 0.46175755 0.3597639 0.5637512 NA NA 0.46175755</span>
<span class="co"># 29 2030 0.48639359 0.3782932 0.5944939 NA NA 0.48639359</span>
2021-05-24 15:29:17 +02:00
<span class="co"># 30 2031 0.51109592 0.3973697 0.6248221 NA NA 0.51109592</span></code></pre></div>
2019-02-11 10:27:10 +01:00
<p>The function <code>plot</code> is available in base R, and can be extended by other packages to depend the output based on the type of input. We extended its function to cope with resistance predictions:</p>
2021-05-24 15:29:17 +02:00
<div class="sourceCode" id="cb5"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu"><a href="../reference/plot.html">plot</a></span><span class="op">(</span><span class="va">predict_TZP</span><span class="op">)</span></code></pre></div>
2019-02-11 10:27:10 +01:00
<p><img src="resistance_predict_files/figure-html/unnamed-chunk-4-1.png" width="720"></p>
<p>This is the fastest way to plot the result. It automatically adds the right axes, error bars, titles, number of available observations and type of model.</p>
<p>We also support the <code>ggplot2</code> package with our custom function <code><a href="../reference/resistance_predict.html">ggplot_rsi_predict()</a></code> to create more appealing plots:</p>
2021-05-24 15:29:17 +02:00
<div class="sourceCode" id="cb6"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu"><a href="../reference/resistance_predict.html">ggplot_rsi_predict</a></span><span class="op">(</span><span class="va">predict_TZP</span><span class="op">)</span></code></pre></div>
2019-02-11 10:27:10 +01:00
<p><img src="resistance_predict_files/figure-html/unnamed-chunk-5-1.png" width="720"></p>
2021-05-24 15:29:17 +02:00
<div class="sourceCode" id="cb7"><pre class="downlit sourceCode r">
<code class="sourceCode R">
2020-04-17 19:16:30 +02:00
<span class="co"># choose for error bars instead of a ribbon</span>
2021-05-24 15:29:17 +02:00
<span class="fu"><a href="../reference/resistance_predict.html">ggplot_rsi_predict</a></span><span class="op">(</span><span class="va">predict_TZP</span>, ribbon <span class="op">=</span> <span class="cn">FALSE</span><span class="op">)</span></code></pre></div>
2019-02-11 10:27:10 +01:00
<p><img src="resistance_predict_files/figure-html/unnamed-chunk-5-2.png" width="720"></p>
<div id="choosing-the-right-model" class="section level3">
<h3 class="hasAnchor">
<a href="#choosing-the-right-model" class="anchor" aria-hidden="true"></a>Choosing the right model</h3>
2020-05-25 01:01:14 +02:00
<p>Resistance is not easily predicted; if we look at vancomycin resistance in Gram-positive bacteria, the spread (i.e. standard error) is enormous:</p>
2021-05-24 15:29:17 +02:00
<div class="sourceCode" id="cb8"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">example_isolates</span> <span class="op">%&gt;%</span>
<span class="fu"><a href="https://dplyr.tidyverse.org/reference/filter.html" class="external-link">filter</a></span><span class="op">(</span><span class="fu"><a href="../reference/mo_property.html">mo_gramstain</a></span><span class="op">(</span><span class="va">mo</span>, language <span class="op">=</span> <span class="cn">NULL</span><span class="op">)</span> <span class="op">==</span> <span class="st">"Gram-positive"</span><span class="op">)</span> <span class="op">%&gt;%</span>
2020-10-26 12:23:03 +01:00
<span class="fu"><a href="../reference/resistance_predict.html">resistance_predict</a></span><span class="op">(</span>col_ab <span class="op">=</span> <span class="st">"VAN"</span>, year_min <span class="op">=</span> <span class="fl">2010</span>, info <span class="op">=</span> <span class="cn">FALSE</span>, model <span class="op">=</span> <span class="st">"binomial"</span><span class="op">)</span> <span class="op">%&gt;%</span>
2021-05-24 15:29:17 +02:00
<span class="fu"><a href="../reference/resistance_predict.html">ggplot_rsi_predict</a></span><span class="op">(</span><span class="op">)</span>
<span class="co"># Using column 'date' as input for `col_date`.</span></code></pre></div>
2019-02-11 10:27:10 +01:00
<p><img src="resistance_predict_files/figure-html/unnamed-chunk-6-1.png" width="720"></p>
<p>Vancomycin resistance could be 100% in ten years, but might also stay around 0%.</p>
2019-08-08 15:52:07 +02:00
<p>You can define the model with the <code>model</code> parameter. The model chosen above is a generalised linear regression model using a binomial distribution, assuming that a period of zero resistance was followed by a period of increasing resistance leading slowly to more and more resistance.</p>
2019-02-11 10:27:10 +01:00
<p>Valid values are:</p>
<table class="table">
<colgroup>
<col width="32%">
<col width="25%">
<col width="42%">
</colgroup>
<thead><tr class="header">
<th>Input values</th>
<th>Function used by R</th>
<th>Type of model</th>
</tr></thead>
<tbody>
<tr class="odd">
<td>
<code>"binomial"</code> or <code>"binom"</code> or <code>"logit"</code>
</td>
<td><code><a href="https://rdrr.io/r/stats/glm.html" class="external-link">glm(..., family = binomial)</a></code></td>
2019-02-11 10:27:10 +01:00
<td>Generalised linear model with binomial distribution</td>
</tr>
<tr class="even">
<td>
<code>"loglin"</code> or <code>"poisson"</code>
</td>
<td><code><a href="https://rdrr.io/r/stats/glm.html" class="external-link">glm(..., family = poisson)</a></code></td>
2019-02-11 10:27:10 +01:00
<td>Generalised linear model with poisson distribution</td>
</tr>
<tr class="odd">
<td>
<code>"lin"</code> or <code>"linear"</code>
</td>
<td><code><a href="https://rdrr.io/r/stats/lm.html" class="external-link">lm()</a></code></td>
2019-02-11 10:27:10 +01:00
<td>Linear model</td>
</tr>
</tbody>
</table>
2020-05-25 01:01:14 +02:00
<p>For the vancomycin resistance in Gram-positive bacteria, a linear model might be more appropriate since no binomial distribution is to be expected based on the observed years:</p>
2021-05-24 15:29:17 +02:00
<div class="sourceCode" id="cb9"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">example_isolates</span> <span class="op">%&gt;%</span>
<span class="fu"><a href="https://dplyr.tidyverse.org/reference/filter.html" class="external-link">filter</a></span><span class="op">(</span><span class="fu"><a href="../reference/mo_property.html">mo_gramstain</a></span><span class="op">(</span><span class="va">mo</span>, language <span class="op">=</span> <span class="cn">NULL</span><span class="op">)</span> <span class="op">==</span> <span class="st">"Gram-positive"</span><span class="op">)</span> <span class="op">%&gt;%</span>
2020-10-26 12:23:03 +01:00
<span class="fu"><a href="../reference/resistance_predict.html">resistance_predict</a></span><span class="op">(</span>col_ab <span class="op">=</span> <span class="st">"VAN"</span>, year_min <span class="op">=</span> <span class="fl">2010</span>, info <span class="op">=</span> <span class="cn">FALSE</span>, model <span class="op">=</span> <span class="st">"linear"</span><span class="op">)</span> <span class="op">%&gt;%</span>
2021-05-24 15:29:17 +02:00
<span class="fu"><a href="../reference/resistance_predict.html">ggplot_rsi_predict</a></span><span class="op">(</span><span class="op">)</span>
<span class="co"># Using column 'date' as input for `col_date`.</span></code></pre></div>
2019-02-11 10:27:10 +01:00
<p><img src="resistance_predict_files/figure-html/unnamed-chunk-7-1.png" width="720"></p>
<p>This seems more likely, doesnt it?</p>
<p>The model itself is also available from the object, as an <code>attribute</code>:</p>
2021-05-24 15:29:17 +02:00
<div class="sourceCode" id="cb10"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">model</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/attributes.html" class="external-link">attributes</a></span><span class="op">(</span><span class="va">predict_TZP</span><span class="op">)</span><span class="op">$</span><span class="va">model</span>
2020-04-17 19:16:30 +02:00
<span class="fu"><a href="https://rdrr.io/r/base/summary.html" class="external-link">summary</a></span><span class="op">(</span><span class="va">model</span><span class="op">)</span><span class="op">$</span><span class="va">family</span>
2020-04-17 19:16:30 +02:00
<span class="co"># </span>
<span class="co"># Family: binomial </span>
<span class="co"># Link function: logit</span>
<span class="fu"><a href="https://rdrr.io/r/base/summary.html" class="external-link">summary</a></span><span class="op">(</span><span class="va">model</span><span class="op">)</span><span class="op">$</span><span class="va">coefficients</span>
2020-05-25 01:01:14 +02:00
<span class="co"># Estimate Std. Error z value Pr(&gt;|z|)</span>
<span class="co"># (Intercept) -200.67944891 46.17315349 -4.346237 1.384932e-05</span>
2021-05-24 15:29:17 +02:00
<span class="co"># year 0.09883005 0.02295317 4.305725 1.664395e-05</span></code></pre></div>
2019-02-11 10:27:10 +01:00
</div>
</div>
</div>
2020-04-13 21:09:56 +02:00
<div class="col-md-3 hidden-xs hidden-sm" id="pkgdown-sidebar">
2019-10-13 09:31:58 +02:00
2020-04-17 19:16:30 +02:00
<nav id="toc" data-toggle="toc"><h2 data-toc-skip>Contents</h2>
</nav>
2019-02-11 10:27:10 +01:00
</div>
</div>
2019-10-13 09:31:58 +02:00
2019-02-11 10:27:10 +01:00
<footer><div class="copyright">
<p></p>
<p>Developed by <a href="https://www.rug.nl/staff/m.s.berends/" class="external-link external-link">Matthijs S. Berends</a>, <a href="https://www.rug.nl/staff/c.f.luz/" class="external-link external-link">Christian F. Luz</a>, <a href="https://www.rug.nl/staff/a.w.friedrich/" class="external-link external-link">Alexander W. Friedrich</a>, <a href="https://www.rug.nl/staff/b.sinha/" class="external-link external-link">Bhanu N. M. Sinha</a>, <a href="https://www.rug.nl/staff/c.j.albers/" class="external-link external-link">Casper J. Albers</a>, <a href="https://www.rug.nl/staff/c.glasner/" class="external-link external-link">Corinna Glasner</a>.</p>
2019-02-11 10:27:10 +01:00
</div>
<div class="pkgdown">
<p></p>
<p>Site built with <a href="https://pkgdown.r-lib.org/" class="external-link external-link">pkgdown</a> 1.6.1.9001.</p>
2019-02-11 10:27:10 +01:00
</div>
2019-10-13 09:31:58 +02:00
2019-02-11 10:27:10 +01:00
</footer>
</div>
2020-02-23 20:56:11 +01:00
2020-02-23 20:56:11 +01:00
</body>
2019-02-11 10:27:10 +01:00
</html>