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

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

License

MIT + file LICENSE

Maintainer

Sergey Kucheryavskiy

Last Published

November 9th, 2022

Functions in mdatools (0.13.1)

as.matrix.simcamres

as.matrix method for SIMCAM results
as.matrix.regres

as.matrix method for regression results
as.matrix.regcoeffs

as.matrix method for regression coefficients class
capitalize

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

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

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

as.matrix method for ldecomp object
carbs

Raman spectra of carbonhydrates
as.matrix.plsres

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

as.matrix method for SIMCA classification results
chisq.crit

Calculates critical limits for distance values using Chi-square distribution
classify.plsda

PLS-DA classification
classres

Results of classification
classify.simca

SIMCA classification
categorize.pca

Categorize PCA results based on orthogonal and score distances.
classres.getPerformance

Calculation of classification performance parameters
categorize.pls

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

Check reference class values and convert it to a factor if necessary
chisq.prob

Calculate probabilities for distance values using Chi-square distribution
categorize

Categorize PCA results
constraintAngle

Method for angle constraint
constraintUnimod

Method for unimodality constraint
constraintNonNegativity

Method for non-negativity constraint
crossval

Generate sequence of indices for cross-validation
crossval.getParams

Define parameters based on 'cv' value
constraintClosure

Method for closure constraint
constraint

Class for MCR-ALS constraint
confint.regcoeffs

Confidence intervals for regression coefficients
constraints.list

Shows information about all implemented constraints
constraintNorm

Method for normalization constraint
employ.constraint

Applies constraint to a dataset
crossval.regmodel

Cross-validation of a regression model
ellipse

Create ellipse on the current plot
employ.prep

Applies a list with preprocessing methods to a dataset
ddmoments.param

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

Create the identity matrix
ddrobust.param

Calculates critical limits for distance values using Data Driven robust approach
dd.crit

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

String with description of cross-validation method
getConfusionMatrix.classres

Confusion matrix for classification results
getImplementedConstraints

Shows a list with implemented constraints
getDataLabels

Create a vector with labels for plot series
crossval.simca

Cross-validation of a SIMCA model
fprintf

Imitation of fprinf() function
getCalibrationData

Calibration data
getProbabilities.pca

Probabilities for residual distances
getConfidenceEllipse

Compute confidence ellipse for a set of points
getCalibrationData.simcam

Get calibration data
getCalibrationData.pca

Returns matrix with original calibration data
getConfusionMatrix

Confusion matrix for classification results
getPlotColors

Define colors for plot series
getProbabilities

Get class belonging probability
getLabelsAsValues

Create labels from data values
getMainTitle

Get main title
getImplementedPrepMethods

Shows a list with implemented preprocessing methods
getLabelsAsIndices

Create labels as column or row indices
getConvexHull

Compute coordinates of a closed convex hull for data points
getRes

Return list with valid results
getVariance.mcr

Compute explained variance for MCR case
getSelectedComponents

Get selected components
getR

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

Identifies pure variables
getRegcoeffs

Get regression coefficients
hotelling.crit

Calculate critical limits for distance values using Hotelling T2 distribution
getSelectivityRatio.pls

Selectivity ratio for PLS model
getVIPScores

VIP scores
getVIPScores.pls

VIP scores for PLS model
getProbabilities.simca

Probabilities of class belonging for PCA/SIMCA results
getSelectivityRatio

Selectivity ratio
jm.crit

Calculate critical limits for distance values using Jackson-Mudholkar approach
getRegcoeffs.regmodel

Regression coefficients for PLS model'
ipls.backward

Runs the backward iPLS algorithm
ipls

Variable selection with interval PLS
ldecomp.getLimParams

Compute parameters for critical limits based on calibration results
ldecomp.getDistances

Compute score and residual distances
ipls.forward

Runs the forward iPLS algorithm
ldecomp

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

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

Compute critical limits for score distances (T2)
hotelling.prob

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

