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.

You can also take video-lectures from YouTube channel devoted to introductory Chemometric course I give to master students. The lectures explain theory behind basic Chemometric methods but also show how to use them in mdatools.

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.5) 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.5.tar.gz and it is located in a current working directory, just run the following:

install.packages("mdatools_0.11.5.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.5

License

MIT + file LICENSE

Maintainer

Sergey Kucheryavskiy

Last Published

April 30th, 2021

Functions in mdatools (0.11.5)

as.matrix.ldecomp

as.matrix method for ldecomp object
carbs

Raman spectra of carbonhydrates
as.matrix.regcoeffs

as.matrix method for regression coefficients class
as.matrix.plsdares

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

as.matrix method for SIMCAM results
as.matrix.classres

as.matrix method for classification results
as.matrix.regres

as.matrix method for regression results
capitalize

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

as.matrix method for PLS results
as.matrix.simcares

as.matrix method for SIMCA classification results
categorize

Categorize PCA results
classmodel.processRefValues

Check reference class values and convert it to a factor if necessary
constraints.list

Shows information about all implemented constraints
classify.simca

SIMCA classification
constraintUnimod

Method for unimodality constraint
employ.constraint

Applies constraint to a dataset
chisq.prob

Calculate probabilities for distance values using Chi-square distribution
getConfidenceEllipse

Compute confidence ellipse for a set of points
classify.plsda

PLS-DA classification
eye

Create the identity matrix
chisq.crit

Calculates critical limits for distance values using Chi-square distribution
confint.regcoeffs

Confidence intervals for regression coefficients
categorize.pls

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

Method for non-negativity constraint
crossval.simca

Cross-validation of a SIMCA model
categorize.pca

Categorize PCA results based on orthogonal and score distances.
crossval.getParams

Define parameters based on 'cv' value
ddrobust.param

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

Generate sequence of indices for cross-validation
ddmoments.param

Calculates critical limits for distance values using Data Driven moments approach
constraint

Class for MCR-ALS constraint
getLabelsAsValues

Create labels from data values
getImplementedConstraints

Shows a list with implemented constraints
getDataLabels

Create a vector with labels for plot series
getLabelsAsIndices

Create labels as column or row indices
getProbabilities

Get class belonging probability
classres

Results of classification
ellipse

Create ellipse on the current plot
getMainTitle

Get main title
constraintNorm

Method for normalization constraint
mcrals.ols

Ordinary least squares
crossval.regmodel

Cross-validation of a regression model
ipls.backward

Runs the backward iPLS algorithm
ldecomp.plotResiduals

Residuals distance plot for a set of ldecomp objects
ipls.forward

Runs the forward iPLS algorithm
getProbabilities.pca

Probabilities for residual distances
mda.purgeCols

Removes excluded (hidden) colmns from data
hotelling.prob

Calculate probabilities for distance values and given parameters using Hotelling T2 distribution
hotelling.crit

Calculate critical limits for distance values using Hotelling T2 distribution
getConfusionMatrix

Confusion matrix for classification results
employ

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

Selectivity ratio
mcrals.cal

Identifies pure variables
mda.cbind

A wrapper for cbind() method with proper set of attributes
mcrpure

Multivariate curve resolution based on pure variables
ldecomp.getVariances

Compute explained variance
getCalibrationData.pca

Returns matrix with original calibration data
ldecomp.getLimParams

Compute parameters for critical limits based on calibration results
getCalibrationData.simcam

Get calibration data
getR

Creates rotation matrix to map a set vectors base1 to a set of vectors base2.
mda.subset

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

A wrapper for t() method with proper set of attributes
mcrals.fcnnls

Fast combinatorial non-negative least squares
pca

Principal Component Analysis
mdaplotg.getLegend

Create and return vector with legend values
mdaplot.getYAxisLim

Calculate limits for y-axis.
mdaplot.getXTicks

Prepare xticks for plot
plot.randtest

Plot for randomization test results
mdatools

Package for Multivariate Data Analysis (Chemometrics)
mdaplotg

Plotting function for several plot series
classres.getPerformance

Calculation of classification performance parameters
constraintAngle

Method for angle constraint
constraintClosure

Method for closure constraint
getConfusionMatrix.classres

Confusion matrix for classification results
getRegcoeffs

Get regression coefficients
getVariance.mcr

Compute explained variance for MCR case
mdaplot.formatValues

Format vector with numeric values
mda.df2mat

Convert data frame to a matrix
plot.plsda

Model overview plot for PLS-DA
mdaplot.getColors

Color values for plot elements
mdaplot.plotAxes

Create axes plane
pca.mvreplace

Replace missing values in data
plotContributions.mcr

Show plot with resolved contributions
mda.purgeRows

Removes excluded (hidden) rows from data
getVIPScores.pls

VIP scores for PLS model
mdaplot.getYTickLabels

Prepare yticklabels for plot
pca.nipals

NIPALS based PCA algorithm
mcrals.nnls

Non-negative least squares
mdaplot.showColorbar

Plot colorbar
getRegcoeffs.regmodel

Regression coefficients for PLS model'
mdaplot.prepareColors

Prepare colors based on palette and opacity value
plotCooman.simcam

Cooman's plot for SIMCAM model
plotCumVariance

Variance plot
plotPointsShape

Add confidence ellipse or convex hull for group of points
plotLoadings.pca

Loadings plot for PCA model
plotCooman.simcamres

Cooman's plot for SIMCAM results
plotCumVariance.ldecomp

Cumulative explained variance plot
plotMisclassified

Misclassification ratio plot
plot.regcoeffs

Regression coefficients plot
plotPredictions

Predictions plot
getRes

Return list with valid results
plotRegressionLine

Add regression line for data points
plotSpecificity.classres

Specificity plot for classification results
plotRegcoeffs.regmodel

Regression coefficient plot for regression model
plotSpecificity.classmodel

Specificity plot for classification model
dd.crit

Calculates critical limits for distance values using Data Driven moments approach
crossval.str

String with description of cross-validation method
mdaplot.areColors

Check color values
mdaplot

Plotting function for a single set of objects
mda.im2data

Convert image to data matrix
fprintf

Imitation of fprinf() function
plotXScores.pls

X scores plot for PLS
getConvexHull

Compute coordinates of a closed convex hull for data points
ldecomp

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

Predictions plot for SIMCAM model
getCalibrationData

Calibration data
plot.pcares

Plot method for PCA results object
plot.pls

Model overview plot for PLS
plotPredictions.classmodel

Predictions plot for classification model
plotCorr.randtest

Correlation plot for randomization test results
plot.pca

Model overview plot for PCA
plotContributions

Plot resolved contributions
getProbabilities.simca

Probabilities of class belonging for PCA/SIMCA results
getPureVariables

Identifies pure variables
plotXCumVariance.plsres

Explained cumulative X variance plot for PLS results
getSelectivityRatio.pls

Selectivity ratio for PLS model
jm.crit

Calculate critical limits for distance values using Jackson-Mudholkar approach
plotXScores.plsres

X scores plot for PLS results
plotDiscriminationPower.simcam

Discrimination power plot for SIMCAM model
ldecomp.getLimitsCoordinates

Compute coordinates of lines or curves with critical limits
imshow

show image data as an image
mda.inclcols

Include/unhide the excluded columns
getPlotColors

Define colors for plot series
getSelectedComponents

Get selected components
plotPredictions.simcamres

Prediction plot for SIMCAM results
ldecomp.getDistances

Compute score and residual distances
plotSpecificity

Specificity plot
mda.exclcols

Exclude/hide columns in a dataset
mda.exclrows

Exclude/hide rows in a dataset
getVIPScores

VIP scores
mda.rbind

A wrapper for rbind() method with proper set of attributes
plotRMSE.ipls

RMSE development plot
plotCorr

Correlation plot
plsda

Partial Least Squares Discriminant Analysis
pls.simpls

SIMPLS algorithm
mcr

General class for Multivariate Curve Resolution model
ipls

Variable selection with interval PLS
mda.inclrows

include/unhide the excluded rows
mcrals

Multivariate curve resolution using Alternating Least Squares
plotProbabilities

Plot for class belonging probability
plotBiplot

Biplot
pca.cal

PCA model calibration
mda.purge

Removes excluded (hidden) rows and colmns from data
mdaplot.showLines

Plot lines
mdaplot.getYTicks

Prepare yticks for plot
plotScores.pca

Scores plot for PCA model
plsres

PLS results
print.mcrpure

Print method for mcrpure object
print.mcrals

Print method for mcrpure object
plsdares

PLS-DA results
mda.setattr

Set data attributes
pca.run

Runs one of the selected PCA methods
plotResiduals.pca

Residuals distance plot for PCA model
pca.svd

Singular Values Decomposition based PCA algorithm
plotModelDistance.simcam

Model distance plot for SIMCAM model
plotModelDistance

Model distance plot
plotSelection

Selected intervals plot
pcv

Compute matrix with pseudo-validation set
pcares

Results of PCA decomposition
plotRMSE

RMSE plot
plot.mcr

Plot summary for MCR model
plotXYLoadings.pls

XY loadings plot for PLS
plot.regres

Plot method for regression results
pca.getB

Low-dimensional approximation of data matrix X
print.pls

Print method for PLS model object
plotCumVariance.mcr

Show plot with cumulative explained variance
plot.simcamres

Model overview plot for SIMCAM results
plotLines

Show plot series as set of lines
plotCumVariance.pca

Cumulative explained variance plot for PCA model
plot.simcam

Model overview plot for SIMCAM
pellets

Image data
plotPredictions.classres

Prediction plot for classification results
plotYCumVariance.pls

Cumulative explained Y variance plot for PLS
plotLoadings

Loadings plot
plotSpectra.mcr

Show plot with resolved spectra
plotSpectra

Plot resolved spectra
plotYResiduals.regmodel

Y residuals plot for regression model
plotT2DoF

Degrees of freedom plot for score distance (Nh)
plotXVariance

X variance plot
plotQDoF

Degrees of freedom plot for orthogonal distance (Nh)
simcam.getPerformanceStats

Performance statistics for SIMCAM model
plotVIPScores

VIP scores plot
plotSelection.ipls

iPLS performance plot
plotWeights.pls

X loadings plot for PLS
plotWeights

Plot for PLS weights
plot.ipls

Overview plot for iPLS results
predict.plsda

PLS-DA predictions
plotXCumVariance

X cumulative variance plot
plotXVariance.pls

Explained X variance plot for PLS
plotPerformance.classres

Performance plot for classification results
plotBars

Show plot series as bars
plotHist

Statistic histogram
plotVariance.pls

Variance plot for PLS
plot.simca

Model overview plot for SIMCA
plotExtreme.pca

Extreme plot
print.simca

Print method for SIMCA model object
jm.prob

Calculate probabilities for distance values and given parameters using Hotelling T2 distribution
ldecomp.getQLimits

Compute critical limits for orthogonal distances (Q)
plotXLoadings

X loadings plot
setDistanceLimits.pls

Compute and set statistical limits for residual distances.
predict.simca

SIMCA predictions
preparePlotData

Take dataset and prepare them for plot
plotYVariance

Y variance plot
regres.slope

Slope
regress.addattrs

Add names and attributes to matrix with statistics
print.simcam

Print method for SIMCAM model object
showLabels

Show labels on plot
mdaplotg.showLegend

Show legend for mdaplotg
showDistanceLimits

Show residual distance limits
print.classres

Print information about classification result object
showPredictions

Predictions
mdaplot.getXAxisLim

Calculate limits for x-axis.
mda.getattr

Get data attributes
mda.show

Wrapper for show() method
mda.setimbg

Remove background pixels from image data
mda.getexclind

Get indices of excluded rows or columns
simca

SIMCA one-class classification
print.plsdares

Print method for PLS-DA results object
simcam

SIMCA multiclass classification
vipscores

VIP scores for PLS model
unmix.mcrpure

Unmix spectral data using pure variables estimated before
ldecomp.getT2Limits

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

Overview plot for PLS-DA results
plotErrorbars

Show plot series as error bars
mda.data2im

Convert data matrix to an image
plot.classres

Plot function for classification results
mdaplotg.getXLim

Compute x-axis limits for mdaplotg
mdaplotg.processParam

Check mdaplotg parameters and replicate them if necessary
mdaplot.getXTickLabels

Prepare xticklabels for plot
plotMisclassified.classmodel

Misclassified ratio plot for classification model
plotMisclassified.classres

Misclassified ratio plot for classification results
plotPerformance.classmodel

Performance plot for classification model
setDistanceLimits

Set residual distance limits
plotCooman

Cooman's plot
mdaplotg.getYLim

Compute y-axis limits for mdaplotg
pinv

Pseudo-inverse matrix
mdaplotyy

Create line plot with double y-axis
plotConfidenceEllipse

Add confidence ellipse for groups of points on scatter plot
people

People data
plotPerformance

Classification performance plot
plotExtreme

Shows extreme plot for SIMCA model
plotPurity

Plot purity values
mdaplotg.prepareData

Prepare data for mdaplotg
plotBiplot.pca

PCA biplot
plotScatter

Show plot series as set of points
plotDensity

Show plot series as density plot (using hex binning)
plot.plsres

Overview plot for PLS results
showPredictions.classres

Show predicted class values
plotResiduals.regres

Residuals plot for regression results
plotRMSE.regmodel

RMSE plot for regression model
plotSensitivity.classres

Sensitivity plot for classification results
pls.cal

PLS model calibration
plotXResiduals

X residuals plot
plotXYLoadings

X loadings plot
prep.savgol

Savytzky-Golay filter
plotXResiduals.pls

Residual distance plot for decomposition of X data
plotVariance.plsres

Explained X variance plot for PLS results
summary.pca

Summary method for PCA model object
plotPuritySpectra

Plot purity spectra
plotDiscriminationPower

Discrimination power plot
plotYResiduals

Y residuals plot
predict.pca

PCA predictions
plotXVariance.plsres

Explained X variance plot for PLS results
plotPredictions.regres

Predictions plot for regression results
plotConvexHull

Add convex hull for groups of points on scatter plot
print.randtest

Print method for randtest object
plotHist.randtest

Histogram plot for randomization test results
plotPredictions.regmodel

Predictions plot for regression model
predict.simcam

SIMCA multiple classes predictions
print.ldecomp

Print method for linear decomposition
summary.randtest

Summary method for randtest object
summary.pcares

Summary method for PCA results object
summary.regcoeffs

Summary method for regcoeffs object
print.ipls

Print method for iPLS
plotPurity.mcrpure

Purity values plot
plotVariance.ldecomp

Explained variance plot
plotModellingPower

Modelling power plot
plotPuritySpectra.mcrpure

Purity spectra plot
simdata

Spectral data of polyaromatic hydrocarbons mixing
plotScores

Scores plot
plotYCumVariance.plsres

Explained cumulative Y variance plot for PLS results
plotVariance.mcr

Show plot with explained variance
plotseries

Create plot series object based on data, plot type and parameters
plotScores.ldecomp

Scores plot
plotHotellingEllipse

Hotelling ellipse
plotXResiduals.plsres

X residuals plot for PLS results
pls.run

Runs selected PLS algorithm
plotDistDoF

Degrees of freedom plot for both distances
plotResiduals

Residuals plot
plotVariance

Variance plot
plotXYResiduals.pls

Residual XY-distance plot
plotRMSE.regres

RMSE plot for regression results
plotProbabilities.classres

Plot for class belonging probability
plotVariance.pca

Explained variance plot for PCA model
pls.getLimitsCoordinates

Compute coordinates of lines or curves with critical limits
prep.ref2km

Kubelka-Munk transformation
plotRegcoeffs

Regression coefficients plot
plotResiduals.ldecomp

Residual distance plot
prepCalData

Prepares calibration data
plotXScores

X scores plot
plotXYScores.plsres

XY scores plot for PLS results
plotSelectivityRatio

Selectivity ratio plot
summary.classres

Summary statistics about classification result object
plotSelectivityRatio.pls

Selectivity ratio plot for PLS model
regres.r2

Determination coefficient
prep.generic

Generic function for preprocessing
predict.pls

PLS predictions
print.plsda

Print method for PLS-DA model object
repmat

Replicate matric x
plotSensitivity.classmodel

Sensitivity plot for classification model
plotXYResiduals.plsres

Residual distance plot
plotVIPScores.pls

VIP scores plot for PLS model
plotSensitivity

Sensitivity plot
plotXCumVariance.pls

Cumulative explained X variance plot for PLS
prep.snv

Standard Normal Variate transformation
summary.mcrals

Summary method for mcrals object
plotYResiduals.plsres

Y residuals plot for PLS results
summary.simca

Summary method for SIMCA model object
pls

Partial Least Squares regression
selectCompNum.pls

Select optimal number of components for PLS model
selratio

Selectivity ratio calculation
summary.mcrpure

Summary method for mcrpure object
print.regcoeffs

print method for regression coefficients class
rotationMatrixToX1

Creates a rotation matrix to map a vector x to [1 0 0 ... 0]
plotXLoadings.pls

X loadings plot for PLS
splitExcludedData

Split the excluded part of data
summary.simcamres

Summary method for SIMCAM results object
print.regres

print method for regression results object
plotXYResiduals

Plot for XY-residuals
splitPlotData

Split dataset to x and y values depending on plot type
plotYVariance.plsres

Explained Y variance plot for PLS results
plotXYScores

XY scores plot
plotXYScores.pls

XY scores plot for PLS
plotYVariance.pls

Explained Y variance plot for PLS
prep.msc

Multiplicative Scatter Correction transformation
prep.alsbasecorr

Baseline correction using assymetric least squares
prep.norm

Normalization
regres.bias

Prediction bias
prep.autoscale

Autoscale values
summary.simcares

Summary method for SIMCA results object
predict.mcrpure

MCR predictions
predict.mcrals

MCR ALS predictions
print.pcares

Print method for PCA results object
regres

Regression results
print.pca

Print method for PCA model object
pls.getZLimits

Compute critical limits for orthogonal distances (Q)
plotYCumVariance

Y cumulative variance plot
selectCompNum

Select optimal number of components for a model
print.regmodel

Print method for PLS model object
regcoeffs

Regression coefficients
randtest

Randomization test for PLS regression
summary.ipls

Summary for iPLS results
regres.rmse

RMSE
selectCompNum.pca

Select optimal number of components for PCA model
summary.plsda

Summary method for PLS-DA model object
print.simcamres

Print method for SIMCAM results object
regres.err

Error of prediction
print.plsres

print method for PLS results object
print.simcares

Print method for SIMCA results object
summary.simcam

Summary method for SIMCAM model object
summary.pls

Summary method for PLS model object
regcoeffs.getStats

Distribution statistics for regression coeffificents
simcares

Results of SIMCA one-class classification
simcamres

Results of SIMCA multiclass classification
setDistanceLimits.pca

Compute and set statistical limits for Q and T2 residual distances.
summary.plsdares

Summary method for PLS-DA results object
summary.plsres

summary method for PLS results object
summary.ldecomp

Summary statistics for linear decomposition
summary.regmodel

Summary method for regression model object
summary.regres

summary method for regression results object