1
0
mirror of https://github.com/msberends/AMR.git synced 2025-07-13 05:21:50 +02:00

new antibiotics

This commit is contained in:
2019-05-10 16:44:59 +02:00
parent 73f1ee1159
commit 68cc7ef0d0
147 changed files with 6228 additions and 4187 deletions

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 69 KiB

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 51 KiB

After

Width:  |  Height:  |  Size: 50 KiB

View File

@ -40,7 +40,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.6.1.9002</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.6.1.9003</span>
</span>
</div>
@ -105,7 +105,7 @@
</a>
</li>
<li>
<a href="../reference/atc_property.html">
<a href="../reference/ab_property.html">
<span class="fa fa-capsules"></span>
Get properties of an antibiotic
@ -192,7 +192,7 @@
<h1>How to import data from SPSS / SAS / Stata</h1>
<h4 class="author">Matthijs S. Berends</h4>
<h4 class="date">05 April 2019</h4>
<h4 class="date">10 May 2019</h4>
<div class="hidden name"><code>SPSS.Rmd</code></div>
@ -240,7 +240,7 @@
<p>If you are working at a midsized or small company, you can save it tens of thousands of dollars by using R instead of e.g. SPSS - gaining even more functions and flexibility. And all R enthousiasts can do as much PR as they want (like I do here), because nobody is officially associated with or affiliated by R. It is really free.</p>
</li>
</ul>
<p>If you sometimes write syntaxes in SPSS to run a complete analysis or to automate some of your work, you should perhaps do this in R. You will notice that writing syntaxes in R is a lot more nifty and clever than in SPSS.</p>
<p>If you sometimes write syntaxes in SPSS to run a complete analysis or to automate some of your work, you should perhaps do this in R. You will notice that writing syntaxes in R is a lot more nifty and clever than in SPSS. Still, as working with any statistical package, you will have to have knowledge about what you are doing (statistically) and what you are willing to accomplish.</p>
<p>To demonstrate the first point:</p>
<div class="sourceCode" id="cb1"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb1-1" title="1"><span class="co"># not all values are valid MIC values:</span></a>
<a class="sourceLine" id="cb1-2" title="2"><span class="kw"><a href="../reference/as.mic.html">as.mic</a></span>(<span class="fl">0.125</span>)</a>
@ -265,14 +265,17 @@
<a class="sourceLine" id="cb1-21" title="21"><span class="co">#&gt; mo amox</span></a>
<a class="sourceLine" id="cb1-22" title="22"><span class="co">#&gt; 1 klebsiella R</span></a>
<a class="sourceLine" id="cb1-23" title="23"></a>
<a class="sourceLine" id="cb1-24" title="24"><span class="co"># hundreds of trade names can be translated to an ATC or name:</span></a>
<a class="sourceLine" id="cb1-25" title="25"><span class="kw"><a href="../reference/atc_property.html">atc_name</a></span>(<span class="st">"floxapen"</span>)</a>
<a class="sourceLine" id="cb1-24" title="24"><span class="co"># hundreds of trade names can be translated to a name, trade name or an ATC code:</span></a>
<a class="sourceLine" id="cb1-25" title="25"><span class="kw"><a href="../reference/ab_property.html">ab_name</a></span>(<span class="st">"floxapen"</span>)</a>
<a class="sourceLine" id="cb1-26" title="26"><span class="co">#&gt; [1] "Flucloxacillin"</span></a>
<a class="sourceLine" id="cb1-27" title="27"><span class="kw"><a href="../reference/as.atc.html">as.atc</a></span>(<span class="st">"floxapen"</span>)</a>
<a class="sourceLine" id="cb1-28" title="28"><span class="co">#&gt; Class 'atc'</span></a>
<a class="sourceLine" id="cb1-29" title="29"><span class="co">#&gt; [1] J01CF05</span></a>
<a class="sourceLine" id="cb1-30" title="30"><span class="kw"><a href="../reference/atc_property.html">atc_tradenames</a></span>(<span class="st">"floxapen"</span>)</a>
<a class="sourceLine" id="cb1-31" title="31"><span class="co">#&gt; [1] "Flopen" "Floxapen" "Fluclox" "Sesamol" "Softapen" "Staphylex"</span></a></code></pre></div>
<a class="sourceLine" id="cb1-27" title="27"><span class="kw"><a href="../reference/ab_property.html">ab_tradenames</a></span>(<span class="st">"floxapen"</span>)</a>
<a class="sourceLine" id="cb1-28" title="28"><span class="co">#&gt; [1] "Floxacillin" "FLOXACILLIN" "Floxapen" </span></a>
<a class="sourceLine" id="cb1-29" title="29"><span class="co">#&gt; [4] "Floxapen sodium salt" "Fluclox" "Flucloxacilina" </span></a>
<a class="sourceLine" id="cb1-30" title="30"><span class="co">#&gt; [7] "Flucloxacillin" "Flucloxacilline" "Flucloxacillinum" </span></a>
<a class="sourceLine" id="cb1-31" title="31"><span class="co">#&gt; [10] "Fluorochloroxacillin"</span></a>
<a class="sourceLine" id="cb1-32" title="32"><span class="kw"><a href="../reference/ab_property.html">ab_atc</a></span>(<span class="st">"floxapen"</span>)</a>
<a class="sourceLine" id="cb1-33" title="33"><span class="co">#&gt; Class 'atc'</span></a>
<a class="sourceLine" id="cb1-34" title="34"><span class="co">#&gt; [1] J01CF05</span></a></code></pre></div>
</div>
<div id="import-data-from-spsssasstata" class="section level2">
<h2 class="hasAnchor">

View File

@ -40,7 +40,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.5.0.9017</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.6.1.9003</span>
</span>
</div>
@ -70,7 +70,7 @@
</a>
</li>
<li>
<a href="../articles/Predict.html">
<a href="../articles/resistance_predict.html">
<span class="fa fa-dice"></span>
Predict antimicrobial resistance
@ -83,6 +83,13 @@
Work with WHONET data
</a>
</li>
<li>
<a href="../articles/SPSS.html">
<span class="fa fa-file-upload"></span>
Import data from SPSS/SAS/Stata
</a>
</li>
<li>
<a href="../articles/EUCAST.html">
<span class="fa fa-exchange-alt"></span>
@ -91,14 +98,14 @@
</a>
</li>
<li>
<a href="../articles/mo_property.html">
<a href="../reference/mo_property.html">
<span class="fa fa-bug"></span>
Get properties of a microorganism
</a>
</li>
<li>
<a href="../articles/ab_property.html">
<a href="../reference/ab_property.html">
<span class="fa fa-capsules"></span>
Get properties of an antibiotic
@ -185,7 +192,7 @@
<h1>How to get properties of an antibiotic</h1>
<h4 class="author">Matthijs S. Berends</h4>
<h4 class="date">09 February 2019</h4>
<h4 class="date">10 May 2019</h4>
<div class="hidden name"><code>ab_property.Rmd</code></div>

