Learn R Programming

⚠️There's a newer version (0.14.2) of this package.Take me there.

Multivariate Data Analysis Tools

mdatools is an R package for preprocessing, exploring and analysis of multivariate data. The package provides methods mostly common for Chemometrics. It was created for an introductory PhD course on Chemometrics given at Section of Chemical Engineering, Aalborg University. The general idea of the package is to collect most widespread chemometric methods and give a similar "user interface" (or rather API) for using them. So if a user knows how to make a model and visualize results for one method, he or she can easily do this for the others.

For more details and examples read a Bookdown tutorial. The project website, mdatools.com, contains additional information about supplementary materials and tools.

If you want to cite the package, please use the following: Sergey Kucheryavskiy, mdatools – R package for chemometrics, Chemometrics and Intelligent Laboratory Systems, Volume 198, 2020 (DOI: 10.1016/j.chemolab.2020.103937).

What is new

Latest release (0.11.2) is available both from GitHub and CRAN. You can see the full list of changes here. The Bookdown tutorial has been also updated and contains the description of new methods added in the last release.

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), mostly major releases will be published there (with 2-3 weeks delay after GitHub release as more thorough testing is needed). You can download a zip-file with source package and install it using the install.packages command, e.g. if the downloaded file is mdatools_0.11.2.tar.gz and it is located in a current working directory, just run the following:

install.packages("mdatools_0.11.2.tar.gz")

If you have devtools package installed, the following command will install the current developer version from the master branch of GitHub repository (do not forget to load the devtools package first):

install_github("svkucheryavski/mdatools")

Copy Link

Version

Install

install.packages('mdatools')

Monthly Downloads

1,342

Version

0.11.2

License

MIT + file LICENSE

Maintainer

Sergey Kucheryavskiy

Last Published

October 22nd, 2020

Functions in mdatools (0.11.2)

capitalize

Capitalize text or vector with text values
as.matrix.plsdares

as.matrix method for PLS-DA results
as.matrix.regcoeffs

as.matrix method for regression coefficients class
chisq.prob

Calculate probabilities for distance values using Chi-square distribution
classify.plsda

PLS-DA classification
carbs

Raman spectra of carbonhydrates
classres.getPerformance

Calculation of classification performance parameters
as.matrix.simcares

as.matrix method for SIMCA classification results
constraintNonNegativity

Method for non-negativity constraint
as.matrix.simcamres

as.matrix method for SIMCAM results
classres

Results of classification
constraintNorm

Method for normalization constraint
as.matrix.regres

as.matrix method for regression results
getCalibrationData

Calibration data
employ.constraint

Applies constraint to a dataset
getCalibrationData.pca

Returns matrix with original calibration data
fprintf

Imitation of fprinf() function
getSelectedComponents

Get selected components
getConfidenceEllipse

Compute confidence ellipse for a set of points
getRes

Return list with valid results
getSelectivityRatio

Selectivity ratio
getCalibrationData.simcam

Get calibration data
getRegcoeffs.regmodel

Regression coefficients for PLS model'
getPlotColors

Define colors for plot series
getProbabilities

Get class belonging probability
constraintUnimod

Method for unimodality constraint
constraints.list

Shows information about all implemented constraints
crossval.regmodel

Cross-validation of a regression model
as.matrix.plsres

as.matrix method for PLS results
categorize

Categorize PCA results
crossval.simca

Cross-validation of a SIMCA model
categorize.pca

Categorize PCA results based on orthogonal and score distances.
constraintClosure

Method for closure constraint
constraintAngle

Method for angle constraint
ldecomp