Residuals distance plot for a set of ldecomp objects
imshow

show image data as an image
mcrals.nnls

Non-negative least squares
mcr

General class for Multivariate Curve Resolution model
mcrals.fcnnls

Fast combinatorial non-negative least squares
mda.im2data

Convert image to data matrix
ldecomp.getQLimits

Compute critical limits for orthogonal distances (Q)
ldecomp.getLimitsCoordinates

Compute coordinates of lines or curves with critical limits
mda.getexclind

Get indices of excluded rows or columns
mda.df2mat

Convert data frame to a matrix
mda.exclcols

Exclude/hide columns in a dataset
mda.purgeRows

Removes excluded (hidden) rows from data
mda.data2im

Convert data matrix to an image
mda.inclcols

Include/unhide the excluded columns
ldecomp.getVariances

Compute explained variance
mda.cbind

A wrapper for cbind() method with proper set of attributes
mda.inclrows

include/unhide the excluded rows
mda.setattr

Set data attributes
mcrals.cal

Identifies pure variables
mda.setimbg

Remove background pixels from image data
mcrpure

Multivariate curve resolution based on pure variables
mcrals.ols

Ordinary least squares
mda.subset

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

Wrapper for show() method
mcrals

Multivariate curve resolution using Alternating Least Squares
mdaplot.formatValues

Format vector with numeric values
mda.purgeCols

Removes excluded (hidden) colmns from data
mda.t

A wrapper for t() method with proper set of attributes
mdaplot.getYAxisLim

Calculate limits for y-axis.
mdaplot.areColors

Check color values
mda.purge

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

Prepare xticklabels for plot
mdaplot.getXAxisLim

Calculate limits for x-axis.
mda.exclrows

Exclude/hide rows in a dataset
mda.rbind

A wrapper for rbind() method with proper set of attributes
mdaplot.getYTickLabels

Prepare yticklabels for plot
mdaplotg.getYLim

Compute y-axis limits for mdaplotg
mdaplotg

Plotting function for several plot series
mdaplotg.prepareData

Prepare data for mdaplotg
mdaplot.showLines

Plot lines
mda.getattr

Get data attributes
mdaplot.getColors

Color values for plot elements
mdaplot.getXTicks

Prepare xticks for plot
mdaplot

Plotting function for a single set of objects
mdaplot.getYTicks

Prepare yticks for plot
mdaplot.plotAxes

Create axes plane
mdaplot.prepareColors

Prepare colors based on palette and opacity value
mdaplotg.getXLim

Compute x-axis limits for mdaplotg
mdaplotg.getLegend

Create and return vector with legend values
pca.getB

Low-dimensional approximation of data matrix X
pca.cal

PCA model calibration
mdaplot.showColorbar

Plot colorbar
mdaplotyy

Create line plot with double y-axis
pcares

Results of PCA decomposition
people

People data
pca

Principal Component Analysis
pca.nipals

NIPALS based PCA algorithm
plot.plsda

Model overview plot for PLS-DA
pinv

Pseudo-inverse matrix
pca.svd

Singular Values Decomposition based PCA algorithm
plot.simcam

Model overview plot for SIMCAM
pca.run

Runs one of the selected PCA methods
plot.ipls

Overview plot for iPLS results
mdaplotg.processParam

Check mdaplotg parameters and replicate them if necessary
plot.plsdares

Overview plot for PLS-DA results
plot.simca

Model overview plot for SIMCA
plotBiplot

Biplot
pca.mvreplace

Replace missing values in data
plotBiplot.pca

PCA biplot
plot.classres

Plot function for classification results
mdaplotg.showLegend

Show legend for mdaplotg
pellets

Image data
plotContributions.mcr

Show plot with resolved contributions
plotConvexHull

Add convex hull for groups of points on scatter plot
pcv

Compute matrix with pseudo-validation set
plot.pls

Model overview plot for PLS
plot.pcares