View File

@ -40,7 +40,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.6.1.9002</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.6.1.9003</span>
</span>
</div>
@ -105,7 +105,7 @@
</a>
</li>
<li>
<a href="../reference/atc_property.html">
<a href="../reference/ab_property.html">
<span class="fa fa-capsules"></span>
Get properties of an antibiotic
@ -192,7 +192,7 @@
<h1>Benchmarks</h1>
<h4 class="author">Matthijs S. Berends</h4>
<h4 class="date">09 April 2019</h4>
<h4 class="date">10 May 2019</h4>
<div class="hidden name"><code>benchmarks.Rmd</code></div>
@ -217,14 +217,14 @@
<a class="sourceLine" id="cb2-8" title="8"> <span class="dt">times =</span> <span class="dv">10</span>)</a>
<a class="sourceLine" id="cb2-9" title="9"><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/print">print</a></span>(S.aureus, <span class="dt">unit =</span> <span class="st">"ms"</span>, <span class="dt">signif =</span> <span class="dv">2</span>)</a>
<a class="sourceLine" id="cb2-10" title="10"><span class="co">#&gt; Unit: milliseconds</span></a>
<a class="sourceLine" id="cb2-11" title="11"><span class="co">#&gt; expr min lq mean median uq max neval</span></a>
<a class="sourceLine" id="cb2-12" title="12"><span class="co">#&gt; as.mo("sau") 18 18.0 27 18.0 18.0 65 10</span></a>
<a class="sourceLine" id="cb2-13" title="13"><span class="co">#&gt; as.mo("stau") 48 48.0 56 48.0 48.0 130 10</span></a>
<a class="sourceLine" id="cb2-14" title="14"><span class="co">#&gt; as.mo("staaur") 18 18.0 24 18.0 18.0 76 10</span></a>
<a class="sourceLine" id="cb2-15" title="15"><span class="co">#&gt; as.mo("STAAUR") 18 18.0 27 18.0 19.0 63 10</span></a>
<a class="sourceLine" id="cb2-16" title="16"><span class="co">#&gt; as.mo("S. aureus") 28 28.0 33 28.0 29.0 72 10</span></a>
<a class="sourceLine" id="cb2-17" title="17"><span class="co">#&gt; as.mo("S. aureus") 28 29.0 38 29.0 31.0 76 10</span></a>
<a class="sourceLine" id="cb2-18" title="18"><span class="co">#&gt; as.mo("Staphylococcus aureus") 8 8.1 12 8.1 8.2 52 10</span></a></code></pre></div>
<a class="sourceLine" id="cb2-11" title="11"><span class="co">#&gt; expr min lq mean median uq max neval</span></a>
<a class="sourceLine" id="cb2-12" title="12"><span class="co">#&gt; as.mo("sau") 18.0 18 23.0 18 18.0 65 10</span></a>
<a class="sourceLine" id="cb2-13" title="13"><span class="co">#&gt; as.mo("stau") 47.0 48 48.0 48 48.0 50 10</span></a>
<a class="sourceLine" id="cb2-14" title="14"><span class="co">#&gt; as.mo("staaur") 18.0 18 22.0 18 18.0 62 10</span></a>
<a class="sourceLine" id="cb2-15" title="15"><span class="co">#&gt; as.mo("STAAUR") 18.0 18 32.0 19 62.0 62 10</span></a>
<a class="sourceLine" id="cb2-16" title="16"><span class="co">#&gt; as.mo("S. aureus") 28.0 28 42.0 28 28.0 120 10</span></a>
<a class="sourceLine" id="cb2-17" title="17"><span class="co">#&gt; as.mo("S. aureus") 28.0 28 40.0 28 29.0 98 10</span></a>
<a class="sourceLine" id="cb2-18" title="18"><span class="co">#&gt; as.mo("Staphylococcus aureus") 7.9 8 9.2 8 8.1 20 10</span></a></code></pre></div>
<p>In the table above, all measurements are shown in milliseconds (thousands of seconds). A value of 5 milliseconds means it can determine 200 input values per second. It case of 100 milliseconds, this is only 10 input values per second. The second input is the only one that has to be looked up thoroughly. All the others are known codes (the first one is a WHONET code) or common laboratory codes, or common full organism names like the last one. Full organism names are always preferred.</p>
<p>To achieve this speed, the <code>as.mo</code> function also takes into account the prevalence of human pathogenic microorganisms. The downside is of course that less prevalent microorganisms will be determined less fast. See this example for the ID of <em>Thermus islandicus</em> (<code>B_THERMS_ISL</code>), a bug probably never found before in humans:</p>
<div class="sourceCode" id="cb3"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb3-1" title="1">T.islandicus &lt;-<span class="st"> </span><span class="kw"><a href="https://www.rdocumentation.org/packages/microbenchmark/topics/microbenchmark">microbenchmark</a></span>(<span class="kw"><a href="../reference/as.mo.html">as.mo</a></span>(<span class="st">"theisl"</span>),</a>
@ -236,12 +236,12 @@
<a class="sourceLine" id="cb3-7" title="7"><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/print">print</a></span>(T.islandicus, <span class="dt">unit =</span> <span class="st">"ms"</span>, <span class="dt">signif =</span> <span class="dv">2</span>)</a>
<a class="sourceLine" id="cb3-8" title="8"><span class="co">#&gt; Unit: milliseconds</span></a>
<a class="sourceLine" id="cb3-9" title="9"><span class="co">#&gt; expr min lq mean median uq max neval</span></a>
<a class="sourceLine" id="cb3-10" title="10"><span class="co">#&gt; as.mo("theisl") 460 480 490 500 510 510 10</span></a>
<a class="sourceLine" id="cb3-11" title="11"><span class="co">#&gt; as.mo("THEISL") 460 460 490 470 510 520 10</span></a>
<a class="sourceLine" id="cb3-12" title="12"><span class="co">#&gt; as.mo("T. islandicus") 72 73 88 75 110 120 10</span></a>
<a class="sourceLine" id="cb3-13" title="13"><span class="co">#&gt; as.mo("T. islandicus") 73 73 87 74 100 140 10</span></a>
<a class="sourceLine" id="cb3-14" title="14"><span class="co">#&gt; as.mo("Thermus islandicus") 72 73 90 75 120 130 10</span></a></code></pre></div>
<p>That takes 8 times as much time on average. A value of 100 milliseconds means it can only determine ~10 different input values per second. We can conclude that looking up arbitrary codes of less prevalent microorganisms is the worst way to go, in terms of calculation performance. Full names (like <em>Thermus islandicus</em>) are almost fast - these are the most probable input from most data sets.</p>
<a class="sourceLine" id="cb3-10" title="10"><span class="co">#&gt; as.mo("theisl") 470 470 490 470 520 520 10</span></a>
<a class="sourceLine" id="cb3-11" title="11"><span class="co">#&gt; as.mo("THEISL") 470 470 500 510 520 520 10</span></a>
<a class="sourceLine" id="cb3-12" title="12"><span class="co">#&gt; as.mo("T. islandicus") 76 76 81 76 77 120 10</span></a>
<a class="sourceLine" id="cb3-13" title="13"><span class="co">#&gt; as.mo("T. islandicus") 76 76 94 78 120 120 10</span></a>
<a class="sourceLine" id="cb3-14" title="14"><span class="co">#&gt; as.mo("Thermus islandicus") 74 74 96 77 120 150 10</span></a></code></pre></div>
<p>That takes 8.2 times as much time on average. A value of 100 milliseconds means it can only determine ~10 different input values per second. We can conclude that looking up arbitrary codes of less prevalent microorganisms is the worst way to go, in terms of calculation performance. Full names (like <em>Thermus islandicus</em>) are almost fast - these are the most probable input from most data sets.</p>
<p>In the figure below, we compare <em>Escherichia coli</em> (which is very common) with <em>Prevotella brevis</em> (which is moderately common) and with <em>Thermus islandicus</em> (which is very uncommon):</p>
<div class="sourceCode" id="cb4"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb4-1" title="1"><span class="kw"><a href="https://www.rdocumentation.org/packages/graphics/topics/par">par</a></span>(<span class="dt">mar =</span> <span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/c">c</a></span>(<span class="dv">5</span>, <span class="dv">16</span>, <span class="dv">4</span>, <span class="dv">2</span>)) <span class="co"># set more space for left margin text (16)</span></a>
<a class="sourceLine" id="cb4-2" title="2"></a>
@ -253,7 +253,7 @@
<a class="sourceLine" id="cb4-8" title="8"> <span class="kw"><a href="../reference/as.mo.html">as.mo</a></span>(<span class="st">"E. coli"</span>),</a>
<a class="sourceLine" id="cb4-9" title="9"> <span class="dt">times =</span> <span class="dv">10</span>),</a>
<a class="sourceLine" id="cb4-10" title="10"> <span class="dt">horizontal =</span> <span class="ot">TRUE</span>, <span class="dt">las =</span> <span class="dv">1</span>, <span class="dt">unit =</span> <span class="st">"s"</span>, <span class="dt">log =</span> <span class="ot">FALSE</span>,</a>
<a class="sourceLine" id="cb4-11" title="11"> <span class="dt">xlab =</span> <span class="st">""</span>, <span class="dt">ylab =</span> <span class="st">"Time in seconds"</span>, <span class="dt">ylim =</span> <span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/c">c</a></span>(<span class="dv">0</span>, <span class="fl">0.5</span>),</a>
<a class="sourceLine" id="cb4-11" title="11"> <span class="dt">xlab =</span> <span class="st">""</span>, <span class="dt">ylab =</span> <span class="st">"Time in seconds"</span>,</a>
<a class="sourceLine" id="cb4-12" title="12"> <span class="dt">main =</span> <span class="st">"Benchmarks per prevalence"</span>)</a></code></pre></div>
<p><img src="benchmarks_files/figure-html/unnamed-chunk-5-1.png" width="720"></p>
<p>Uncommon microorganisms take a lot more time than common microorganisms. To relieve this pitfall and further improve performance, two important calculations take almost no time at all: <strong>repetitive results</strong> and <strong>already precalculated results</strong>.</p>
@ -286,9 +286,9 @@
<a class="sourceLine" id="cb5-23" title="23"> <span class="dt">times =</span> <span class="dv">10</span>)</a>
<a class="sourceLine" id="cb5-24" title="24"><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/print">print</a></span>(run_it, <span class="dt">unit =</span> <span class="st">"ms"</span>, <span class="dt">signif =</span> <span class="dv">3</span>)</a>
<a class="sourceLine" id="cb5-25" title="25"><span class="co">#&gt; Unit: milliseconds</span></a>
<a class="sourceLine" id="cb5-26" title="26"><span class="co">#&gt; expr min lq mean median uq max neval</span></a>
<a class="sourceLine" id="cb5-27" title="27"><span class="co">#&gt; mo_fullname(x) 774 777 811 783 829 947 10</span></a></code></pre></div>
<p>So transforming 500,000 values (!!) of 50 unique values only takes 0.78 seconds (783 ms). You only lose time on your unique input values.</p>
<a class="sourceLine" id="cb5-26" title="26"><span class="co">#&gt; expr min lq mean median uq max neval</span></a>
<a class="sourceLine" id="cb5-27" title="27"><span class="co">#&gt; mo_fullname(x) 777 780 859 864 870 1080 10</span></a></code></pre></div>
<p>So transforming 500,000 values (!!) of 50 unique values only takes 0.86 seconds (864 ms). You only lose time on your unique input values.</p>
</div>
<div id="precalculated-results" class="section level3">
<h3 class="hasAnchor">
@ -300,11 +300,11 @@
<a class="sourceLine" id="cb6-4" title="4"> <span class="dt">times =</span> <span class="dv">10</span>)</a>
<a class="sourceLine" id="cb6-5" title="5"><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/print">print</a></span>(run_it, <span class="dt">unit =</span> <span class="st">"ms"</span>, <span class="dt">signif =</span> <span class="dv">3</span>)</a>
<a class="sourceLine" id="cb6-6" title="6"><span class="co">#&gt; Unit: milliseconds</span></a>
<a class="sourceLine" id="cb6-7" title="7"><span class="co">#&gt; expr min lq mean median uq max neval</span></a>
<a class="sourceLine" id="cb6-8" title="8"><span class="co">#&gt; A 12.000 12.100 12.500 12.400 12.800 13.20 10</span></a>
<a class="sourceLine" id="cb6-9" title="9"><span class="co">#&gt; B 25.800 26.200 26.900 26.600 27.800 28.00 10</span></a>
<a class="sourceLine" id="cb6-10" title="10"><span class="co">#&gt; C 0.476 0.691 0.758 0.812 0.848 1.03 10</span></a></code></pre></div>
<p>So going from <code><a href="../reference/mo_property.html">mo_fullname("Staphylococcus aureus")</a></code> to <code>"Staphylococcus aureus"</code> takes 0.0008 seconds - it doesnt even start calculating <em>if the result would be the same as the expected resulting value</em>. That goes for all helper functions:</p>
<a class="sourceLine" id="cb6-7" title="7"><span class="co">#&gt; expr min lq mean median uq max neval</span></a>
<a class="sourceLine" id="cb6-8" title="8"><span class="co">#&gt; A 13.30 14.0 14.3 14.1 14.30 17.30 10</span></a>
<a class="sourceLine" id="cb6-9" title="9"><span class="co">#&gt; B 25.20 25.5 36.5 26.5 39.60 71.30 10</span></a>
<a class="sourceLine" id="cb6-10" title="10"><span class="co">#&gt; C 1.68 1.7 1.9 1.8 1.94 2.81 10</span></a></code></pre></div>
<p>So going from <code><a href="../reference/mo_property.html">mo_fullname("Staphylococcus aureus")</a></code> to <code>"Staphylococcus aureus"</code> takes 0.0018 seconds - it doesnt even start calculating <em>if the result would be the same as the expected resulting value</em>. That goes for all helper functions:</p>
<div class="sourceCode" id="cb7"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb7-1" title="1">run_it &lt;-<span class="st"> </span><span class="kw"><a href="https://www.rdocumentation.org/packages/microbenchmark/topics/microbenchmark">microbenchmark</a></span>(<span class="dt">A =</span> <span class="kw"><a href="../reference/mo_property.html">mo_species</a></span>(<span class="st">"aureus"</span>),</a>
<a class="sourceLine" id="cb7-2" title="2"> <span class="dt">B =</span> <span class="kw"><a href="../reference/mo_property.html">mo_genus</a></span>(<span class="st">"Staphylococcus"</span>),</a>
<a class="sourceLine" id="cb7-3" title="3"> <span class="dt">C =</span> <span class="kw"><a href="../reference/mo_property.html">mo_fullname</a></span>(<span class="st">"Staphylococcus aureus"</span>),</a>
@ -317,14 +317,14 @@
<a class="sourceLine" id="cb7-10" title="10"><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/print">print</a></span>(run_it, <span class="dt">unit =</span> <span class="st">"ms"</span>, <span class="dt">signif =</span> <span class="dv">3</span>)</a>
<a class="sourceLine" id="cb7-11" title="11"><span class="co">#&gt; Unit: milliseconds</span></a>
<a class="sourceLine" id="cb7-12" title="12"><span class="co">#&gt; expr min lq mean median uq max neval</span></a>
<a class="sourceLine" id="cb7-13" title="13"><span class="co">#&gt; A 0.364 0.403 0.452 0.455 0.496 0.575 10</span></a>
<a class="sourceLine" id="cb7-14" title="14"><span class="co">#&gt; B 0.478 0.533 0.566 0.565 0.594 0.645 10</span></a>
<a class="sourceLine" id="cb7-15" title="15"><span class="co">#&gt; C 0.512 0.726 0.851 0.893 1.010 1.150 10</span></a>
<a class="sourceLine" id="cb7-16" title="16"><span class="co">#&gt; D 0.409 0.460 0.490 0.507 0.530 0.544 10</span></a>
<a class="sourceLine" id="cb7-17" title="17"><span class="co">#&gt; E 0.375 0.380 0.454 0.476 0.488 0.524 10</span></a>
<a class="sourceLine" id="cb7-18" title="18"><span class="co">#&gt; F 0.395 0.411 0.463 0.442 0.522 0.587 10</span></a>
<a class="sourceLine" id="cb7-19" title="19"><span class="co">#&gt; G 0.381 0.404 0.454 0.451 0.495 0.546 10</span></a>
<a class="sourceLine" id="cb7-20" title="20"><span class="co">#&gt; H 0.232 0.268 0.304 0.297 0.336 0.391 10</span></a></code></pre></div>
<a class="sourceLine" id="cb7-13" title="13"><span class="co">#&gt; A 0.417 0.456 0.511 0.494 0.558 0.612 10</span></a>
<a class="sourceLine" id="cb7-14" title="14"><span class="co">#&gt; B 0.416 0.555 0.620 0.614 0.658 0.837 10</span></a>
<a class="sourceLine" id="cb7-15" title="15"><span class="co">#&gt; C 1.360 1.630 1.970 1.880 1.970 3.220 10</span></a>
<a class="sourceLine" id="cb7-16" title="16"><span class="co">#&gt; D 0.435 0.519 0.671 0.665 0.734 1.120 10</span></a>
<a class="sourceLine" id="cb7-17" title="17"><span class="co">#&gt; E 0.356 0.429 0.491 0.452 0.486 0.916 10</span></a>
<a class="sourceLine" id="cb7-18" title="18"><span class="co">#&gt; F 0.384 0.450 0.559 0.502 0.543 1.180 10</span></a>
<a class="sourceLine" id="cb7-19" title="19"><span class="co">#&gt; G 0.407 0.450 0.591 0.527 0.663 1.080 10</span></a>
<a class="sourceLine" id="cb7-20" title="20"><span class="co">#&gt; H 0.219 0.272 0.295 0.276 0.311 0.420 10</span></a></code></pre></div>
<p>Of course, when running <code><a href="../reference/mo_property.html">mo_phylum("Firmicutes")</a></code> the function has zero knowledge about the actual microorganism, namely <em>S. aureus</em>. But since the result would be <code>"Firmicutes"</code> too, there is no point in calculating the result. And because this package knows all phyla of all known bacteria (according to the Catalogue of Life), it can just return the initial value immediately.</p>
</div>
<div id="results-in-other-languages" class="section level3">
@ -350,14 +350,14 @@
<a class="sourceLine" id="cb8-17" title="17"> <span class="dt">times =</span> <span class="dv">10</span>)</a>
<a class="sourceLine" id="cb8-18" title="18"><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/print">print</a></span>(run_it, <span class="dt">unit =</span> <span class="st">"ms"</span>, <span class="dt">signif =</span> <span class="dv">4</span>)</a>
<a class="sourceLine" id="cb8-19" title="19"><span class="co">#&gt; Unit: milliseconds</span></a>
<a class="sourceLine" id="cb8-20" title="20"><span class="co">#&gt; expr min lq mean median uq max neval</span></a>
<a class="sourceLine" id="cb8-21" title="21"><span class="co">#&gt; en 18.37 19.07 19.98 19.22 19.41 27.24 10</span></a>
<a class="sourceLine" id="cb8-22" title="22"><span class="co">#&gt; de 30.58 31.06 35.93 31.42 31.54 77.27 10</span></a>
<a class="sourceLine" id="cb8-23" title="23"><span class="co">#&gt; nl 31.01 31.33 37.73 31.41 31.59 93.52 10</span></a>
<a class="sourceLine" id="cb8-24" title="24"><span class="co">#&gt; es 31.38 31.45 36.30 31.81 32.53 76.12 10</span></a>
<a class="sourceLine" id="cb8-25" title="25"><span class="co">#&gt; it 30.98 31.40 36.99 31.58 32.30 84.46 10</span></a>
<a class="sourceLine" id="cb8-26" title="26"><span class="co">#&gt; fr 31.19 31.21 35.82 31.45 31.62 75.52 10</span></a>
<a class="sourceLine" id="cb8-27" title="27"><span class="co">#&gt; pt 31.02 31.36 40.85 32.22 33.84 76.22 10</span></a></code></pre></div>
<a class="sourceLine" id="cb8-20" title="20"><span class="co">#&gt; expr min lq mean median uq max neval</span></a>
<a class="sourceLine" id="cb8-21" title="21"><span class="co">#&gt; en 18.34 18.37 23.22 18.54 19.53 63.17 10</span></a>
<a class="sourceLine" id="cb8-22" title="22"><span class="co">#&gt; de 23.46 23.50 23.76 23.57 23.76 25.10 10</span></a>
<a class="sourceLine" id="cb8-23" title="23"><span class="co">#&gt; nl 50.78 52.48 62.59 53.54 57.07 100.20 10</span></a>
<a class="sourceLine" id="cb8-24" title="24"><span class="co">#&gt; es 23.53 23.59 28.70 23.76 24.17 68.55 10</span></a>
<a class="sourceLine" id="cb8-25" title="25"><span class="co">#&gt; it 23.31 23.40 23.69 23.51 23.79 24.73 10</span></a>
<a class="sourceLine" id="cb8-26" title="26"><span class="co">#&gt; fr 23.45 23.52 24.21 24.06 24.88 25.21 10</span></a>
<a class="sourceLine" id="cb8-27" title="27"><span class="co">#&gt; pt 23.54 23.72 24.37 24.39 24.90 25.58 10</span></a></code></pre></div>
<p>Currently supported are German, Dutch, Spanish, Italian, French and Portuguese.</p>
</div>
</div>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 27 KiB

