Skip to content

Commit

Permalink
Merge branch 'master' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
svkucheryavski committed Oct 30, 2016
2 parents f6d228a + 1e2af91 commit 7d0cbce
Show file tree
Hide file tree
Showing 43 changed files with 1,117 additions and 61 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: mdatools
Title: Multivariate Data Analysis for Chemometrics
Version: 0.8.0
Date: 2016-10-07
Version: 0.8.1
Date: 2016-10-30
Author: Sergey Kucheryavskiy
Maintainer: Sergey Kucheryavskiy <[email protected]>
Description: Package implements projection based methods for preprocessing,
Expand Down
6 changes: 6 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
v.0.8.1
=======
* fixed a bug in PCA when explained variance was calculated incorrectly for data with excluded rows
* fixed several issues with SIMCA (cross-validation) and SIMCAM (Cooman's plot)
* added a chapter about SIMCA to the tutorial

v.0.8.0
=======
* tutorial has been moved from GitBook to Bookdown and fully rewritten
Expand Down
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
v.0.8.1
=======
* fixed a bug in PCA when explained variance was calculated incorrectly for data with excluded rows
* fixed several issues with SIMCA (cross-validation) and SIMCAM (Cooman's plot)
* added a chapter about SIMCA to the tutorial

v.0.8.0
=======
* tutorial has been moved from GitBook to Bookdown and fully rewritten
Expand Down
4 changes: 3 additions & 1 deletion R/ldecomp.R
Original file line number Diff line number Diff line change
Expand Up @@ -238,11 +238,13 @@ ldecomp.getVariances = function(Q, totvar) {
cumresvar = colSums(Q) / totvar * 100
cumexpvar = 100 - cumresvar
expvar = c(cumexpvar[1], diff(cumexpvar))

res = list(
expvar = expvar,
cumexpvar = cumexpvar
)

res
}

#' Statistical limits for Q and T2 residuals
Expand Down
6 changes: 5 additions & 1 deletion R/pca.R
Original file line number Diff line number Diff line change
Expand Up @@ -685,13 +685,17 @@ predict.pca = function(object, x, cal = FALSE, ...) {
x = prep.autoscale(x, center = object$center, scale = object$scale)
scores = x %*% object$loadings
residuals = x - tcrossprod(scores, object$loadings)

# compute total variance
if (length(object$exclcols) > 0){
x = x[, -object$exclcols, drop = F]
attrs$exclcols = object$exclcols
}

if (length(attrs$exclrows) > 0){
x = x[-object$exclrows, ,drop = F]
}

totvar = sum(x^2)

# create and return the results object
Expand Down
8 changes: 1 addition & 7 deletions R/simca.R
Original file line number Diff line number Diff line change
Expand Up @@ -324,20 +324,14 @@ simca.crossval = function(model, x, cv, center = T, scale = F) {
Q[ind, ] = Q[ind, ] + res$Q
T2[ind, ] = T2[ind, ] + res$T2

# compute limits
lim = ldecomp.getResLimits(m$eigenvals, nrow(x.cal), ncomp, model$alpha)
Qlim = Qlim + lim$Qlim
T2lim = T2lim + lim$T2lim
}
}
}

Q = Q / nrep;
T2 = T2 / nrep;
Qlim = Qlim / nrep;
T2lim = T2lim / nrep;

m = list(Qlim = Qlim, T2lim = T2lim, classname = model$classname, ncomp = model$ncomp)
m = list(Qlim = model$Qlim, T2lim = model$T2lim, classname = model$classname, ncomp = model$ncomp)
r = list(Q = Q, T2 = T2, classname = model$classname)
c.pred = simca.classify(m, r)

Expand Down
1 change: 0 additions & 1 deletion R/simcam.R
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ predict.simcam = function(object, x, c.ref = NULL, cv = F, ...) {
pred.res[[i]] = predict(object$models[[i]], x, c.ref)
c.pred[, , i] = pred.res[[i]]$c.pred[, object$models[[i]]$ncomp.selected, ]
}

dimnames(c.pred) = list(rownames(x), paste('Comp'), object$classnames)
c.pred = mda.setattr(c.pred, attrs, 'row')
attr(c.pred, 'name') = 'SIMCAM predictions'
Expand Down
2 changes: 1 addition & 1 deletion R/simcamres.R
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ plotCooman.simcamres = function(obj, nc = c(1, 2), type = 'p', main = "Cooman's
attrs = mda.getattr(obj$c.pred)
res1 = obj$pred.res[[nc[1]]]
res2 = obj$pred.res[[nc[2]]]
data = cbind(sqrt(res1$Q[, res1$ncomp.selected]), sqrt(res2$Q[, res2$ncomp.selected]))
data = cbind(res1$Q[, res1$ncomp.selected], res2$Q[, res2$ncomp.selected])
rownames(data) = rownames(obj$c.pred)
data = mda.setattr(data, attrs, 'row')
if (show.limits == T)
Expand Down
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-61-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.
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.
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.
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.
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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 8 additions & 2 deletions docs/attributes-and-factors.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

<meta name="author" content="Sergey Kucheryavskiy">

<meta name="date" content="2016-10-16">
<meta name="date" content="2016-10-30">

<script type="text/x-mathjax-config">
MathJax.Hub.Config({
Expand Down Expand Up @@ -107,7 +107,7 @@
<ul class="summary">
<li class="chapter" data-level="" data-path="index.html"><a href="index.html"><i class="fa fa-check"></i>Introduction</a></li>
<li class="chapter" data-level="" data-path="what-is-new.html"><a href="what-is-new.html"><i class="fa fa-check"></i>What is new</a><ul>
<li class="chapter" data-level="" data-path="what-is-new.html"><a href="what-is-new.html#what-to-expect-from-future-releases"><i class="fa fa-check"></i>What to expect from future releases</a></li>
<li class="chapter" data-level="" data-path="what-is-new.html"><a href="what-is-new.html#what-expect-from-future-releases"><i class="fa fa-check"></i>What expect from future releases</a></li>
<li class="chapter" data-level="" data-path="what-is-new.html"><a href="what-is-new.html#last-changes-and-improvements-to-book-and-package"><i class="fa fa-check"></i>Last changes and improvements to book and package</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="overview.html"><a href="overview.html"><i class="fa fa-check"></i>Overview</a><ul>
Expand Down Expand Up @@ -159,6 +159,12 @@
</ul></li>
<li class="chapter" data-level="" data-path="variable-selection.html"><a href="variable-selection.html"><i class="fa fa-check"></i>Variable selection</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="simca-classification.html"><a href="simca-classification.html"><i class="fa fa-check"></i>SIMCA classification</a><ul>
<li class="chapter" data-level="" data-path="calibration-and-validation.html"><a href="calibration-and-validation.html"><i class="fa fa-check"></i>Calibration and validation</a><ul>
<li class="chapter" data-level="" data-path="calibration-and-validation.html"><a href="calibration-and-validation.html#predictions-and-validation-with-a-test-set"><i class="fa fa-check"></i>Predictions and validation with a test set</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="multiclass-classification.html"><a href="multiclass-classification.html"><i class="fa fa-check"></i>Multiclass classification</a></li>
</ul></li>
</ul>

</nav>
Expand Down
Loading

0 comments on commit 7d0cbce

Please sign in to comment.