Class for storing and visualising linear decomposition of dataset (X = TP' + E)
categorize.pls

Categorize data rows based on PLS results and critical limits for total distance.
ldecomp.getVariances

Compute explained variance
mda.setimbg

Remove background pixels from image data
mda.getexclind

Get indices of excluded rows or columns
ldecomp.getDistances

Compute score and residual distances
ldecomp.plotResiduals

Residuals distance plot for a set of ldecomp objects
mda.getattr

Get data attributes
getConvexHull

Compute coordinates of a closed convex hull for data points
getSelectivityRatio.pls

Selectivity ratio for PLS model
getDataLabels

Create a vector with labels for plot series
mda.show

Wrapper for show() method
chisq.crit

Calculates critical limits for distance values using Chi-square distribution
ldecomp.getLimParams

Compute parameters for critical limits based on calibration results
getVIPScores

VIP scores
mcrals

Multivariate curve resolution using Alternating Least Squares
mcr

General class for Multivariate Curve Resolution model
ldecomp.getLimitsCoordinates

Compute coordinates of lines or curves with critical limits
ddrobust.param

Calculates critical limits for distance values using Data Driven robust approach
getConfusionMatrix

Confusion matrix for classification results
ddmoments.param

Calculates critical limits for distance values using Data Driven moments approach
getConfusionMatrix.classres

Confusion matrix for classification results
mda.inclrows

include/unhide the excluded rows
mda.purge

Removes excluded (hidden) rows and colmns from data
constraint

Class for MCR-ALS constraint
dd.crit

Calculates critical limits for distance values using Data Driven moments approach
confint.regcoeffs

Confidence intervals for regression coefficients
pcares

Results of PCA decomposition
mdaplot.getColors

Color values for plot elements
crossval.str

String with description of cross-validation method
mdaplot.formatValues

Format vector with numeric values
pellets

Image data
classify.simca

SIMCA classification
getPureVariables

Identifies pure variables
getRegcoeffs

Get regression coefficients
ldecomp.getQLimits

Compute critical limits for orthogonal distances (Q)
mdaplot.getYTickLabels

Prepare yticklabels for plot
ldecomp.getT2Limits

Compute critical limits for score distances (T2)
plot.mcr

Plot summary for MCR model
plot.pca

Model overview plot for PCA
plot.plsres

Overview plot for PLS results
getLabelsAsValues

Create labels from data values
plot.randtest

Plot for randomization test results
plotCorr.randtest

Correlation plot for randomization test results
mcrals.cal

Identifies pure variables
plotCumVariance

Variance plot
plotLoadings

Loadings plot
plotLoadings.pca

Loadings plot for PCA model
imshow

show image data as an image
getMainTitle

Get main title
classmodel.processRefValues

Check reference class values and convert it to a factor if necessary
crossval.getParams

Define parameters based on 'cv' value
ellipse

Create ellipse on the current plot
crossval

Generate sequence of indices for cross-validation
plotPuritySpectra.mcrpure

Purity spectra plot
mcrals.nnls

Non-negative least squares
ipls

Variable selection with interval PLS
plotQDoF

Degrees of freedom plot for orthogonal distance (Nh)
hotelling.crit

Calculate critical limits for distance values using Hotelling T2 distribution
mdaplot.getYTicks

Prepare yticks for plot
mcrals.ols

Ordinary least squares
mdaplot.showLines

Plot lines
mdaplot.showColorbar

Plot colorbar
pca.svd

Singular Values Decomposition based PCA algorithm
plot.pls

Model overview plot for PLS
plot.pcares

Plot method for PCA results object
pca.run

Runs one of the selected PCA methods
mda.im2data

Convert image to data matrix
mcrals.fcnnls

Fast combinatorial non-negative least squares
hotelling.prob

Calculate probabilities for distance values and given parameters using Hotelling T2 distribution
plotRegcoeffs

Regression coefficients plot
mda.purgeCols

Removes excluded (hidden) colmns from data
jm.crit

Calculate critical limits for distance values using Jackson-Mudholkar approach
jm.prob

Calculate probabilities for distance values and given parameters using Hotelling T2 distribution
mcrpure

Multivariate curve resolution based on pure variables
mda.cbind

A wrapper for cbind() method with proper set of attributes
plotContributions.mcr

Show plot with resolved contributions
plotCumVariance.mcr

Show plot with cumulative explained variance
plotCumVariance.ldecomp

Cumulative explained variance plot
plotConvexHull

Add convex hull for groups of points on scatter plot
mda.inclcols

Include/unhide the excluded columns
plotHist

Statistic histogram
plotRegcoeffs.regmodel

Regression coefficient plot for regression model
mda.rbind

A wrapper for rbind() method with proper set of attributes
mda.data2im

Convert data matrix to an image
mda.df2mat

Convert data frame to a matrix
mda.setattr

Set data attributes
getImplementedConstraints

Shows a list with implemented constraints
getProbabilities.pca

Probabilities for residual distances
getLabelsAsIndices

Create labels as column or row indices
employ

Generic function to apply a method (e.g. constraint)
mda.purgeRows

Removes excluded (hidden) rows from data
mdaplot.getXAxisLim

Calculate limits for x-axis.
mdaplot.getXTickLabels

Prepare xticklabels for plot
mda.t

A wrapper for t() method with proper set of attributes
mda.subset

A wrapper for subset() method with proper set of attributed
mdaplotg.prepareData

Prepare data for mdaplotg
getVIPScores.pls

VIP scores for PLS model
getProbabilities.simca

Probabilities of class belonging for PCA/SIMCA results
getVariance.mcr

Compute explained variance for MCR case
mdaplot.plotAxes

Create axes plane
mdaplot.getYAxisLim

Calculate limits for y-axis.
mdaplot.getXTicks

Prepare xticks for plot
mda.exclrows

Exclude/hide rows in a dataset
ipls.forward

Runs the forward iPLS algorithm
mda.exclcols

Exclude/hide columns in a dataset
ipls.backward

Runs the backward iPLS algorithm
mdaplotg.processParam

Check mdaplotg parameters and replicate them if necessary
plot.plsdares

Overview plot for PLS-DA results
plot.plsda

Model overview plot for PLS-DA
plotBiplot

Biplot
plotSelectivityRatio.pls

Selectivity ratio plot for PLS model
mdaplot

Plotting function for a single set of objects
plotHist.randtest

Histogram plot for randomization test results
plotSensitivity

Sensitivity plot
plotSpecificity.classres

Specificity plot for classification results
plotSpectra

Plot resolved spectra
plotXScores.plsres

X scores plot for PLS results
plotWeights

Plot for PLS weights
mdaplotg

Plotting function for several plot series
mdaplot.prepareColors

Prepare colors based on palette and opacity value
plotXVariance

X variance plot
plotWeights.pls

X loadings plot for PLS
plotBiplot.pca

PCA biplot
mdaplotg.getLegend

Create and return vector with legend values
mdaplotg.getYLim

Compute y-axis limits for mdaplotg
mdaplotg.getXLim

Compute x-axis limits for mdaplotg
plotDistDoF

Degrees of freedom plot for both distances
plotPredictions.simcamres

Prediction plot for SIMCAM results
plotProbabilities

Plot for class belonging probability
plotPerformance.classmodel

Performance plot for classification model
plotPerformance

Classification performance plot
plotVariance

Variance plot
plotXScores

X scores plot
plotVariance.ldecomp

Explained variance plot
pca.mvreplace

Replace missing values in data
pca.nipals

NIPALS based PCA algorithm
predict.simca

SIMCA predictions
plotErrorbars

Show plot series as error bars
plotYCumVariance.plsres

Explained cumulative Y variance plot for PLS results
pls.run

Runs selected PLS algorithm
plotXYScores.plsres

XY scores plot for PLS results
plotXScores.pls

X scores plot for PLS
plotXYScores.pls

XY scores plot for PLS
plotYResiduals

Y residuals plot
mdaplotyy

Create line plot with double y-axis
mdaplot.areColors

Check color values
mdaplotg.showLegend

Show legend for mdaplotg
predict.simcam

SIMCA multiple classes predictions
people

People data
print.ipls

Print method for iPLS
print.plsda

Print method for PLS-DA model object
print.classres

Print information about classification result object
plotCooman.simcamres

Cooman's plot for SIMCAM results
plot.regcoeffs

Regression coefficients plot
pinv

Pseudo-inverse matrix
plot.regres

Plot method for regression results
plotCorr

Correlation plot
plotCumVariance.pca

Cumulative explained variance plot for PCA model
pca.cal

PCA model calibration
plotMisclassified

Misclassification ratio plot
pls.simpls

SIMPLS algorithm
prep.alsbasecorr

Baseline correction using assymetric least squares
plotMisclassified.classmodel

Misclassified ratio plot for classification model
plotPurity

Plot purity values
plotProbabilities.classres

Plot for class belonging probability
plotPredictions.classmodel

Predictions plot for classification model
plotPredictions

Predictions plot
plotRMSE.regmodel

RMSE plot for regression model
plot.ipls

Overview plot for iPLS results
plot.simcamres

Model overview plot for SIMCAM results
plot.classres

Plot function for classification results
pca.getB

Low-dimensional approximation of data matrix X
prep.autoscale

Autoscale values
plotDensity

Show plot series as density plot (using hex binning)
plotBars

Show plot series as bars
prep.snv

Standard Normal Variate transformation
print.pcares

Print method for PCA results object
prep.savgol

Savytzky-Golay filter
print.pls

Print method for PLS model object
plotExtreme

Shows extreme plot for SIMCA model
plotCooman.simcam

Cooman's plot for SIMCAM model
plotCooman

Cooman's plot
plotExtreme.pca

Extreme plot
plotMisclassified.classres

Misclassified ratio plot for classification results
plotModelDistance

Model distance plot
plotPerformance.classres

Performance plot for classification results
plotPointsShape

Add confidence ellipse or convex hull for group of points
simcam.getPerformanceStats

Performance statistics for SIMCAM model
selectCompNum.pls

Select optimal number of components for PLS model
simcam

SIMCA multiclass classification
selratio

Selectivity ratio calculation
plotPredictions.regres

Predictions plot for regression results
plotPredictions.simcam

Predictions plot for SIMCAM model
plotResiduals.pca

Residuals distance plot for PCA model
plotResiduals.ldecomp

Residual distance plot
plotRMSE.regres

RMSE plot for regression results
summary.mcrals

Summary method for mcrals object
plotScores

Scores plot
summary.mcrpure

Summary method for mcrpure object
plotScores.pca

Scores plot for PCA model
plotSelection

Selected intervals plot
plotSpecificity.classmodel

Specificity plot for classification model
plotSpecificity

Specificity plot
print.plsdares

Print method for PLS-DA results object
plotVariance.mcr

Show plot with explained variance
mdatools

Package for Multivariate Data Analysis (Chemometrics)
regcoeffs.getStats

Distribution statistics for regression coeffificents
regress.addattrs

Add names and attributes to matrix with statistics
regcoeffs

Regression coefficients
plotVIPScores

VIP scores plot
plotVIPScores.pls

VIP scores plot for PLS model
plotScores.ldecomp

Scores plot
plot.simca

Model overview plot for SIMCA
plot.simcam

Model overview plot for SIMCAM
pca

Principal Component Analysis
plotVariance.pls

Variance plot for PLS
plotConfidenceEllipse

Add confidence ellipse for groups of points on scatter plot
plotDiscriminationPower.simcam

Discrimination power plot for SIMCAM model
plotDiscriminationPower

Discrimination power plot
plotContributions

Plot resolved contributions
plotLines

Show plot series as set of lines
plotHotellingEllipse

Hotelling ellipse
plotPredictions.classres

Prediction plot for classification results
setDistanceLimits.pls

Compute and set statistical limits for residual distances.
repmat

Replicate matric x
plotVariance.pca

Explained variance plot for PCA model
plotVariance.plsres

Explained X variance plot for PLS results
plotXYResiduals.pls

Residual XY-distance plot
plotXYResiduals

Plot for XY-residuals
plotPredictions.regmodel

Predictions plot for regression model
showDistanceLimits

Show residual distance limits
plotRegressionLine

Add regression line for data points
plotModelDistance.simcam

Model distance plot for SIMCAM model
plotXResiduals.pls

Residual distance plot for decomposition of X data
plotXResiduals.plsres

X residuals plot for PLS results
plotResiduals

Residuals plot
plotResiduals.regres

Residuals plot for regression results
plotXYScores

XY scores plot
plotYCumVariance.pls

Cumulative explained Y variance plot for PLS
plotYCumVariance

Y cumulative variance plot
plotXYResiduals.plsres

Residual distance plot
splitPlotData

Split dataset to x and y values depending on plot type
plotSensitivity.classmodel

Sensitivity plot for classification model
plotScatter

Show plot series as set of points
plotModellingPower

Modelling power plot
summary.classres

Summary statistics about classification result object
plotSensitivity.classres

Sensitivity plot for classification results
pls.getLimitsCoordinates

Compute coordinates of lines or curves with critical limits
plotXCumVariance

X cumulative variance plot
summary.plsdares

Summary method for PLS-DA results object
plotPuritySpectra

Plot purity spectra
plotPurity.mcrpure

Purity values plot
plotXLoadings

X loadings plot
plotXCumVariance.pls

Cumulative explained X variance plot for PLS
plotXYLoadings

X loadings plot
plotXCumVariance.plsres

Explained cumulative X variance plot for PLS results
pls.getZLimits

Compute critical limits for orthogonal distances (Q)
prep.msc

Multiplicative Scatter Correction transformation
summary.plsres

summary method for PLS results object
prep.norm

Normalization
plotYVariance.plsres

Explained Y variance plot for PLS results
prepCalData

Prepares calibration data
summary.simcares

Summary method for SIMCA results object
summary.simcamres

Summary method for SIMCAM results object
plotRMSE

RMSE plot
plotXYLoadings.pls

XY loadings plot for PLS
plotYResiduals.plsres

Y residuals plot for PLS results
plotseries

Create plot series object based on data, plot type and parameters
preparePlotData

Take dataset and prepare them for plot
plsres

PLS results
predict.mcrals

MCR ALS predictions
print.regmodel

Print method for PLS model object
print.pca

Print method for PCA model object
print.regcoeffs

print method for regression coefficients class
print.mcrpure

Print method for mcrpure object
plotSelection.ipls

iPLS performance plot
plotRMSE.ipls

RMSE development plot
regres

Regression results
print.simcam

Print method for SIMCAM model object
regres.bias

Prediction bias
plotSelectivityRatio

Selectivity ratio plot
plotSpectra.mcr

Show plot with resolved spectra
plotYResiduals.regmodel

Y residuals plot for regression model
plsda

Partial Least Squares Discriminant Analysis
print.simcamres

Print method for SIMCAM results object
plsdares

PLS-DA results
plotT2DoF

Degrees of freedom plot for score distance (Nh)
predict.mcrpure

MCR predictions
regres.rmse

RMSE
predict.pca

PCA predictions
print.randtest

Print method for randtest object
print.plsres

print method for PLS results object
setDistanceLimits.pca

Compute and set statistical limits for Q and T2 residual distances.
setDistanceLimits

Set residual distance limits
regres.slope

Slope
plotXLoadings.pls

X loadings plot for PLS
showPredictions.classres

Show predicted class values
showLabels

Show labels on plot
randtest

Randomization test for PLS regression
selectCompNum

Select optimal number of components for a model
print.simcares

Print method for SIMCA results object
simca

SIMCA one-class classification
summary.randtest

Summary method for randtest object
plotXResiduals

X residuals plot
plotXVariance.pls

Explained X variance plot for PLS
plotXVariance.plsres

Explained X variance plot for PLS results
plotYVariance

Y variance plot
summary.regcoeffs

Summary method for regcoeffs object
plotYVariance.pls

Explained Y variance plot for PLS
pls.cal

PLS model calibration
pls

Partial Least Squares regression
unmix.mcrpure

Unmix spectral data using pure variables estimated before
vipscores

VIP scores for PLS model
predict.pls

PLS predictions
simcamres

Results of SIMCA multiclass classification
selectCompNum.pca

Select optimal number of components for PCA model
simcares

Results of SIMCA one-class classification
print.ldecomp

Print method for linear decomposition
predict.plsda

PLS-DA predictions
print.regres

print method for regression results object
print.mcrals

Print method for mcrpure object
splitExcludedData

Split the excluded part of data
simdata

Spectral data of polyaromatic hydrocarbons mixing
showPredictions

Predictions
summary.regmodel

Summary method for regression model object
summary.regres

summary method for regression results object
print.simca

Print method for SIMCA model object
summary.ipls

Summary for iPLS results
summary.ldecomp

Summary statistics for linear decomposition
summary.simcam

Summary method for SIMCAM model object
summary.simca

Summary method for SIMCA model object
regres.err

Error of prediction
summary.pca

Summary method for PCA model object
regres.r2

Determination coefficient
summary.pcares

Summary method for PCA results object
summary.pls

Summary method for PLS model object
summary.plsda

Summary method for PLS-DA model object
as.matrix.classres

as.matrix method for classification results
as.matrix.ldecomp

as.matrix method for ldecomp object