View File

@ -78,7 +78,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.6.1.9002</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.6.1.9003</span>
</span>
</div>
@ -143,7 +143,7 @@
</a>
</li>
<li>
<a href="../reference/atc_property.html">
<a href="../reference/ab_property.html">
<span class="fa fa-capsules"></span>
Get properties of an antibiotic
@ -241,7 +241,7 @@
<li><a href="G_test.html">How to use the *G*-test</a></li>
<li><a href="SPSS.html">How to import data from SPSS / SAS / Stata</a></li>
<li><a href="WHONET.html">How to work with WHONET data</a></li>
<li><a href="atc_property.html">How to get properties of an antibiotic</a></li>
<li><a href="ab_property.html">How to get properties of an antibiotic</a></li>
<li><a href="benchmarks.html">Benchmarks</a></li>
<li><a href="freq.html">How to create frequency tables</a></li>
<li><a href="mo_property.html">How to get properties of a microorganism</a></li>

View File

@ -40,7 +40,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.6.0</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.6.1.9003</span>
</span>
</div>
@ -105,7 +105,7 @@
</a>
</li>
<li>
<a href="../reference/atc_property.html">
<a href="../reference/ab_property.html">
<span class="fa fa-capsules"></span>
Get properties of an antibiotic
@ -192,7 +192,7 @@
<h1>How to predict antimicrobial resistance</h1>
<h4 class="author">Matthijs S. Berends</h4>
<h4 class="date">27 March 2019</h4>
<h4 class="date">10 May 2019</h4>
<div class="hidden name"><code>resistance_predict.Rmd</code></div>
@ -218,16 +218,16 @@
<a href="#prediction-analysis" class="anchor"></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 analysis</a>. Based on a date column, it calculates cases per year and uses a regression model to predict antimicrobial resistance.</p>
<p>It is basically as easy as:</p>
<div class="sourceCode" id="cb2"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb2-1" title="1"><span class="co"># resistance prediction of piperacillin/tazobactam (pita):</span></a>
<a class="sourceLine" id="cb2-2" title="2"><span class="kw"><a href="../reference/resistance_predict.html">resistance_predict</a></span>(<span class="dt">tbl =</span> septic_patients, <span class="dt">col_date =</span> <span class="st">"date"</span>, <span class="dt">col_ab =</span> <span class="st">"pita"</span>)</a>
<div class="sourceCode" id="cb2"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb2-1" title="1"><span class="co"># resistance prediction of piperacillin/tazobactam (TZP):</span></a>
<a class="sourceLine" id="cb2-2" title="2"><span class="kw"><a href="../reference/resistance_predict.html">resistance_predict</a></span>(<span class="dt">tbl =</span> septic_patients, <span class="dt">col_date =</span> <span class="st">"date"</span>, <span class="dt">col_ab =</span> <span class="st">"TZP"</span>)</a>
<a class="sourceLine" id="cb2-3" title="3"></a>
<a class="sourceLine" id="cb2-4" title="4"><span class="co"># or:</span></a>
<a class="sourceLine" id="cb2-5" title="5">septic_patients <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb2-6" title="6"><span class="st"> </span><span class="kw"><a href="../reference/resistance_predict.html">resistance_predict</a></span>(<span class="dt">col_ab =</span> <span class="st">"pita"</span>)</a>
<a class="sourceLine" id="cb2-6" title="6"><span class="st"> </span><span class="kw"><a href="../reference/resistance_predict.html">resistance_predict</a></span>(<span class="dt">col_ab =</span> <span class="st">"TZP"</span>)</a>
<a class="sourceLine" id="cb2-7" title="7"></a>
<a class="sourceLine" id="cb2-8" title="8"><span class="co"># to bind it to object 'predict_pita' for example:</span></a>
<a class="sourceLine" id="cb2-9" title="9">predict_pita &lt;-<span class="st"> </span>septic_patients <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb2-10" title="10"><span class="st"> </span><span class="kw"><a href="../reference/resistance_predict.html">resistance_predict</a></span>(<span class="dt">col_ab =</span> <span class="st">"pita"</span>)</a></code></pre></div>
<a class="sourceLine" id="cb2-8" title="8"><span class="co"># to bind it to object 'predict_TZP' for example:</span></a>
<a class="sourceLine" id="cb2-9" title="9">predict_TZP &lt;-<span class="st"> </span>septic_patients <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb2-10" title="10"><span class="st"> </span><span class="kw"><a href="../reference/resistance_predict.html">resistance_predict</a></span>(<span class="dt">col_ab =</span> <span class="st">"TZP"</span>)</a></code></pre></div>
<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>
<pre><code>#&gt; NOTE: Using column `date` as input for `col_date`.
@ -240,62 +240,62 @@
#&gt;
#&gt; Deviance Residuals:
#&gt; Min 1Q Median 3Q Max
#&gt; -2.9224 -1.3120 0.0170 0.7586 3.1932
#&gt; -2.9203 -1.3066 0.0166 0.7641 3.1984
#&gt;
#&gt; Coefficients:
#&gt; Estimate Std. Error z value Pr(&gt;|z|)
#&gt; (Intercept) -222.92857 45.93922 -4.853 1.22e-06 ***
#&gt; year 0.10994 0.02284 4.814 1.48e-06 ***
#&gt; (Intercept) -222.51053 45.94675 -4.843 1.28e-06 ***
#&gt; year 0.10973 0.02284 4.805 1.55e-06 ***
#&gt; ---
#&gt; Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#&gt;
#&gt; (Dispersion parameter for binomial family taken to be 1)
#&gt;
#&gt; Null deviance: 59.794 on 14 degrees of freedom
#&gt; Residual deviance: 35.191 on 13 degrees of freedom
#&gt; AIC: 93.464
#&gt; Null deviance: 59.763 on 14 degrees of freedom
#&gt; Residual deviance: 35.261 on 13 degrees of freedom
#&gt; AIC: 93.537
#&gt;
#&gt; Number of Fisher Scoring iterations: 4</code></pre>
<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>
<div class="sourceCode" id="cb4"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb4-1" title="1">predict_pita</a>
<div class="sourceCode" id="cb4"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb4-1" title="1">predict_TZP</a>
<a class="sourceLine" id="cb4-2" title="2"><span class="co">#&gt; year value se_min se_max observations observed estimated</span></a>
<a class="sourceLine" id="cb4-3" title="3"><span class="co">#&gt; 1 2003 0.06250000 NA NA 32 0.06250000 0.06177594</span></a>
<a class="sourceLine" id="cb4-4" title="4"><span class="co">#&gt; 2 2004 0.08536585 NA NA 82 0.08536585 0.06846343</span></a>
<a class="sourceLine" id="cb4-5" title="5"><span class="co">#&gt; 3 2005 0.10000000 NA NA 60 0.10000000 0.07581637</span></a>
<a class="sourceLine" id="cb4-6" title="6"><span class="co">#&gt; 4 2006 0.05084746 NA NA 59 0.05084746 0.08388789</span></a>
<a class="sourceLine" id="cb4-7" title="7"><span class="co">#&gt; 5 2007 0.12121212 NA NA 66 0.12121212 0.09273250</span></a>
<a class="sourceLine" id="cb4-8" title="8"><span class="co">#&gt; 6 2008 0.04166667 NA NA 72 0.04166667 0.10240539</span></a>
<a class="sourceLine" id="cb4-9" title="9"><span class="co">#&gt; 7 2009 0.01639344 NA NA 61 0.01639344 0.11296163</span></a>
<a class="sourceLine" id="cb4-10" title="10"><span class="co">#&gt; 8 2010 0.09433962 NA NA 53 0.09433962 0.12445516</span></a>
<a class="sourceLine" id="cb4-11" title="11"><span class="co">#&gt; 9 2011 0.18279570 NA NA 93 0.18279570 0.13693759</span></a>
<a class="sourceLine" id="cb4-12" title="12"><span class="co">#&gt; 10 2012 0.30769231 NA NA 65 0.30769231 0.15045682</span></a>
<a class="sourceLine" id="cb4-13" title="13"><span class="co">#&gt; 11 2013 0.08620690 NA NA 58 0.08620690 0.16505550</span></a>
<a class="sourceLine" id="cb4-14" title="14"><span class="co">#&gt; 12 2014 0.15254237 NA NA 59 0.15254237 0.18076926</span></a>
<a class="sourceLine" id="cb4-15" title="15"><span class="co">#&gt; 13 2015 0.27272727 NA NA 55 0.27272727 0.19762493</span></a>
<a class="sourceLine" id="cb4-16" title="16"><span class="co">#&gt; 14 2016 0.25000000 NA NA 84 0.25000000 0.21563859</span></a>
<a class="sourceLine" id="cb4-17" title="17"><span class="co">#&gt; 15 2017 0.16279070 NA NA 86 0.16279070 0.23481370</span></a>
<a class="sourceLine" id="cb4-18" title="18"><span class="co">#&gt; 16 2018 0.25513926 0.2228376 0.2874409 NA NA 0.25513926</span></a>
<a class="sourceLine" id="cb4-19" title="19"><span class="co">#&gt; 17 2019 0.27658825 0.2386811 0.3144954 NA NA 0.27658825</span></a>
<a class="sourceLine" id="cb4-20" title="20"><span class="co">#&gt; 18 2020 0.29911630 0.2551715 0.3430611 NA NA 0.29911630</span></a>
<a class="sourceLine" id="cb4-21" title="21"><span class="co">#&gt; 19 2021 0.32266085 0.2723340 0.3729877 NA NA 0.32266085</span></a>
<a class="sourceLine" id="cb4-22" title="22"><span class="co">#&gt; 20 2022 0.34714076 0.2901847 0.4040968 NA NA 0.34714076</span></a>
<a class="sourceLine" id="cb4-23" title="23"><span class="co">#&gt; 21 2023 0.37245666 0.3087318 0.4361815 NA NA 0.37245666</span></a>
<a class="sourceLine" id="cb4-24" title="24"><span class="co">#&gt; 22 2024 0.39849187 0.3279750 0.4690088 NA NA 0.39849187</span></a>
<a class="sourceLine" id="cb4-25" title="25"><span class="co">#&gt; 23 2025 0.42511415 0.3479042 0.5023241 NA NA 0.42511415</span></a>
<a class="sourceLine" id="cb4-26" title="26"><span class="co">#&gt; 24 2026 0.45217796 0.3684992 0.5358568 NA NA 0.45217796</span></a>
<a class="sourceLine" id="cb4-27" title="27"><span class="co">#&gt; 25 2027 0.47952757 0.3897276 0.5693275 NA NA 0.47952757</span></a>
<a class="sourceLine" id="cb4-28" title="28"><span class="co">#&gt; 26 2028 0.50700045 0.4115444 0.6024565 NA NA 0.50700045</span></a>
<a class="sourceLine" id="cb4-29" title="29"><span class="co">#&gt; 27 2029 0.53443111 0.4338908 0.6349714 NA NA 0.53443111</span></a></code></pre></div>
<a class="sourceLine" id="cb4-3" title="3"><span class="co">#&gt; 1 2003 0.06250000 NA NA 32 0.06250000 0.06179057</span></a>
<a class="sourceLine" id="cb4-4" title="4"><span class="co">#&gt; 2 2004 0.08536585 NA NA 82 0.08536585 0.06846623</span></a>
<a class="sourceLine" id="cb4-5" title="5"><span class="co">#&gt; 3 2005 0.10000000 NA NA 60 0.10000000 0.07580483</span></a>
<a class="sourceLine" id="cb4-6" title="6"><span class="co">#&gt; 4 2006 0.05084746 NA NA 59 0.05084746 0.08385921</span></a>
<a class="sourceLine" id="cb4-7" title="7"><span class="co">#&gt; 5 2007 0.12121212 NA NA 66 0.12121212 0.09268356</span></a>
<a class="sourceLine" id="cb4-8" title="8"><span class="co">#&gt; 6 2008 0.04166667 NA NA 72 0.04166667 0.10233276</span></a>
<a class="sourceLine" id="cb4-9" title="9"><span class="co">#&gt; 7 2009 0.01639344 NA NA 61 0.01639344 0.11286156</span></a>
<a class="sourceLine" id="cb4-10" title="10"><span class="co">#&gt; 8 2010 0.09433962 NA NA 53 0.09433962 0.12432363</span></a>
<a class="sourceLine" id="cb4-11" title="11"><span class="co">#&gt; 9 2011 0.18279570 NA NA 93 0.18279570 0.13677030</span></a>
<a class="sourceLine" id="cb4-12" title="12"><span class="co">#&gt; 10 2012 0.30769231 NA NA 65 0.30769231 0.15024926</span></a>
<a class="sourceLine" id="cb4-13" title="13"><span class="co">#&gt; 11 2013 0.08620690 NA NA 58 0.08620690 0.16480299</span></a>
<a class="sourceLine" id="cb4-14" title="14"><span class="co">#&gt; 12 2014 0.15000000 NA NA 60 0.15000000 0.18046706</span></a>
<a class="sourceLine" id="cb4-15" title="15"><span class="co">#&gt; 13 2015 0.27272727 NA NA 55 0.27272727 0.19726831</span></a>
<a class="sourceLine" id="cb4-16" title="16"><span class="co">#&gt; 14 2016 0.25000000 NA NA 84 0.25000000 0.21522295</span></a>
<a class="sourceLine" id="cb4-17" title="17"><span class="co">#&gt; 15 2017 0.16279070 NA NA 86 0.16279070 0.23433471</span></a>
<a class="sourceLine" id="cb4-18" title="18"><span class="co">#&gt; 16 2018 0.25459302 0.2223385 0.2868476 NA NA 0.25459302</span></a>
<a class="sourceLine" id="cb4-19" title="19"><span class="co">#&gt; 17 2019 0.27597143 0.2381174 0.3138255 NA NA 0.27597143</span></a>
<a class="sourceLine" id="cb4-20" title="20"><span class="co">#&gt; 18 2020 0.29842630 0.2545398 0.3423128 NA NA 0.29842630</span></a>
<a class="sourceLine" id="cb4-21" title="21"><span class="co">#&gt; 19 2021 0.32189595 0.2716308 0.3721611 NA NA 0.32189595</span></a>
<a class="sourceLine" id="cb4-22" title="22"><span class="co">#&gt; 20 2022 0.34630028 0.2894072 0.4031934 NA NA 0.34630028</span></a>
<a class="sourceLine" id="cb4-23" title="23"><span class="co">#&gt; 21 2023 0.37154107 0.3078773 0.4352048 NA NA 0.37154107</span></a>
<a class="sourceLine" id="cb4-24" title="24"><span class="co">#&gt; 22 2024 0.39750288 0.3270414 0.4679643 NA NA 0.39750288</span></a>
<a class="sourceLine" id="cb4-25" title="25"><span class="co">#&gt; 23 2025 0.42405472 0.3468903 0.5012191 NA NA 0.42405472</span></a>
<a class="sourceLine" id="cb4-26" title="26"><span class="co">#&gt; 24 2026 0.45105237 0.3674044 0.5347004 NA NA 0.45105237</span></a>
<a class="sourceLine" id="cb4-27" title="27"><span class="co">#&gt; 25 2027 0.47834130 0.3885523 0.5681303 NA NA 0.47834130</span></a>
<a class="sourceLine" id="cb4-28" title="28"><span class="co">#&gt; 26 2028 0.50576012 0.4102900 0.6012302 NA NA 0.50576012</span></a>
<a class="sourceLine" id="cb4-29" title="29"><span class="co">#&gt; 27 2029 0.53314434 0.4325600 0.6337287 NA NA 0.53314434</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>
<div class="sourceCode" id="cb5"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb5-1" title="1"><span class="kw"><a href="https://www.rdocumentation.org/packages/graphics/topics/plot">plot</a></span>(predict_pita)</a></code></pre></div>
<div class="sourceCode" id="cb5"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb5-1" title="1"><span class="kw"><a href="https://www.rdocumentation.org/packages/graphics/topics/plot">plot</a></span>(predict_TZP)</a></code></pre></div>
<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>
<div class="sourceCode" id="cb6"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb6-1" title="1"><span class="kw"><a href="../reference/resistance_predict.html">ggplot_rsi_predict</a></span>(predict_pita)</a></code></pre></div>
<div class="sourceCode" id="cb6"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb6-1" title="1"><span class="kw"><a href="../reference/resistance_predict.html">ggplot_rsi_predict</a></span>(predict_TZP)</a></code></pre></div>
<p><img src="resistance_predict_files/figure-html/unnamed-chunk-5-1.png" width="720"></p>
<div class="sourceCode" id="cb7"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb7-1" title="1"></a>
<a class="sourceLine" id="cb7-2" title="2"><span class="co"># choose for error bars instead of a ribbon</span></a>
<a class="sourceLine" id="cb7-3" title="3"><span class="kw"><a href="../reference/resistance_predict.html">ggplot_rsi_predict</a></span>(predict_pita, <span class="dt">ribbon =</span> <span class="ot">FALSE</span>)</a></code></pre></div>
<a class="sourceLine" id="cb7-3" title="3"><span class="kw"><a href="../reference/resistance_predict.html">ggplot_rsi_predict</a></span>(predict_TZP, <span class="dt">ribbon =</span> <span class="ot">FALSE</span>)</a></code></pre></div>
<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">
@ -303,7 +303,7 @@
<p>Resistance is not easily predicted; if we look at vancomycin resistance in Gram positives, the spread (i.e. standard error) is enormous:</p>
<div class="sourceCode" id="cb8"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb8-1" title="1">septic_patients <span class="op">%&gt;%</span></a>
<a class="sourceLine" id="cb8-2" title="2"><span class="st"> </span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/filter.html">filter</a></span>(<span class="kw"><a href="../reference/mo_property.html">mo_gramstain</a></span>(mo) <span class="op">==</span><span class="st"> "Gram positive"</span>) <span class="op">%&gt;%</span></a>
<a class="sourceLine" id="cb8-3" title="3"><span class="st"> </span><span class="kw"><a href="../reference/resistance_predict.html">resistance_predict</a></span>(<span class="dt">col_ab =</span> <span class="st">"vanc"</span>, <span class="dt">year_min =</span> <span class="dv">2010</span>, <span class="dt">info =</span> <span class="ot">FALSE</span>) <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb8-3" title="3"><span class="st"> </span><span class="kw"><a href="../reference/resistance_predict.html">resistance_predict</a></span>(<span class="dt">col_ab =</span> <span class="st">"VAN"</span>, <span class="dt">year_min =</span> <span class="dv">2010</span>, <span class="dt">info =</span> <span class="ot">FALSE</span>) <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb8-4" title="4"><span class="st"> </span><span class="kw"><a href="../reference/resistance_predict.html">ggplot_rsi_predict</a></span>()</a>
<a class="sourceLine" id="cb8-5" title="5"><span class="co">#&gt; </span><span class="al">NOTE</span><span class="co">: Using column `date` as input for `col_date`.</span></a></code></pre></div>
<p><img src="resistance_predict_files/figure-html/unnamed-chunk-6-1.png" width="720"></p>
@ -348,13 +348,13 @@
<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>
<div class="sourceCode" id="cb9"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb9-1" title="1">septic_patients <span class="op">%&gt;%</span></a>
<a class="sourceLine" id="cb9-2" title="2"><span class="st"> </span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/filter.html">filter</a></span>(<span class="kw"><a href="../reference/mo_property.html">mo_gramstain</a></span>(mo) <span class="op">==</span><span class="st"> "Gram positive"</span>) <span class="op">%&gt;%</span></a>
<a class="sourceLine" id="cb9-3" title="3"><span class="st"> </span><span class="kw"><a href="../reference/resistance_predict.html">resistance_predict</a></span>(<span class="dt">col_ab =</span> <span class="st">"vanc"</span>, <span class="dt">year_min =</span> <span class="dv">2010</span>, <span class="dt">info =</span> <span class="ot">FALSE</span>, <span class="dt">model =</span> <span class="st">"linear"</span>) <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb9-3" title="3"><span class="st"> </span><span class="kw"><a href="../reference/resistance_predict.html">resistance_predict</a></span>(<span class="dt">col_ab =</span> <span class="st">"VAN"</span>, <span class="dt">year_min =</span> <span class="dv">2010</span>, <span class="dt">info =</span> <span class="ot">FALSE</span>, <span class="dt">model =</span> <span class="st">"linear"</span>) <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb9-4" title="4"><span class="st"> </span><span class="kw"><a href="../reference/resistance_predict.html">ggplot_rsi_predict</a></span>()</a>
<a class="sourceLine" id="cb9-5" title="5"><span class="co">#&gt; </span><span class="al">NOTE</span><span class="co">: Using column `date` as input for `col_date`.</span></a></code></pre></div>
<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>
<div class="sourceCode" id="cb10"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb10-1" title="1">model &lt;-<span class="st"> </span><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/attributes">attributes</a></span>(predict_pita)<span class="op">$</span>model</a>
<div class="sourceCode" id="cb10"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb10-1" title="1">model &lt;-<span class="st"> </span><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/attributes">attributes</a></span>(predict_TZP)<span class="op">$</span>model</a>
<a class="sourceLine" id="cb10-2" title="2"></a>
<a class="sourceLine" id="cb10-3" title="3"><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/summary">summary</a></span>(model)<span class="op">$</span>family</a>
<a class="sourceLine" id="cb10-4" title="4"><span class="co">#&gt; </span></a>
@ -363,8 +363,8 @@
<a class="sourceLine" id="cb10-7" title="7"></a>
<a class="sourceLine" id="cb10-8" title="8"><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/summary">summary</a></span>(model)<span class="op">$</span>coefficients</a>
<a class="sourceLine" id="cb10-9" title="9"><span class="co">#&gt; Estimate Std. Error z value Pr(&gt;|z|)</span></a>
<a class="sourceLine" id="cb10-10" title="10"><span class="co">#&gt; (Intercept) -222.9285736 45.93922388 -4.852685 1.218012e-06</span></a>
<a class="sourceLine" id="cb10-11" title="11"><span class="co">#&gt; year 0.1099391 0.02283501 4.814500 1.475690e-06</span></a></code></pre></div>
<a class="sourceLine" id="cb10-10" title="10"><span class="co">#&gt; (Intercept) -222.5105288 45.94675125 -4.842791 1.280277e-06</span></a>
<a class="sourceLine" id="cb10-11" title="11"><span class="co">#&gt; year 0.1097306 0.02283874 4.804581 1.550761e-06</span></a></code></pre></div>
</div>
</div>
</div>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 30 KiB