Plot method for PCA results object
plot.mcr

Plot summary for MCR model
plot.pca

Model overview plot for PCA
plotCumVariance

Variance plot
plotCorr.randtest

Correlation plot for randomization test results
plotDiscriminationPower.simcam

Discrimination power plot for SIMCAM model
plotDiscriminationPower

Discrimination power plot
mdatools

Package for Multivariate Data Analysis (Chemometrics)
plotBars

Show plot series as bars
plot.simcamres

Model overview plot for SIMCAM results
plotCumVariance.ldecomp

Cumulative explained variance plot
plotCumVariance.mcr

Show plot with cumulative explained variance
plot.regcoeffs

Regression coefficients plot
plotHist.randtest

Histogram plot for randomization test results
plot.randtest

Plot for randomization test results
plotHist

Statistic histogram
plotPerformance.classmodel

Performance plot for classification model
plotPerformance

Classification performance plot
plotLines

Show plot series as set of lines
plotHotellingEllipse

Hotelling ellipse
plot.plsres

Overview plot for PLS results
plotMisclassified

Misclassification ratio plot
plotMisclassified.classmodel

Misclassified ratio plot for classification model
plotCooman

Cooman's plot
plotConfidenceEllipse

Add confidence ellipse for groups of points on scatter plot
plot.regres

Plot method for regression results
plotContributions

Plot resolved contributions
plotCooman.simcamres

Cooman's plot for SIMCAM results
plotDistDoF

Degrees of freedom plot for both distances
plotErrorbars

Show plot series as error bars
plotCorr

Correlation plot
plotLoadings

Loadings plot
plotCooman.simcam

Cooman's plot for SIMCAM model
plotMisclassified.classres

Misclassified ratio plot for classification results
plotPredictions.regres

Predictions plot for regression results
plotRMSE

RMSE plot
plotModellingPower

Modelling power plot
plotModelDistance.simcam

Model distance plot for SIMCAM model
plotExtreme

Shows extreme plot for SIMCA model
plotExtreme.pca

Extreme plot
plotDensity

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

Add confidence ellipse or convex hull for group of points
plotModelDistance

Model distance plot
plotRMSE.ipls

RMSE development plot
plotPredictions.simcam

Predictions plot for SIMCAM model
plotResiduals.regres

Residuals plot for regression results
plotScatter

Show plot series as set of points
plotRMSERatio

Plot for ratio RMSEC/RMSECV vs RMSECV
plotCumVariance.pca

Cumulative explained variance plot for PCA model
plotPerformance.classres

Performance plot for classification results
plotQDoF

Degrees of freedom plot for orthogonal distance (Nh)
plotPredictions.classres

Prediction plot for classification results
plotPredictions.regmodel

Predictions plot for regression model
plotLoadings.pca

Loadings plot for PCA model
plotPredictions.simcamres

Prediction plot for SIMCAM results
plotRegressionLine

Add regression line for data points
plotScores.pca

Scores plot for PCA model
plotPurity

Plot purity values
plotProbabilities.classres

Plot for class belonging probability
plotPredictions

Predictions plot
plotRMSERatio.regmodel

RMSECV/RMSEC ratio plot for regression model
plotResiduals.ldecomp

Residual distance plot
plotSpecificity.classres

Specificity plot for classification results
plotSpectra

Plot resolved spectra
plotResiduals.pca

Residuals distance plot for PCA model
plotResiduals

Residuals plot
plotPuritySpectra.mcrpure

Purity spectra plot
plotPredictions.classmodel

Predictions plot for classification model
plotScores

Scores plot
plotProbabilities

Plot for class belonging probability
plotPuritySpectra

Plot purity spectra
plotPurity.mcrpure

Purity values plot
plotXLoadings.pls

X loadings plot for PLS
plotSensitivity.classmodel

Sensitivity plot for classification model
plotScores.ldecomp

Scores plot
plotXCumVariance.pls

