<scriptsrc="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js"integrity="sha256-U5ZEeKfGNOja007MMD3YBI0A3OSZOQbeG6z2f2Y0hu8="crossorigin="anonymous"></script><!-- Font Awesome icons --><linkrel="stylesheet"href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"integrity="sha256-eZrrJcwDc/3uDhsdt61sL2oOBY362qM3lon1gyExkL0="crossorigin="anonymous">
<p>As with many uses in R, we need some additional packages for AMR analysis. Our package works closely together with the <ahref="https://www.tidyverse.org">tidyverse packages</a><ahref="https://dplyr.tidyverse.org/"><code>dplyr</code></a> and <ahref="https://ggplot2.tidyverse.org"><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>
<p>Our package contains a function <code><ahref="../reference/resistance_predict.html">resistance_predict()</a></code>, which takes the same input as functions for <ahref="./AMR.html">other AMR analysis</a>. Based on a date column, it calculates cases per year and uses a regression model to predict antimicrobial resistance.</p>
<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><ahref="../reference/resistance_predict.html">resistance_predict(..., info = FALSE)</a></code>.</p>
<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>
<aclass="sourceLine"id="cb4-2"data-line-number="2"><spanclass="co"># year value se_min se_max observations observed estimated</span></a>
<aclass="sourceLine"id="cb4-3"data-line-number="3"><spanclass="co"># 1 2003 0.06250000 NA NA 32 0.06250000 0.05486389</span></a>
<aclass="sourceLine"id="cb4-4"data-line-number="4"><spanclass="co"># 2 2004 0.08536585 NA NA 82 0.08536585 0.06089002</span></a>
<aclass="sourceLine"id="cb4-5"data-line-number="5"><spanclass="co"># 3 2005 0.05000000 NA NA 60 0.05000000 0.06753075</span></a>
<aclass="sourceLine"id="cb4-6"data-line-number="6"><spanclass="co"># 4 2006 0.05084746 NA NA 59 0.05084746 0.07483801</span></a>
<aclass="sourceLine"id="cb4-7"data-line-number="7"><spanclass="co"># 5 2007 0.12121212 NA NA 66 0.12121212 0.08286570</span></a>
<aclass="sourceLine"id="cb4-8"data-line-number="8"><spanclass="co"># 6 2008 0.04166667 NA NA 72 0.04166667 0.09166918</span></a>
<aclass="sourceLine"id="cb4-9"data-line-number="9"><spanclass="co"># 7 2009 0.01639344 NA NA 61 0.01639344 0.10130461</span></a>
<aclass="sourceLine"id="cb4-10"data-line-number="10"><spanclass="co"># 8 2010 0.05660377 NA NA 53 0.05660377 0.11182814</span></a>
<aclass="sourceLine"id="cb4-11"data-line-number="11"><spanclass="co"># 9 2011 0.18279570 NA NA 93 0.18279570 0.12329488</span></a>
<aclass="sourceLine"id="cb4-12"data-line-number="12"><spanclass="co"># 10 2012 0.30769231 NA NA 65 0.30769231 0.13575768</span></a>
<aclass="sourceLine"id="cb4-13"data-line-number="13"><spanclass="co"># 11 2013 0.06896552 NA NA 58 0.06896552 0.14926576</span></a>
<aclass="sourceLine"id="cb4-14"data-line-number="14"><spanclass="co"># 12 2014 0.10000000 NA NA 60 0.10000000 0.16386307</span></a>
<aclass="sourceLine"id="cb4-15"data-line-number="15"><spanclass="co"># 13 2015 0.23636364 NA NA 55 0.23636364 0.17958657</span></a>
<aclass="sourceLine"id="cb4-16"data-line-number="16"><spanclass="co"># 14 2016 0.22619048 NA NA 84 0.22619048 0.19646431</span></a>
<aclass="sourceLine"id="cb4-17"data-line-number="17"><spanclass="co"># 15 2017 0.16279070 NA NA 86 0.16279070 0.21451350</span></a>
<aclass="sourceLine"id="cb4-18"data-line-number="18"><spanclass="co"># 16 2018 0.23373852 0.2021578 0.2653193 NA NA 0.23373852</span></a>
<aclass="sourceLine"id="cb4-19"data-line-number="19"><spanclass="co"># 17 2019 0.25412909 0.2168525 0.2914057 NA NA 0.25412909</span></a>
<aclass="sourceLine"id="cb4-20"data-line-number="20"><spanclass="co"># 18 2020 0.27565854 0.2321869 0.3191302 NA NA 0.27565854</span></a>
<aclass="sourceLine"id="cb4-21"data-line-number="21"><spanclass="co"># 19 2021 0.29828252 0.2481942 0.3483709 NA NA 0.29828252</span></a>
<aclass="sourceLine"id="cb4-22"data-line-number="22"><spanclass="co"># 20 2022 0.32193804 0.2649008 0.3789753 NA NA 0.32193804</span></a>
<aclass="sourceLine"id="cb4-23"data-line-number="23"><spanclass="co"># 21 2023 0.34654311 0.2823269 0.4107593 NA NA 0.34654311</span></a>
<aclass="sourceLine"id="cb4-24"data-line-number="24"><spanclass="co"># 22 2024 0.37199700 0.3004860 0.4435080 NA NA 0.37199700</span></a>
<aclass="sourceLine"id="cb4-25"data-line-number="25"><spanclass="co"># 23 2025 0.39818127 0.3193839 0.4769787 NA NA 0.39818127</span></a>
<aclass="sourceLine"id="cb4-26"data-line-number="26"><spanclass="co"># 24 2026 0.42496142 0.3390173 0.5109056 NA NA 0.42496142</span></a>
<aclass="sourceLine"id="cb4-27"data-line-number="27"><spanclass="co"># 25 2027 0.45218939 0.3593720 0.5450068 NA NA 0.45218939</span></a>
<aclass="sourceLine"id="cb4-28"data-line-number="28"><spanclass="co"># 26 2028 0.47970658 0.3804212 0.5789920 NA NA 0.47970658</span></a>
<aclass="sourceLine"id="cb4-29"data-line-number="29"><spanclass="co"># 27 2029 0.50734745 0.4021241 0.6125708 NA NA 0.50734745</span></a></code></pre></div>
<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>
<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><ahref="../reference/resistance_predict.html">ggplot_rsi_predict()</a></code> to create more appealing plots:</p>
<aclass="sourceLine"id="cb8-5"data-line-number="5"><spanclass="co"># </span><spanclass="al">NOTE</span><spanclass="co">: Using column `date` as input for `col_date`.</span></a></code></pre></div>
<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>
<p>For the vancomycin resistance in Gram positive bacteria, a linear model might be more appropriate since no (left half of a) binomial distribution is to be expected based on the observed years:</p>
<aclass="sourceLine"id="cb9-5"data-line-number="5"><spanclass="co"># </span><spanclass="al">NOTE</span><spanclass="co">: Using column `date` as input for `col_date`.</span></a></code></pre></div>
<p>Developed by <ahref="https://www.rug.nl/staff/m.s.berends/">Matthijs S. Berends</a>, <ahref="https://www.rug.nl/staff/c.f.luz/">Christian F. Luz</a>, <ahref="https://www.rug.nl/staff/a.w.friedrich/">Alex W. Friedrich</a>, <ahref="https://www.rug.nl/staff/b.sinha/">Bhanu N. M. Sinha</a>, <ahref="https://www.rug.nl/staff/c.j.albers/">Casper J. Albers</a>, <ahref="https://www.rug.nl/staff/c.glasner/">Corinna Glasner</a>.</p>