Skip to content

Commit

Permalink
changes in Bookdown documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
svkucheryavski committed Aug 3, 2017
1 parent 72333a1 commit 3e0a013
Show file tree
Hide file tree
Showing 20 changed files with 32 additions and 14 deletions.
Binary file modified docs/_main_files/figure-html/unnamed-chunk-100-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/_main_files/figure-html/unnamed-chunk-101-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/_main_files/figure-html/unnamed-chunk-43-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/_main_files/figure-html/unnamed-chunk-77-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/_main_files/figure-html/unnamed-chunk-78-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/_main_files/figure-html/unnamed-chunk-79-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/_main_files/figure-html/unnamed-chunk-91-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/_main_files/figure-html/unnamed-chunk-92-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/_main_files/figure-html/unnamed-chunk-94-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/_main_files/figure-html/unnamed-chunk-95-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/_main_files/figure-html/unnamed-chunk-98-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions docs/calibration-and-validation.html
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ <h2>Calibration and validation</h2>
## Comp 3 8.45 98.82 0.92 12.24 0.84</code></pre>
<p>Let’s look at plots and start with summary plot.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">plot</span>(m)</code></pre></div>
<p><img src="_main_files/figure-html/unnamed-chunk-90-1.png" width="864" /></p>
<p><img src="_main_files/figure-html/unnamed-chunk-91-1.png" width="864" /></p>
<p>The plot is very similar to what we seen for PCA model, the only difference is that it shows <em>modelling power</em> instead of loadings. Modelling power is a measure of contribution of each variable to the model and varies from 0 to 1. Usually variables with modelling power below 0.1 are considered as irrelevant.</p>
<p>Let’s give a closer look at the residuals plot with different values for alpha (we will keep number of components equal to three in all cases).</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">m1 =<span class="st"> </span><span class="kw">simca</span>(X.ver, <span class="st">&#39;versicolor&#39;</span>, <span class="dt">ncomp =</span> <span class="dv">3</span>, <span class="dt">cv =</span> <span class="dv">1</span>, <span class="dt">alpha =</span> <span class="fl">0.01</span>)
Expand All @@ -233,7 +233,7 @@ <h2>Calibration and validation</h2>
<span class="kw">plotResiduals</span>(m2)
<span class="kw">plotResiduals</span>(m3)
<span class="kw">plotResiduals</span>(m4)</code></pre></div>
<p><img src="_main_files/figure-html/unnamed-chunk-91-1.png" width="864" /></p>
<p><img src="_main_files/figure-html/unnamed-chunk-92-1.png" width="864" /></p>
<p>As you can see, using alpha = 0.01 reduced number of false negatives to zero, as the acceptance limits became larger, while alpha = 0.15 gives a lot of incorrectly rejected class members. It must be noted, that decreasing alpha will also lead to a larger number of false positives, which we can not see in this case.</p>
<div id="predictions-and-validation-with-a-test-set" class="section level3 unnumbered">
<h3>Predictions and validation with a test set</h3>
Expand Down Expand Up @@ -262,12 +262,12 @@ <h3>Predictions and validation with a test set</h3>
<span class="kw">plotSensitivity</span>(res)
<span class="kw">plotMisclassified</span>(res)
<span class="kw">plotPerformance</span>(res)</code></pre></div>
<p><img src="_main_files/figure-html/unnamed-chunk-93-1.png" width="864" /></p>
<p><img src="_main_files/figure-html/unnamed-chunk-94-1.png" width="864" /></p>
<p>The classification results can be shown both graphically and numerically. Here is a prediction plot for the results.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">par</span>(<span class="dt">mfrow =</span> <span class="kw">c</span>(<span class="dv">2</span>, <span class="dv">1</span>))
<span class="kw">plotPredictions</span>(res)
<span class="kw">plotPredictions</span>(res, <span class="dt">ncomp =</span> <span class="dv">2</span>)</code></pre></div>
<p><img src="_main_files/figure-html/unnamed-chunk-94-1.png" width="864" /></p>
<p><img src="_main_files/figure-html/unnamed-chunk-95-1.png" width="864" /></p>
<p>So we can see that for the model with three components we have no false positives (specificity = 1) and one false negative (sensitivity = 24/25 = 0.96). You can also show the predictions as a matrix with -1 and +1 using method <code>showPredictions()</code> or get the array with predicted class values directly as it is shown in the example below (for first 10 rows, different number of components and the first classification variable).</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">show</span>(res$c.pred[<span class="dv">31</span>:<span class="dv">40</span>, <span class="dv">1</span>:<span class="dv">3</span>, <span class="dv">1</span>])</code></pre></div>
<pre><code>## Comp 1 Comp 2 Comp 3
Expand Down
20 changes: 19 additions & 1 deletion docs/models-and-results-1.html
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,24 @@ <h3>Model calibration</h3>
## IQ
## -0.088658626</code></pre>
<p>You can see a summary for the regression coefficients object by calling function <code>summary()</code> for the object <code>m$coeffs</code> like it is show below. By default it shows only estimated regression coefficients for the selected y-variable and number of components. However, if you employ Jack-Knifing (see section <em>Variable selection</em> below), the object with regression coefficients will also contain some statistics, including standard error, p-value (for test if the coefficient is equal to zero in populatio) and confidence interval. All statistics in this case will be shown automatically with <code>summary()</code>.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">summary</span>(m$coeffs)</code></pre></div>
<pre><code>## Regression coefficients for Shoesize
## ------------------------------------
## Height Weight Hairleng Age Income
## 0.176077659 0.175803980 -0.164627444 0.046606027 0.059998121
## Beer Wine Sex Swim Region
## 0.133136867 0.002751573 -0.164627444 0.173739533 -0.031357608
## IQ
## -0.003353428</code></pre>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">summary</span>(m$coeffs, <span class="dt">ncomp =</span> <span class="dv">3</span>)</code></pre></div>
<pre><code>## Regression coefficients for Shoesize
## ------------------------------------
## Height Weight Hairleng Age Income
## 0.210411676 0.197646483 -0.138824482 0.026613035 -0.000590693
## Beer Wine Sex Swim Region
## 0.148917913 0.138138095 -0.138824482 0.223962000 0.010392542
## IQ
## -0.088658626</code></pre>
<p>You can also get the corrected coefficients, which can be applied directly to the raw data (without centering and standardization), by using method <code>getRegcoeffs()</code>:</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">show</span>(<span class="kw">getRegcoeffs</span>(m, <span class="dt">ncomp =</span> <span class="dv">3</span>))</code></pre></div>
<pre><code>## Shoesize
Expand Down Expand Up @@ -321,7 +339,7 @@ <h3>Model validation</h3>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">par</span>(<span class="dt">mfrow =</span> <span class="kw">c</span>(<span class="dv">1</span>, <span class="dv">2</span>))
<span class="kw">plotRMSE</span>(m1)
<span class="kw">plotRMSE</span>(m2)</code></pre></div>
<p><img src="_main_files/figure-html/unnamed-chunk-73-1.png" width="864" /></p>
<p><img src="_main_files/figure-html/unnamed-chunk-74-1.png" width="864" /></p>
<p>Parameter <code>cv</code> has the same format as for PCA. If it is a number, it will be used as number of segments for random cross-validation, e.g. if <code>cv = 2</code> cross-validation with two segments will be carried out. For full cross-validation use <code>cv = 1</code> like we did in the example above. For more advanced option you can provide a list with name of cross-validation method, number of segments and number of iterations, e.g. <code>cv = list('rand', 4, 4)</code> for running random cross-validation with four segments and four repetitions or <code>cv = list('ven', 8)</code> for systematic split into eight segments (<em>venetian blinds</em>).</p>
<p>Method <code>summary()</code> for model shows performance statistics calculated using optimal number of components for each of the results.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">summary</span>(m1)</code></pre></div>
Expand Down
8 changes: 4 additions & 4 deletions docs/multiclass-classification.html
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ <h2>Multiclass classification</h2>
<p>Now we apply the combined model to the test set and look at the predictions.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">res =<span class="st"> </span><span class="kw">predict</span>(m, X.t, c.t)
<span class="kw">plotPredictions</span>(res)</code></pre></div>
<p><img src="_main_files/figure-html/unnamed-chunk-97-1.png" width="864" /></p>
<p><img src="_main_files/figure-html/unnamed-chunk-98-1.png" width="864" /></p>
<p>In this case the predictions are shown only for the number of components each model found optimal. The names of classes along y-axis are the individual models. Similarly we can show the predicted values.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">show</span>(res$c.pred[<span class="dv">20</span>:<span class="dv">30</span>, <span class="dv">1</span>, <span class="dv">1</span>:<span class="dv">3</span>])</code></pre></div>
<pre><code>## setosa virginica versicola
Expand All @@ -250,17 +250,17 @@ <h2>Multiclass classification</h2>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">par</span>(<span class="dt">mfrow =</span> <span class="kw">c</span>(<span class="dv">1</span>, <span class="dv">2</span>))
<span class="kw">plotModelDistance</span>(m, <span class="dv">1</span>)
<span class="kw">plotModelDistance</span>(m, <span class="dv">2</span>)</code></pre></div>
<p><img src="_main_files/figure-html/unnamed-chunk-99-1.png" width="864" /></p>
<p><img src="_main_files/figure-html/unnamed-chunk-100-1.png" width="864" /></p>
<p>The second plot is a discrimination power, mentioned in the beginning of the section.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">par</span>(<span class="dt">mfrow =</span> <span class="kw">c</span>(<span class="dv">1</span>, <span class="dv">2</span>))
<span class="kw">plotDiscriminationPower</span>(m, <span class="kw">c</span>(<span class="dv">1</span>, <span class="dv">3</span>), <span class="dt">show.labels =</span> T)
<span class="kw">plotDiscriminationPower</span>(m, <span class="kw">c</span>(<span class="dv">2</span>, <span class="dv">3</span>), <span class="dt">show.labels =</span> T)</code></pre></div>
<p><img src="_main_files/figure-html/unnamed-chunk-100-1.png" width="864" /></p>
<p><img src="_main_files/figure-html/unnamed-chunk-101-1.png" width="864" /></p>
<p>And, finally, a Cooman’s plot showing an orthogonal distance from objects to two selected classes/models.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">par</span>(<span class="dt">mfrow =</span> <span class="kw">c</span>(<span class="dv">1</span>, <span class="dv">2</span>))
<span class="kw">plotCooman</span>(m, <span class="kw">c</span>(<span class="dv">1</span>, <span class="dv">3</span>), <span class="dt">show.labels =</span> T)
<span class="kw">plotCooman</span>(m, <span class="kw">c</span>(<span class="dv">2</span>, <span class="dv">3</span>), <span class="dt">show.labels =</span> T)</code></pre></div>
<p><img src="_main_files/figure-html/unnamed-chunk-101-1.png" width="864" /></p>
<p><img src="_main_files/figure-html/unnamed-chunk-102-1.png" width="864" /></p>