Cumulative explained X variance plot for PLS
plotXVariance.pls

Explained X variance plot for PLS
plotXScores.plsres

X scores plot for PLS results
plotT2DoF

Degrees of freedom plot for score distance (Nh)
plotXResiduals

X residuals plot
plotVIPScores.pls

VIP scores plot for PLS model
plotXCumVariance

X cumulative variance plot
plotYCumVariance

Y cumulative variance plot
plotSelection

Selected intervals plot
plotYCumVariance.pls

Cumulative explained Y variance plot for PLS
plotXVariance

X variance plot
plotSpectra.mcr

Show plot with resolved spectra
plotSensitivity.classres

Sensitivity plot for classification results
plotRMSE.regmodel

RMSE plot for regression model
plotVIPScores

VIP scores plot
plotXVariance.plsres

Explained X variance plot for PLS results
plotXYLoadings

X loadings plot
plotXYResiduals

Plot for XY-residuals
plotWeights

Plot for PLS weights
plotWeights.pls

X loadings plot for PLS
plotSelection.ipls

iPLS performance plot
plotRMSE.regres

RMSE plot for regression results
plotXYLoadings.pls

XY loadings plot for PLS
pls.getZLimits

Compute critical limits for orthogonal distances (Q)
plotXResiduals.plsres

X residuals plot for PLS results
plotYVariance

Y variance plot
plotXYResiduals.pls

Residual XY-distance plot
plotRegcoeffs

Regression coefficients plot
plotRegcoeffs.regmodel

Regression coefficient plot for regression model
plotSelectivityRatio

Selectivity ratio plot
plotXResiduals.pls

Residual distance plot for decomposition of X data
pls.getLimitsCoordinates

Compute coordinates of lines or curves with critical limits
plotYResiduals.plsres

Y residuals plot for PLS results
plotYResiduals.regmodel

Y residuals plot for regression model
pls.getyscores

Compute and orthogonalize matrix with Y-scores
pls.run

Runs selected PLS algorithm
plotYCumVariance.plsres

Explained cumulative Y variance plot for PLS results
pls.getxscores

Compute matrix with X-scores
plotSensitivity

Sensitivity plot
plotYResiduals

Y residuals plot
plotSelectivityRatio.pls

Selectivity ratio plot for PLS model
pls.getydecomp

Compute object with decomposition of y-values
plotVariance.mcr

Show plot with explained variance
pls.simpls

SIMPLS algorithm
plotXLoadings

X loadings plot
plotYVariance.pls

Explained Y variance plot for PLS
plotXYResiduals.plsres

Residual distance plot
plotXScores

X scores plot
plotVariance.pca

Explained variance plot for PCA model
plotXScores.pls

X scores plot for PLS
plotXYScores

XY scores plot
plotXCumVariance.plsres

Explained cumulative X variance plot for PLS results
plotYVariance.plsres

Explained Y variance plot for PLS results
predict.mcrpure

MCR predictions
pls.simplsold

SIMPLS algorithm (old implementation)
prep.snv

Standard Normal Variate transformation
plotseries

Create plot series object based on data, plot type and parameters
prep.savgol

Savytzky-Golay filter
plsres

PLS results
predict.mcrals

MCR ALS predictions
prep.list

Shows information about all implemented preprocessing methods.
predict.simcam

SIMCA multiple classes predictions
prep

Class for preprocessing object
plsdares

PLS-DA results
predict.simca

SIMCA predictions
predict.pca

PCA predictions
prep.autoscale

Autoscale values
prep.alsbasecorr

Baseline correction using asymetric least squares
prep.msc

Multiplicative Scatter Correction transformation
print.pcares

Print method for PCA results object
print.pca

Print method for PCA model object
prep.ref2km

Kubelka-Munk transformation
print.simcam

Print method for SIMCAM model object
prep.norm

Normalization
plsda

Partial Least Squares Discriminant Analysis
print.randtest

