From 352ac6b141e8cf2e4e6c71b5d754a344594b5ee7 Mon Sep 17 00:00:00 2001 From: Sergey Kucheryavskiy Date: Thu, 3 Jan 2019 08:36:48 +0100 Subject: [PATCH 1/4] fixed a bug leading to wrong results for multiclass PLS-DA if level names in class variable are not ordered alphabetically --- R/plsda.R | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/R/plsda.R b/R/plsda.R index eac19b4..2fb9629 100755 --- a/R/plsda.R +++ b/R/plsda.R @@ -217,8 +217,9 @@ plsda.cal = function(x, c, ncomp, center, scale, cv, method, light, alpha, coeff } else { c = checkReferenceValues.classmodel(m, c, x) y = mda.df2mat(as.factor(c), full = TRUE) - classnames = unique(c) + classnames = levels(as.factor(c)) } + y[y == 0] = -1 colnames(y) = classnames rownames(y) = rownames(x) From 811e53f7b968671d55c9dc9ac3e6b2c1481550ef Mon Sep 17 00:00:00 2001 From: Sergey Kucheryavskiy Date: Thu, 3 Jan 2019 08:38:51 +0100 Subject: [PATCH 2/4] small improvements to getConfusionMatrix() related to order of class names in reference class variable --- R/classres.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/classres.R b/R/classres.R index 53025e2..0144906 100755 --- a/R/classres.R +++ b/R/classres.R @@ -208,7 +208,7 @@ getConfusionMatrix.classres = function(obj, ncomp = NULL, ...) { # get class names and numbers classes = dimnames(obj$c.pred)[[3]] nclasses = length(classes) - ref.classes = unique(obj$c.ref) + ref.classes = levels(as.factor(obj$c.ref)) ref.nclasses = length(ref.classes) # compute the confusion matrix From 90b7ed6d253f435f8d87f7aba50ca75094a4e023 Mon Sep 17 00:00:00 2001 From: Sergey Kucheryavskiy Date: Thu, 3 Jan 2019 08:46:54 +0100 Subject: [PATCH 3/4] small updates to texts related to new version --- DESCRIPTION | 4 ++-- NEWS.md | 4 ++++ README.md | 6 +++--- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 70cbfc3..1aa49a6 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: mdatools Title: Multivariate Data Analysis for Chemometrics -Version: 0.9.2 -Date: 2018-11-09 +Version: 0.9.3 +Date: 2019-01-03 Author: Sergey Kucheryavskiy Maintainer: Sergey Kucheryavskiy Description: Package implements projection based methods for preprocessing, diff --git a/NEWS.md b/NEWS.md index b3adeea..340e639 100755 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,7 @@ +v.0.9.3 +======= +* fixed a bug leading to wrong results in multiclass PLS-DA if class labels in reference class variable (factor) were not in alphabetical order + v.0.9.2 ======= * improvements to `ipls()` method plus fixed a bug preventing breaking the selection loop (#56) diff --git a/README.md b/README.md index 0bc43eb..b4d9c25 100755 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ For more details and examples read a [Bookdown tutorial](http://svkucheryavski.g What is new ----------- -New minor release (0.9.2) is available both from GitHub and CRAN (from 9.11.2018). +New minor release (0.9.3) is available both from GitHub and CRAN (from 3.01.2019). The latest major release (0.9.0) brings a set of new features, including methods for computing of critical limits for PCA/SIMCA residuals, adjuested residuals plot, and randomized algorithms for fast PCA decomposition of dataset with large number of rows. The text of tutorial has been amended correspondingly and now also includes a new chapter with detailed explanation of calculation of the critical limits. @@ -20,10 +20,10 @@ A full list of changes is available [here](NEWS.md) How to install -------------- -The package is available from CRAN by usual installing procedure. However due to restrictions in CRAN politics regarding number of submissions (one in 3-4 month) only major releases will be published there (with 2-3 weeks delay after GitHub release as more thorought testing is needed). To get the latest release plase use [GitHub sources](https://github.com/svkucheryavski/mdatools). You can [download](https://github.com/svkucheryavski/mdatools/releases) a zip-file with source package and install it using the `install.packages` command, e.g. if the downloaded file is `mdatools_0.9.2.tar.gz` and it is located in a current working directory, just run the following: +The package is available from CRAN by usual installing procedure. However due to restrictions in CRAN politics regarding number of submissions (one in 3-4 month) only major releases will be published there (with 2-3 weeks delay after GitHub release as more thorought testing is needed). To get the latest release plase use [GitHub sources](https://github.com/svkucheryavski/mdatools). You can [download](https://github.com/svkucheryavski/mdatools/releases) a zip-file with source package and install it using the `install.packages` command, e.g. if the downloaded file is `mdatools_0.9.3.tar.gz` and it is located in a current working directory, just run the following: ``` -install.packages('mdatools_0.9.2.tar.gz') +install.packages('mdatools_0.9.3.tar.gz') ``` If you have `devtools` package installed, the following command will install the latest release from the master branch of GitHub repository (do not forget to load the `devtools` package first): From a129cefac73cd4d95381df3cfaf2599560c55448 Mon Sep 17 00:00:00 2001 From: Sergey Kucheryavskiy Date: Thu, 3 Jan 2019 09:40:53 +0100 Subject: [PATCH 4/4] Help files were re-created. --- DESCRIPTION | 3 ++- NAMESPACE | 2 ++ R/pca.R | 4 +++- R/pls.R | 4 +++- man/getRegcoeffs.pls.Rd | 7 ++++--- man/ipls.Rd | 7 ++++--- man/ldecomp.getDistances.Rd | 3 ++- man/mdaplot.Rd | 9 +++++---- man/mdaplot.getAxesLim.Rd | 4 ++-- man/mdaplot.plotAxes.Rd | 6 +++--- man/mdaplot.showLines.Rd | 3 ++- man/mdaplot.showRegressionLine.Rd | 4 ++-- man/mdaplotg.Rd | 15 ++++++++------- man/pca.Rd | 7 ++++--- man/pca.cal.Rd | 4 ++-- man/pca.mvreplace.Rd | 4 ++-- man/plot.randtest.Rd | 4 ++-- man/plot.regcoeffs.Rd | 6 +++--- man/plotCooman.simcamres.Rd | 4 ++-- man/plotCumVariance.ldecomp.Rd | 4 ++-- man/plotModelDistance.simcam.Rd | 4 ++-- man/plotPerformance.classmodel.Rd | 6 +++--- man/plotPredictions.plsres.Rd | 4 ++-- man/plotPredictions.regres.Rd | 6 +++--- man/plotRMSE.ipls.Rd | 14 +++++++------- man/plotRMSE.regres.Rd | 3 ++- man/plotResiduals.pcares.Rd | 4 ++-- man/plotResiduals.simcares.Rd | 6 +++--- man/plotScores.pca.Rd | 6 +++--- man/plotSelection.ipls.Rd | 5 +++-- man/plotSelectivityRatio.pls.Rd | 4 ++-- man/plotVariance.ldecomp.Rd | 4 ++-- man/plotVariance.pca.Rd | 4 ++-- man/plotVariance.pls.Rd | 7 ++++--- man/plotXCumVariance.plsres.Rd | 3 ++- man/plotXResiduals.pls.Rd | 4 ++-- man/plotXScores.plsres.Rd | 3 ++- man/plotYCumVariance.plsres.Rd | 3 ++- man/plotYResiduals.regres.Rd | 4 ++-- man/pls.Rd | 9 ++++++--- man/pls.cal.Rd | 5 +++-- man/plsda.Rd | 5 +++-- man/prep.autoscale.Rd | 9 +++++++-- man/randtest.Rd | 3 ++- man/selectCompNum.Rd | 4 +++- man/selectCompNum.pca.Rd | 4 +++- man/selectCompNum.pls.Rd | 13 +++++++++++-- man/setResLimits.pca.Rd | 3 ++- man/summary.regcoeffs.Rd | 3 ++- 49 files changed, 151 insertions(+), 105 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 1aa49a6..5eca34e 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -6,11 +6,12 @@ Author: Sergey Kucheryavskiy Maintainer: Sergey Kucheryavskiy Description: Package implements projection based methods for preprocessing, exploring and analysis of multivariate data used in chemometrics. +Encoding: UTF-8 License: MIT + file LICENSE Imports: methods, graphics, grDevices, stats -RoxygenNote: 6.0.1 +RoxygenNote: 6.1.1 Suggests: testthat diff --git a/NAMESPACE b/NAMESPACE index 038c6fe..1674d5e 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -130,6 +130,8 @@ S3method(summary,simca) S3method(summary,simcam) S3method(summary,simcamres) S3method(summary,simcares) +export(classres) +export(crossval) export(erfinv) export(getCalibrationData) export(getConfusionMatrix) diff --git a/R/pca.R b/R/pca.R index d1b5741..c996eb1 100755 --- a/R/pca.R +++ b/R/pca.R @@ -222,12 +222,14 @@ getCalibrationData.pca = function(obj, ...) { #' PCA model (object of class \code{pca}) #' @param ncomp #' number of components to select +#' @param ... +#' other parameters if any #' #' @return #' the same model with selected number of components #' #' @export -selectCompNum.pca = function(model, ncomp) { +selectCompNum.pca = function(model, ncomp, ...) { if (ncomp < 1 || ncomp > model$ncomp) stop('Wrong number of selected components!') diff --git a/R/pls.R b/R/pls.R index 46220cd..bb598ad 100755 --- a/R/pls.R +++ b/R/pls.R @@ -801,6 +801,8 @@ pls.crossval = function(model, x, y, cv, center, scale, method, jack.knife = T) #' @param selcrit #' criterion for selecting optimal number of components (\code{'min'} for #' first local minimum of RMSECV and \code{'wold'} for Wold's rule.) +#' @param ... +#' other parameters if any #' #' @return #' the same model with selected number of components @@ -813,7 +815,7 @@ pls.crossval = function(model, x, y, cv, center, scale, method, jack.knife = T) #' See examples in help for \code{\link{pls}} function. #' #' @export -selectCompNum.pls = function(model, ncomp = NULL, selcrit = model$ncomp.selcrit) { +selectCompNum.pls = function(model, ncomp = NULL, selcrit = model$ncomp.selcrit, ...) { if (!is.null(ncomp)) { # user defined number of components if (ncomp > model$ncomp || ncomp < 0) diff --git a/man/getRegcoeffs.pls.Rd b/man/getRegcoeffs.pls.Rd index 7c64109..0d3babe 100644 --- a/man/getRegcoeffs.pls.Rd +++ b/man/getRegcoeffs.pls.Rd @@ -4,8 +4,8 @@ \alias{getRegcoeffs.pls} \title{Regression coefficients for PLS model'} \usage{ -\method{getRegcoeffs}{pls}(obj, ncomp = NULL, ny = NULL, full = FALSE, - alpha = obj$coeffs.alpha, ...) +\method{getRegcoeffs}{pls}(obj, ncomp = NULL, ny = NULL, + full = FALSE, alpha = obj$coeffs.alpha, ...) } \arguments{ \item{obj}{a PLS model (object of class \code{pls})} @@ -14,7 +14,8 @@ \item{ny}{if y is multivariate which variables you want to see the coefficients for} -\item{full}{if TRUE the method also shows p-values and t-values as well as confidence intervals for the coefficients (if available)} +\item{full}{if TRUE the method also shows p-values and t-values as well as confidence intervals for the +coefficients (if available)} \item{alpha}{significance level for confidence intervals (a number between 0 and 1, e.g. for 95\% alpha = 0.05)} diff --git a/man/ipls.Rd b/man/ipls.Rd index 9c1af51..1db67aa 100644 --- a/man/ipls.Rd +++ b/man/ipls.Rd @@ -5,9 +5,10 @@ \title{Variable selection with interval PLS} \usage{ ipls(x, y, glob.ncomp = 10, center = T, scale = F, cv = 10, - exclcols = NULL, exclrows = NULL, int.ncomp = 10, int.num = NULL, - int.width = NULL, int.limits = NULL, int.niter = NULL, - ncomp.selcrit = "min", method = "forward", silent = F) + exclcols = NULL, exclrows = NULL, int.ncomp = glob.ncomp, + int.num = NULL, int.width = NULL, int.limits = NULL, + int.niter = NULL, ncomp.selcrit = "min", method = "forward", + silent = F) } \arguments{ \item{x}{a matrix with predictor values} diff --git a/man/ldecomp.getDistances.Rd b/man/ldecomp.getDistances.Rd index 1a5504c..97666c8 100644 --- a/man/ldecomp.getDistances.Rd +++ b/man/ldecomp.getDistances.Rd @@ -4,7 +4,8 @@ \alias{ldecomp.getDistances} \title{Residuals distances for linear decomposition} \usage{ -ldecomp.getDistances(scores, loadings, residuals, tnorm = NULL, cal = FALSE) +ldecomp.getDistances(scores, loadings, residuals, tnorm = NULL, + cal = FALSE) } \arguments{ \item{scores}{matrix with scores (T).} diff --git a/man/mdaplot.Rd b/man/mdaplot.Rd index e684942..b061293 100644 --- a/man/mdaplot.Rd +++ b/man/mdaplot.Rd @@ -9,10 +9,11 @@ mdaplot(data = NULL, plot.data = NULL, type = "p", pch = 16, xlim = NULL, ylim = NULL, colmap = "default", labels = NULL, main = NULL, xlab = NULL, ylab = NULL, show.labels = F, show.colorbar = T, show.lines = F, show.grid = T, show.axes = T, - xticks = NULL, yticks = NULL, xticklabels = NULL, yticklabels = NULL, - xlas = 0, ylas = 0, lab.col = "darkgray", lab.cex = 0.65, - show.excluded = FALSE, col.excluded = "#E0E0E0", nbins = 256, - colramp = mdaplot.getColors, force.x.values = NA, opacity = 1, ...) + xticks = NULL, yticks = NULL, xticklabels = NULL, + yticklabels = NULL, xlas = 0, ylas = 0, lab.col = "darkgray", + lab.cex = 0.65, show.excluded = FALSE, col.excluded = "#E0E0E0", + nbins = 256, colramp = mdaplot.getColors, force.x.values = NA, + opacity = 1, ...) } \arguments{ \item{data}{a vector, matrix or a data.frame with data values.} diff --git a/man/mdaplot.getAxesLim.Rd b/man/mdaplot.getAxesLim.Rd index efe238e..f3cbdfa 100644 --- a/man/mdaplot.getAxesLim.Rd +++ b/man/mdaplot.getAxesLim.Rd @@ -5,8 +5,8 @@ \title{Calculate axes limits} \usage{ mdaplot.getAxesLim(x.values, y.values, lower = NULL, upper = NULL, - show.colorbar = F, show.lines = F, legend = NULL, show.legend = F, - legend.position = "topright", show.labels = F) + show.colorbar = F, show.lines = F, legend = NULL, + show.legend = F, legend.position = "topright", show.labels = F) } \arguments{ \item{x.values}{a vector with x values.} diff --git a/man/mdaplot.plotAxes.Rd b/man/mdaplot.plotAxes.Rd index b336f73..62960ef 100644 --- a/man/mdaplot.plotAxes.Rd +++ b/man/mdaplot.plotAxes.Rd @@ -4,9 +4,9 @@ \alias{mdaplot.plotAxes} \title{Create axes plane} \usage{ -mdaplot.plotAxes(xticklabels = NULL, yticklabels = NULL, xticks = NULL, - yticks = NULL, lim = NULL, main = NULL, xlab = NULL, ylab = NULL, - xlas = 0, ylas = 0) +mdaplot.plotAxes(xticklabels = NULL, yticklabels = NULL, + xticks = NULL, yticks = NULL, lim = NULL, main = NULL, + xlab = NULL, ylab = NULL, xlas = 0, ylas = 0) } \arguments{ \item{xticklabels}{labels for x ticks} diff --git a/man/mdaplot.showLines.Rd b/man/mdaplot.showLines.Rd index 9eb9610..b554fb9 100644 --- a/man/mdaplot.showLines.Rd +++ b/man/mdaplot.showLines.Rd @@ -4,7 +4,8 @@ \alias{mdaplot.showLines} \title{Plot lines} \usage{ -mdaplot.showLines(point, lty = 2, lwd = 0.75, col = rgb(0.2, 0.2, 0.2)) +mdaplot.showLines(point, lty = 2, lwd = 0.75, col = rgb(0.2, 0.2, + 0.2)) } \arguments{ \item{point}{vector with two values: x coordinate for vertical point y for horizontal} diff --git a/man/mdaplot.showRegressionLine.Rd b/man/mdaplot.showRegressionLine.Rd index a4517e5..a99d36c 100644 --- a/man/mdaplot.showRegressionLine.Rd +++ b/man/mdaplot.showRegressionLine.Rd @@ -4,8 +4,8 @@ \alias{mdaplot.showRegressionLine} \title{Regression line for data points} \usage{ -mdaplot.showRegressionLine(data, lty = 1, lwd = 1, colmap = "default", - col = NULL) +mdaplot.showRegressionLine(data, lty = 1, lwd = 1, + colmap = "default", col = NULL) } \arguments{ \item{data}{data values} diff --git a/man/mdaplotg.Rd b/man/mdaplotg.Rd index 9f7b746..78929b4 100644 --- a/man/mdaplotg.Rd +++ b/man/mdaplotg.Rd @@ -4,13 +4,14 @@ \alias{mdaplotg} \title{Plotting function for several sets of objects} \usage{ -mdaplotg(data, groupby = NULL, type = "p", pch = 16, lty = 1, lwd = 1, - bwd = 0.8, legend = NULL, xlab = NULL, ylab = NULL, main = NULL, - labels = NULL, ylim = NULL, xlim = NULL, colmap = "default", - legend.position = "topright", show.legend = T, show.labels = F, - show.lines = F, show.grid = T, xticks = NULL, xticklabels = NULL, - yticks = NULL, yticklabels = NULL, show.excluded = FALSE, - lab.col = "darkgray", lab.cex = 0.65, xlas = 1, ylas = 1, ...) +mdaplotg(data, groupby = NULL, type = "p", pch = 16, lty = 1, + lwd = 1, bwd = 0.8, legend = NULL, xlab = NULL, ylab = NULL, + main = NULL, labels = NULL, ylim = NULL, xlim = NULL, + colmap = "default", legend.position = "topright", show.legend = T, + show.labels = F, show.lines = F, show.grid = T, xticks = NULL, + xticklabels = NULL, yticks = NULL, yticklabels = NULL, + show.excluded = FALSE, lab.col = "darkgray", lab.cex = 0.65, + xlas = 1, ylas = 1, ...) } \arguments{ \item{data}{a matrix, data frame or a list with data values (see details below).} diff --git a/man/pca.Rd b/man/pca.Rd index 2a6e76c..5907c5a 100644 --- a/man/pca.Rd +++ b/man/pca.Rd @@ -4,9 +4,10 @@ \alias{pca} \title{Principal Component Analysis} \usage{ -pca(x, ncomp = 15, center = T, scale = F, cv = NULL, exclrows = NULL, - exclcols = NULL, x.test = NULL, method = "svd", rand = NULL, - lim.type = "jm", alpha = 0.05, gamma = 0.01, info = "") +pca(x, ncomp = 15, center = T, scale = F, cv = NULL, + exclrows = NULL, exclcols = NULL, x.test = NULL, method = "svd", + rand = NULL, lim.type = "jm", alpha = 0.05, gamma = 0.01, + info = "") } \arguments{ \item{x}{a numerical matrix with calibration data.} diff --git a/man/pca.cal.Rd b/man/pca.cal.Rd index 4341ea5..78d0688 100644 --- a/man/pca.cal.Rd +++ b/man/pca.cal.Rd @@ -4,8 +4,8 @@ \alias{pca.cal} \title{PCA model calibration} \usage{ -pca.cal(x, ncomp, center, scale, method, exclcols = NULL, exclrows = NULL, - cv, rand, lim.type, alpha, gamma, info) +pca.cal(x, ncomp, center, scale, method, exclcols = NULL, + exclrows = NULL, cv, rand, lim.type, alpha, gamma, info) } \arguments{ \item{x}{matrix with data values} diff --git a/man/pca.mvreplace.Rd b/man/pca.mvreplace.Rd index f4b32c6..7be265f 100644 --- a/man/pca.mvreplace.Rd +++ b/man/pca.mvreplace.Rd @@ -4,8 +4,8 @@ \alias{pca.mvreplace} \title{Replace missing values in data} \usage{ -pca.mvreplace(x, center = T, scale = F, maxncomp = 7, expvarlim = 0.95, - covlim = 10^-6, maxiter = 100) +pca.mvreplace(x, center = T, scale = F, maxncomp = 7, + expvarlim = 0.95, covlim = 10^-6, maxiter = 100) } \arguments{ \item{x}{a matrix with data, containing missing values.} diff --git a/man/plot.randtest.Rd b/man/plot.randtest.Rd index 8b00ea4..2d15577 100644 --- a/man/plot.randtest.Rd +++ b/man/plot.randtest.Rd @@ -4,8 +4,8 @@ \alias{plot.randtest} \title{Plot for randomization test results} \usage{ -\method{plot}{randtest}(x, main = "Alpha", xlab = "Components", ylab = "", - ...) +\method{plot}{randtest}(x, main = "Alpha", xlab = "Components", + ylab = "", ...) } \arguments{ \item{x}{results of randomization test (object of class `randtest`)} diff --git a/man/plot.regcoeffs.Rd b/man/plot.regcoeffs.Rd index 5e92382..bd4f9d3 100644 --- a/man/plot.regcoeffs.Rd +++ b/man/plot.regcoeffs.Rd @@ -4,9 +4,9 @@ \alias{plot.regcoeffs} \title{Regression coefficients plot} \usage{ -\method{plot}{regcoeffs}(x, ncomp = 1, ny = 1, type = NULL, col = NULL, - main = NULL, ylab = NULL, show.line = T, show.ci = T, alpha = 0.05, - ...) +\method{plot}{regcoeffs}(x, ncomp = 1, ny = 1, type = NULL, + col = NULL, main = NULL, ylab = NULL, show.line = T, + show.ci = T, alpha = 0.05, ...) } \arguments{ \item{x}{regression coefficients object (class \code{regcoeffs})} diff --git a/man/plotCooman.simcamres.Rd b/man/plotCooman.simcamres.Rd index 6e37658..0a609f0 100644 --- a/man/plotCooman.simcamres.Rd +++ b/man/plotCooman.simcamres.Rd @@ -5,8 +5,8 @@ \title{Cooman's plot for SIMCAM results} \usage{ \method{plotCooman}{simcamres}(obj, nc = c(1, 2), type = "p", - main = "Cooman's plot", xlab = NULL, ylab = NULL, show.limits = T, - legend = NULL, ...) + main = "Cooman's plot", xlab = NULL, ylab = NULL, + show.limits = T, legend = NULL, ...) } \arguments{ \item{obj}{SIMCAM results (object of class \code{simcamres})} diff --git a/man/plotCumVariance.ldecomp.Rd b/man/plotCumVariance.ldecomp.Rd index a2bb956..a66aee6 100644 --- a/man/plotCumVariance.ldecomp.Rd +++ b/man/plotCumVariance.ldecomp.Rd @@ -6,8 +6,8 @@ \usage{ \method{plotCumVariance}{ldecomp}(obj, type = "b", main = "Cumulative variance", xlab = "Components", - ylab = "Explained variance, \%", show.labels = F, labels = "values", - ...) + ylab = "Explained variance, \%", show.labels = F, + labels = "values", ...) } \arguments{ \item{obj}{object of \code{ldecomp} class.} diff --git a/man/plotModelDistance.simcam.Rd b/man/plotModelDistance.simcam.Rd index 10ebbc3..5b2c3ff 100644 --- a/man/plotModelDistance.simcam.Rd +++ b/man/plotModelDistance.simcam.Rd @@ -4,8 +4,8 @@ \alias{plotModelDistance.simcam} \title{Modelling distance plot for SIMCAM model} \usage{ -\method{plotModelDistance}{simcam}(obj, nc = 1, type = "h", main = NULL, - xlab = "Models", ylab = "", ...) +\method{plotModelDistance}{simcam}(obj, nc = 1, type = "h", + main = NULL, xlab = "Models", ylab = "", ...) } \arguments{ \item{obj}{a SIMCAM model (object of class \code{simcam})} diff --git a/man/plotPerformance.classmodel.Rd b/man/plotPerformance.classmodel.Rd index f296b8d..d8f48bc 100644 --- a/man/plotPerformance.classmodel.Rd +++ b/man/plotPerformance.classmodel.Rd @@ -4,9 +4,9 @@ \alias{plotPerformance.classmodel} \title{Performance plot for classification model} \usage{ -\method{plotPerformance}{classmodel}(obj, nc = NULL, param = "specificity", - type = "h", main = NULL, xlab = "Components", ylab = "", ylim = c(0, - 1.15), ...) +\method{plotPerformance}{classmodel}(obj, nc = NULL, + param = "specificity", type = "h", main = NULL, + xlab = "Components", ylab = "", ylim = c(0, 1.15), ...) } \arguments{ \item{obj}{classification model (object of class \code{plsda}, \code{simca}, etc.).} diff --git a/man/plotPredictions.plsres.Rd b/man/plotPredictions.plsres.Rd index a42cdce..d695b3c 100644 --- a/man/plotPredictions.plsres.Rd +++ b/man/plotPredictions.plsres.Rd @@ -4,8 +4,8 @@ \alias{plotPredictions.plsres} \title{Predictions plot for PLS results} \usage{ -\method{plotPredictions}{plsres}(obj, ny = 1, ncomp = NULL, main = NULL, - ...) +\method{plotPredictions}{plsres}(obj, ny = 1, ncomp = NULL, + main = NULL, ...) } \arguments{ \item{obj}{PLS results (object of class \code{plsres})} diff --git a/man/plotPredictions.regres.Rd b/man/plotPredictions.regres.Rd index b736d52..8760258 100644 --- a/man/plotPredictions.regres.Rd +++ b/man/plotPredictions.regres.Rd @@ -4,9 +4,9 @@ \alias{plotPredictions.regres} \title{Predictions plot for regression results} \usage{ -\method{plotPredictions}{regres}(obj, ny = 1, ncomp = NULL, show.line = T, - show.stat = F, stat.col = "#606060", stat.cex = 0.85, axes.equal = T, - col = mdaplot.getColors(1), ...) +\method{plotPredictions}{regres}(obj, ny = 1, ncomp = NULL, + show.line = T, show.stat = F, stat.col = "#606060", + stat.cex = 0.85, axes.equal = T, col = mdaplot.getColors(1), ...) } \arguments{ \item{obj}{regression results (object of class \code{regres})} diff --git a/man/plotRMSE.ipls.Rd b/man/plotRMSE.ipls.Rd index 17c6698..32d3299 100644 --- a/man/plotRMSE.ipls.Rd +++ b/man/plotRMSE.ipls.Rd @@ -4,8 +4,9 @@ \alias{plotRMSE.ipls} \title{RMSE development plot} \usage{ -\method{plotRMSE}{ipls}(obj, glob.ncomp = NULL, main = "RMSE development", - xlab = "Iterations", ylab = "RMSECV", xlim = NULL, ylim = NULL, ...) +\method{plotRMSE}{ipls}(obj, glob.ncomp = NULL, + main = "RMSE development", xlab = "Iterations", ylab = "RMSECV", + xlim = NULL, ylim = NULL, ...) } \arguments{ \item{obj}{iPLS results (object of class ipls)} @@ -29,11 +30,10 @@ Shows how RMSE develops for each iteration of iPLS selection algorithm } \details{ -The plot shows RMSE values obtained at each iteration of the iPLS selection -algorithm as bars. The first bar correspond to the global model with all variables -included, second - to the model obtained at the first iteration and so on. Number -at the bottom of each bar corresponds to the interval included or excluded at the -particular iteration. The selected intervals are shown with green color. +The plot shows RMSE values obtained at each iteration of the iPLS algorithm as bars. The first +bar correspond to the global model with all variables included, second - to the model obtained +at the first iteration and so on. Number at the bottom of each bar corresponds to the interval +included or excluded at the particular iteration. } \seealso{ \code{\link{summary.ipls}}, \code{\link{plotSelection.ipls}} diff --git a/man/plotRMSE.regres.Rd b/man/plotRMSE.regres.Rd index a7bb5bb..e76c870 100644 --- a/man/plotRMSE.regres.Rd +++ b/man/plotRMSE.regres.Rd @@ -4,7 +4,8 @@ \alias{plotRMSE.regres} \title{RMSE plot for regression results} \usage{ -\method{plotRMSE}{regres}(obj, ny = 1, type = "b", labels = "values", ...) +\method{plotRMSE}{regres}(obj, ny = 1, type = "b", labels = "values", + ...) } \arguments{ \item{obj}{regression results (object of class \code{regres})} diff --git a/man/plotResiduals.pcares.Rd b/man/plotResiduals.pcares.Rd index d1c73ea..050ae9b 100644 --- a/man/plotResiduals.pcares.Rd +++ b/man/plotResiduals.pcares.Rd @@ -6,8 +6,8 @@ \usage{ \method{plotResiduals}{pcares}(obj, ncomp = NULL, main = NULL, xlab = NULL, ylab = NULL, show.labels = F, show.limits = T, - norm = F, xlim = NULL, ylim = NULL, lim.col = c("#333333", "#333333"), - lim.lwd = c(1, 1), lim.lty = c(2, 3), ...) + norm = F, xlim = NULL, ylim = NULL, lim.col = c("#333333", + "#333333"), lim.lwd = c(1, 1), lim.lty = c(2, 3), ...) } \arguments{ \item{obj}{object of \code{ldecomp} class.} diff --git a/man/plotResiduals.simcares.Rd b/man/plotResiduals.simcares.Rd index 0b47a9a..ab3d298 100644 --- a/man/plotResiduals.simcares.Rd +++ b/man/plotResiduals.simcares.Rd @@ -5,9 +5,9 @@ \title{Residuals plot for SIMCA results} \usage{ \method{plotResiduals}{simcares}(obj, ncomp = NULL, main = NULL, - xlab = NULL, ylab = NULL, norm = F, show.limits = T, legend = NULL, - lim.col = c("#c0a0a0", "#906060"), lim.lwd = c(1, 1), lim.lty = c(2, 3), - ...) + xlab = NULL, ylab = NULL, norm = F, show.limits = T, + legend = NULL, lim.col = c("#c0a0a0", "#906060"), lim.lwd = c(1, + 1), lim.lty = c(2, 3), ...) } \arguments{ \item{obj}{SIMCA results (object of class \code{simcares})} diff --git a/man/plotScores.pca.Rd b/man/plotScores.pca.Rd index d20d5c3..00fac45 100644 --- a/man/plotScores.pca.Rd +++ b/man/plotScores.pca.Rd @@ -4,9 +4,9 @@ \alias{plotScores.pca} \title{Scores plot for PCA} \usage{ -\method{plotScores}{pca}(obj, comp = c(1, 2), type = "p", main = "Scores", - xlab = NULL, ylab = NULL, show.labels = F, show.legend = NULL, - cgroup = NULL, show.axes = TRUE, ...) +\method{plotScores}{pca}(obj, comp = c(1, 2), type = "p", + main = "Scores", xlab = NULL, ylab = NULL, show.labels = F, + show.legend = NULL, cgroup = NULL, show.axes = TRUE, ...) } \arguments{ \item{obj}{a PCA model (object of class \code{pca})} diff --git a/man/plotSelection.ipls.Rd b/man/plotSelection.ipls.Rd index dae1574..17ffb00 100644 --- a/man/plotSelection.ipls.Rd +++ b/man/plotSelection.ipls.Rd @@ -4,8 +4,9 @@ \alias{plotSelection.ipls} \title{iPLS performance plot} \usage{ -\method{plotSelection}{ipls}(obj, glob.ncomp = NULL, main = "iPLS results", - xlab = obj$xaxis.name, ylab = "RMSECV", xlim = NULL, ylim = NULL, ...) +\method{plotSelection}{ipls}(obj, glob.ncomp = NULL, + main = "iPLS results", xlab = obj$xaxis.name, ylab = "RMSECV", + xlim = NULL, ylim = NULL, ...) } \arguments{ \item{obj}{iPLS results (object of class ipls)} diff --git a/man/plotSelectivityRatio.pls.Rd b/man/plotSelectivityRatio.pls.Rd index febe11d..ca9bbae 100644 --- a/man/plotSelectivityRatio.pls.Rd +++ b/man/plotSelectivityRatio.pls.Rd @@ -4,8 +4,8 @@ \alias{plotSelectivityRatio.pls} \title{Selectivity ratio plot for PLS model} \usage{ -\method{plotSelectivityRatio}{pls}(obj, ncomp = NULL, ny = 1, type = "l", - main = NULL, ylab = "", ...) +\method{plotSelectivityRatio}{pls}(obj, ncomp = NULL, ny = 1, + type = "l", main = NULL, ylab = "", ...) } \arguments{ \item{obj}{a PLS model (object of class \code{pls})} diff --git a/man/plotVariance.ldecomp.Rd b/man/plotVariance.ldecomp.Rd index 53b075a..5086811 100644 --- a/man/plotVariance.ldecomp.Rd +++ b/man/plotVariance.ldecomp.Rd @@ -5,8 +5,8 @@ \title{Explained variance plot for linear decomposition} \usage{ \method{plotVariance}{ldecomp}(obj, type = "b", main = "Variance", - xlab = "Components", ylab = "Explained variance, \%", show.labels = F, - labels = "values", ...) + xlab = "Components", ylab = "Explained variance, \%", + show.labels = F, labels = "values", ...) } \arguments{ \item{obj}{object of \code{ldecomp} class.} diff --git a/man/plotVariance.pca.Rd b/man/plotVariance.pca.Rd index 5355772..ffffcdf 100644 --- a/man/plotVariance.pca.Rd +++ b/man/plotVariance.pca.Rd @@ -5,8 +5,8 @@ \title{Explained variance plot for PCA} \usage{ \method{plotVariance}{pca}(obj, type = "b", variance = "expvar", - main = "Variance", xlab = "Components", ylab = "Explained variance, \%", - show.legend = T, ...) + main = "Variance", xlab = "Components", + ylab = "Explained variance, \%", show.legend = T, ...) } \arguments{ \item{obj}{a PCA model (object of class \code{pca})} diff --git a/man/plotVariance.pls.Rd b/man/plotVariance.pls.Rd index 8cd5724..e782518 100644 --- a/man/plotVariance.pls.Rd +++ b/man/plotVariance.pls.Rd @@ -4,9 +4,10 @@ \alias{plotVariance.pls} \title{Variance plot for PLS} \usage{ -\method{plotVariance}{pls}(obj, decomp = "xdecomp", variance = "expvar", - type = "b", main = "X variance", xlab = "Components", - ylab = "Explained variance, \%", labels = "values", ...) +\method{plotVariance}{pls}(obj, decomp = "xdecomp", + variance = "expvar", type = "b", main = "X variance", + xlab = "Components", ylab = "Explained variance, \%", + labels = "values", ...) } \arguments{ \item{obj}{a PLS model (object of class \code{pls})} diff --git a/man/plotXCumVariance.plsres.Rd b/man/plotXCumVariance.plsres.Rd index f6083a0..42edf37 100644 --- a/man/plotXCumVariance.plsres.Rd +++ b/man/plotXCumVariance.plsres.Rd @@ -4,7 +4,8 @@ \alias{plotXCumVariance.plsres} \title{Explained cumulative X variance plot for PLS results} \usage{ -\method{plotXCumVariance}{plsres}(obj, main = "X cumulative variance", ...) +\method{plotXCumVariance}{plsres}(obj, main = "X cumulative variance", + ...) } \arguments{ \item{obj}{PLS results (object of class \code{plsres})} diff --git a/man/plotXResiduals.pls.Rd b/man/plotXResiduals.pls.Rd index e13cbfd..8256b80 100644 --- a/man/plotXResiduals.pls.Rd +++ b/man/plotXResiduals.pls.Rd @@ -4,8 +4,8 @@ \alias{plotXResiduals.pls} \title{X residuals plot for PLS} \usage{ -\method{plotXResiduals}{pls}(obj, ncomp = NULL, main = NULL, xlab = "T2", - ylab = "Squared residual distance (Q)", ...) +\method{plotXResiduals}{pls}(obj, ncomp = NULL, main = NULL, + xlab = "T2", ylab = "Squared residual distance (Q)", ...) } \arguments{ \item{obj}{a PLS model (object of class \code{pls})} diff --git a/man/plotXScores.plsres.Rd b/man/plotXScores.plsres.Rd index 6085580..3aca554 100644 --- a/man/plotXScores.plsres.Rd +++ b/man/plotXScores.plsres.Rd @@ -4,7 +4,8 @@ \alias{plotXScores.plsres} \title{X scores plot for PLS results} \usage{ -\method{plotXScores}{plsres}(obj, comp = c(1, 2), main = "X scores", ...) +\method{plotXScores}{plsres}(obj, comp = c(1, 2), main = "X scores", + ...) } \arguments{ \item{obj}{PLS results (object of class \code{plsres})} diff --git a/man/plotYCumVariance.plsres.Rd b/man/plotYCumVariance.plsres.Rd index dedb67d..09f448b 100644 --- a/man/plotYCumVariance.plsres.Rd +++ b/man/plotYCumVariance.plsres.Rd @@ -4,7 +4,8 @@ \alias{plotYCumVariance.plsres} \title{Explained cumulative Y variance plot for PLS results} \usage{ -\method{plotYCumVariance}{plsres}(obj, main = "Y cumulative variance", ...) +\method{plotYCumVariance}{plsres}(obj, main = "Y cumulative variance", + ...) } \arguments{ \item{obj}{PLS results (object of class \code{plsres})} diff --git a/man/plotYResiduals.regres.Rd b/man/plotYResiduals.regres.Rd index 2c93ee8..be7ae5c 100644 --- a/man/plotYResiduals.regres.Rd +++ b/man/plotYResiduals.regres.Rd @@ -4,8 +4,8 @@ \alias{plotYResiduals.regres} \title{Residuals plot for regression results} \usage{ -\method{plotYResiduals}{regres}(obj, ny = 1, ncomp = NULL, show.line = T, - ...) +\method{plotYResiduals}{regres}(obj, ny = 1, ncomp = NULL, + show.line = T, ...) } \arguments{ \item{obj}{regression results (object of class \code{regres})} diff --git a/man/pls.Rd b/man/pls.Rd index 8d0b310..4c40bd0 100644 --- a/man/pls.Rd +++ b/man/pls.Rd @@ -55,11 +55,14 @@ Returns an object of \code{pls} class with following fields: \item{weights }{matrix with PLS weights.} \item{selratio }{array with selectivity ratio values.} \item{vipscores }{matrix with VIP scores values.} -\item{coeffs }{object of class \code{\link{regcoeffs}} with regression coefficients calculated for each component.} +\item{coeffs }{object of class \code{\link{regcoeffs}} with regression coefficients calculated +for each component.} \item{info }{information about the model, provided by user when build the model.} \item{calres }{an object of class \code{\link{plsres}} with PLS results for a calibration data.} -\item{testres }{an object of class \code{\link{plsres}} with PLS results for a test data, if it was provided.} -\item{cvres }{an object of class \code{\link{plsres}} with PLS results for cross-validation, if this option was chosen.} +\item{testres }{an object of class \code{\link{plsres}} with PLS results for a test data, if it +was provided.} +\item{cvres }{an object of class \code{\link{plsres}} with PLS results for cross-validation, if +this option was chosen.} } \description{ \code{pls} is used to calibrate, validate and use of partial least squares (PLS) diff --git a/man/pls.cal.Rd b/man/pls.cal.Rd index 085c924..8940038 100644 --- a/man/pls.cal.Rd +++ b/man/pls.cal.Rd @@ -4,8 +4,9 @@ \alias{pls.cal} \title{PLS model calibration} \usage{ -pls.cal(x, y, ncomp, center, scale, method, cv, alpha, coeffs.ci, coeffs.alpha, - info, light, exclcols = NULL, exclrows = NULL, ncomp.selcrit) +pls.cal(x, y, ncomp, center, scale, method, cv, alpha, coeffs.ci, + coeffs.alpha, info, light, exclcols = NULL, exclrows = NULL, + ncomp.selcrit) } \arguments{ \item{x}{a matrix with x values (predictors)} diff --git a/man/plsda.Rd b/man/plsda.Rd index 05c6e6b..2b90311 100644 --- a/man/plsda.Rd +++ b/man/plsda.Rd @@ -6,8 +6,9 @@ \usage{ plsda(x, c, ncomp = 15, center = T, scale = F, cv = NULL, exclcols = NULL, exclrows = NULL, x.test = NULL, c.test = NULL, - method = "simpls", alpha = 0.05, coeffs.ci = NULL, coeffs.alpha = 0.1, - info = "", light = F, ncomp.selcrit = "min", classname = NULL) + method = "simpls", alpha = 0.05, coeffs.ci = NULL, + coeffs.alpha = 0.1, info = "", light = F, ncomp.selcrit = "min", + classname = NULL) } \arguments{ \item{x}{matrix with predictors.} diff --git a/man/prep.autoscale.Rd b/man/prep.autoscale.Rd index 7aad067..c83d8b4 100644 --- a/man/prep.autoscale.Rd +++ b/man/prep.autoscale.Rd @@ -4,7 +4,7 @@ \alias{prep.autoscale} \title{Autoscale values} \usage{ -prep.autoscale(data, center = T, scale = F, max.cov = 0.1) +prep.autoscale(data, center = T, scale = F, max.cov = 0) } \arguments{ \item{data}{a matrix with data values} @@ -13,11 +13,16 @@ prep.autoscale(data, center = T, scale = F, max.cov = 0.1) \item{scale}{a logical value or vector with numbers for weighting} -\item{max.cov}{columns that have coefficient of variation (in percent) below `max.cv` will not be scaled} +\item{max.cov}{columns that have coefficient of variation (in percent) below or equal to `max.cov` will not be scaled} } \value{ data matrix with processed values } \description{ Autoscale (mean center and standardize) values in columns of data matrix. + +The use of `max.cov` allows to avoid overestimation of inert variables, which vary +very little. Note, that the `max.cov` value is already in percent, e.g. if `max.cov = 0.1` it +will compare the coefficient of variation of every variable with 0.1% (not 1%). If you do not +want to use this option simply keep `max.cov = 0`. } diff --git a/man/randtest.Rd b/man/randtest.Rd index e28f6ee..ee054ca 100644 --- a/man/randtest.Rd +++ b/man/randtest.Rd @@ -5,7 +5,8 @@ \title{Randomization test for PLS regression} \usage{ randtest(x, y, ncomp = 15, center = T, scale = F, nperm = 1000, - sig.level = 0.05, silent = TRUE, exclcols = NULL, exclrows = NULL) + sig.level = 0.05, silent = TRUE, exclcols = NULL, + exclrows = NULL) } \arguments{ \item{x}{matrix with predictors.} diff --git a/man/selectCompNum.Rd b/man/selectCompNum.Rd index c8a079b..1752ac3 100644 --- a/man/selectCompNum.Rd +++ b/man/selectCompNum.Rd @@ -4,12 +4,14 @@ \alias{selectCompNum} \title{Select optimal number of components for a model} \usage{ -selectCompNum(model, ncomp) +selectCompNum(model, ncomp = NULL, ...) } \arguments{ \item{model}{a model object} \item{ncomp}{number of components to select} + +\item{...}{other arguments} } \description{ Generic function for selecting number of components for multivariate models (e.g. PCA, PLS, ...) diff --git a/man/selectCompNum.pca.Rd b/man/selectCompNum.pca.Rd index 4d0f888..1b8bf5c 100644 --- a/man/selectCompNum.pca.Rd +++ b/man/selectCompNum.pca.Rd @@ -4,12 +4,14 @@ \alias{selectCompNum.pca} \title{Select optimal number of components for PCA model} \usage{ -\method{selectCompNum}{pca}(model, ncomp) +\method{selectCompNum}{pca}(model, ncomp, ...) } \arguments{ \item{model}{PCA model (object of class \code{pca})} \item{ncomp}{number of components to select} + +\item{...}{other parameters if any} } \value{ the same model with selected number of components diff --git a/man/selectCompNum.pls.Rd b/man/selectCompNum.pls.Rd index 1d852ed..c4150ad 100644 --- a/man/selectCompNum.pls.Rd +++ b/man/selectCompNum.pls.Rd @@ -4,12 +4,18 @@ \alias{selectCompNum.pls} \title{Select optimal number of components for PLS model} \usage{ -\method{selectCompNum}{pls}(model, ncomp = NULL) +\method{selectCompNum}{pls}(model, ncomp = NULL, + selcrit = model$ncomp.selcrit, ...) } \arguments{ \item{model}{PLS model (object of class \code{pls})} \item{ncomp}{number of components to select} + +\item{selcrit}{criterion for selecting optimal number of components (\code{'min'} for +first local minimum of RMSECV and \code{'wold'} for Wold's rule.)} + +\item{...}{other parameters if any} } \value{ the same model with selected number of components @@ -18,6 +24,9 @@ the same model with selected number of components Allows user to select optimal number of components for PLS model } \details{ -If number of components is not specified, the Wold's R criterion is used. +If number of components is not specified, the cross-validation statistics will be used. It can +be either first local minimum of RMSECV (`selcrit='min'`) or Wold's rule (`selcrit='wold'`) +based on ratio of PRESS values and threshold of 0.95. + See examples in help for \code{\link{pls}} function. } diff --git a/man/setResLimits.pca.Rd b/man/setResLimits.pca.Rd index a05fdb4..cee547d 100644 --- a/man/setResLimits.pca.Rd +++ b/man/setResLimits.pca.Rd @@ -4,7 +4,8 @@ \alias{setResLimits.pca} \title{Set statistical limits for Q and T2 residuals for PCA model} \usage{ -\method{setResLimits}{pca}(obj, alpha = obj$alpha, gamma = obj$gamma, ...) +\method{setResLimits}{pca}(obj, alpha = obj$alpha, gamma = obj$gamma, + ...) } \arguments{ \item{obj}{object with PCA model} diff --git a/man/summary.regcoeffs.Rd b/man/summary.regcoeffs.Rd index 94ac6d0..d21b9cd 100644 --- a/man/summary.regcoeffs.Rd +++ b/man/summary.regcoeffs.Rd @@ -4,7 +4,8 @@ \alias{summary.regcoeffs} \title{Summary method for regcoeffs object} \usage{ -\method{summary}{regcoeffs}(object, ncomp = 1, ny = 1, alpha = 0.05, ...) +\method{summary}{regcoeffs}(object, ncomp = 1, ny = 1, alpha = 0.05, + ...) } \arguments{ \item{object}{object of class \code{regcoeffs}}