</div>
<!-- </div> -->
Expand Down
4 changes: 2 additions & 2 deletions docs/plotting-methods-1.html
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ <h2>Plotting methods</h2>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">par</span>(<span class="dt">mfrow =</span> <span class="kw">c</span>(<span class="dv">1</span>, <span class="dv">2</span>))
<span class="kw">plotPredictions</span>(m1)
<span class="kw">plotPredictions</span>(m1, <span class="dt">ncomp =</span> <span class="dv">1</span>)</code></pre></div>
<p><img src="_main_files/figure-html/unnamed-chunk-76-1.png" width="864" /></p>
<p><img src="_main_files/figure-html/unnamed-chunk-77-1.png" width="864" /></p>
<p>The plots for variables are available only for a model object and include:</p>
<table>
<colgroup>
Expand Down Expand Up @@ -301,7 +301,7 @@ <h2>Plotting methods</h2>
</table>
<p>And, of course, both model and result objects have method <code>plot()</code> for giving an overview.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">plot</span>(m1)</code></pre></div>
<p><img src="_main_files/figure-html/unnamed-chunk-77-1.png" width="864" /></p>
<p><img src="_main_files/figure-html/unnamed-chunk-78-1.png" width="864" /></p>
<div id="excluding-rows-and-columns-1" class="section level3 unnumbered">
<h3>Excluding rows and columns</h3>
<p>From v. 0.8.0 PCA implementation as well as any other method in <code>mdatools</code> can exclude rows and columns from calculations. The implementation works similar to what was described for PCA. For example it can be useful if you have some candidates for outliers or do variable selection and do not want to remove rows and columns physically from the data matrix. In this case you can just specify two additional parameters, <code>exclcols</code> and <code>exclrows</code>, using either numbers or names of rows/columns to be excluded. You can also specify a vector with logical values (all <code>TRUE</code>s will be excluded).</p>
Expand Down
Loading

0 comments on commit 3e0a013

Please sign in to comment.