Print method for randtest object
plotSpecificity.classmodel

Specificity plot for classification model
prep.generic

Generic function for preprocessing
print.mcrpure

Print method for mcrpure object
plotVariance.ldecomp

Explained variance plot
plotVariance

Variance plot
preparePlotData

Take dataset and prepare them for plot
plotSpecificity

Specificity plot
print.pls

Print method for PLS model object
regres.r2

Determination coefficient
print.regres

print method for regression results object
selratio

Selectivity ratio calculation
print.simcamres

Print method for SIMCAM results object
regres.slope

Slope
regres.rmse

RMSE
plotXYScores.plsres

XY scores plot for PLS results
print.plsres

print method for PLS results object
setDistanceLimits

Set residual distance limits
plotVariance.plsres

Explained X variance plot for PLS results
plotVariance.pls

Variance plot for PLS
prepCalData

Prepares calibration data
print.regcoeffs

print method for regression coefficients class
regres.err

Error of prediction
print.simca

Print method for SIMCA model object
showDistanceLimits

Show residual distance limits
setDistanceLimits.pca

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

Replicate matric x
showLabels

Show labels on plot
print.classres

Print information about classification result object
plotXYScores.pls

XY scores plot for PLS
pls.cal

PLS model calibration
print.ipls

Print method for iPLS
regres

Regression results
predict.plsda

PLS-DA predictions
print.plsda

Print method for PLS-DA model object
prep.varsel

Variable selection
print.ldecomp

Print method for linear decomposition
regres.bias

Prediction bias
pls

Partial Least Squares regression
print.regmodel

Print method for PLS model object
summary.regcoeffs

Summary method for regcoeffs object
regress.addattrs

Add names and attributes to matrix with statistics
pls.getpredictions

Compute predictions for response values
pls.getxdecomp

Compute object with decomposition of x-values
randtest

Randomization test for PLS regression
print.plsdares

Print method for PLS-DA results object
regcoeffs.getStats

Distribution statistics for regression coeffificents
setDistanceLimits.pls

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

PLS predictions
print.mcrals

Print method for mcrpure object
prep.transform

Transformation
summary.ipls

Summary for iPLS results
summary.classres

Summary statistics about classification result object
simdata

Spectral data of polyaromatic hydrocarbons mixing
selectCompNum.pls

Select optimal number of components for PLS model
print.simcares

Print method for SIMCA results object
summary.regmodel

Summary method for regression model object
simcares

Results of SIMCA one-class classification
regcoeffs

Regression coefficients
splitExcludedData

Split the excluded part of data
showPredictions

Predictions
selectCompNum.pca

Select optimal number of components for PCA model
summary.simcares

Summary method for SIMCA results object
rotationMatrixToX1

Creates a rotation matrix to map a vector x to [1 0 0 ... 0]
simcam.getPerformanceStats

Performance statistics for SIMCAM model
simcamres

Results of SIMCA multiclass classification
summary.pcares

Summary method for PCA results object
splitPlotData

Split dataset to x and y values depending on plot type
unmix.mcrpure

Unmix spectral data using pure variables estimated before
showPredictions.classres

Show predicted class values
summary.mcrpure

Summary method for mcrpure object
selectCompNum

Select optimal number of components for a model
simca

SIMCA one-class classification
summary.randtest

Summary method for randtest object
summary.plsres

summary method for PLS results object
summary.ldecomp

Summary statistics for linear decomposition
summary.mcrals

Summary method for mcrals object
summary.regres

summary method for regression results object
simcam

SIMCA multiclass classification
summary.simca

Summary method for SIMCA model object
summary.pca

Summary method for PCA model object
vipscores

VIP scores for PLS model
summary.plsda

Summary method for PLS-DA model object
summary.plsdares

Summary method for PLS-DA results object
summary.pls

Summary method for PLS model object
summary.simcamres

Summary method for SIMCAM results object
summary.simcam

Summary method for SIMCAM model object