Learn R Programming

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.14.2, August 2024) 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 on CRAN, to install it just use:

install.packages("mdatools")

This is the recommended way to install the package. If you have installed it already and just want to update to the newest version, use:

update.packages("mdatools")

If you want to install it directly from GitHub, the easiest way is to install the devtools package first and then run the following command in R:

devtools::install_github("svkucheryavski/mdatools")

Copy Link

Version

Install

install.packages('mdatools')

Monthly Downloads

993

Version

0.14.2

License

MIT + file LICENSE

Last Published

August 19th, 2024

Functions in mdatools (0.14.2)

plot.plsres

Overview plot for PLS results
getPureVariables

Identifies pure variables
mda.t

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

Fast combinatorial non-negative least squares
mdaplot.getColors

Color values for plot elements
plot.randtest

Plot for randomization test results
getSelectivityRatio.pls

Selectivity ratio for PLS model
capitalize

Capitalize text or vector with text values
mdaplot.getYTicks

Prepare yticks for plot
crossval.regmodel

Cross-validation of a regression model
confint.regcoeffs

Confidence intervals for regression coefficients
plot.regcoeffs

Regression coefficients plot
getSelectivityRatio

Selectivity ratio
getCalibrationData

Calibration data
as.matrix.regres

as.matrix method for regression results
classres

Results of classification
as.matrix.simcares

as.matrix method for SIMCA classification results
crossval.str

String with description of cross-validation method
mda.df2mat

Convert data frame to a matrix
mdaplot.prepareColors

Prepare colors based on palette and opacity value
mcrals.nnls

Non-negative least squares
getVIPScores

VIP scores
mda.purgeCols

Removes excluded (hidden) colmns from data
as.matrix.regcoeffs

as.matrix method for regression coefficients class
getImplementedConstraints

Shows a list with implemented constraints
classify.simca

SIMCA classification
crossval.getParams

Define parameters based on 'cv' value
as.matrix.simcamres

as.matrix method for SIMCAM results
mdaplot.getXTickLabels

Prepare xticklabels for plot
ldecomp.getLimitsCoordinates

Compute coordinates of lines or curves with critical limits
constraintUnimod

Method for unimodality constraint
classmodel.processRefValues

Check reference class values and convert it to a factor if necessary
constraintAngle

Method for angle constraint
classres.getPerformance

Calculation of classification performance parameters
mda.inclcols

Include/unhide the excluded columns
categorize.pls

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

Model overview plot for PLS
mda.data2im

Convert data matrix to an image
constraints.list

Shows information about all implemented constraints
mda.getexclind

Get indices of excluded rows or columns
dd.crit

Calculates critical limits for distance values using Data Driven moments approach
mdaplotg.processParam

Check mdaplotg parameters and replicate them if necessary
mcrals

Multivariate curve resolution using Alternating Least Squares
plot.pca

Model overview plot for PCA
getVariance.mcr

Compute explained variance for MCR case
plotCorr

Correlation plot
chisq.crit

Calculates critical limits for distance values using Chi-square distribution
employ.prep

Applies a list with preprocessing methods to a dataset
getCalibrationData.pca

Returns matrix with original calibration data
getConfidenceEllipse

Compute confidence ellipse for a set of points
getRegcoeffs

Get regression coefficients
constraintClosure

Method for closure constraint
plotRMSERatio.regmodel

RMSECV/RMSEC ratio plot for regression model
mdaplot.getXAxisLim

Calculate limits for x-axis.
getLabelsAsIndices

Create labels as column or row indices
ddmoments.param

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

Class for MCR-ALS constraint
getConfusionMatrix.classres

Confusion matrix for classification results
getImplementedPrepMethods

Shows a list with implemented preprocessing methods
getConfusionMatrix

Confusion matrix for classification results
crossval.simca

Cross-validation of a SIMCA model
carbs

Raman spectra of carbonhydrates
ldecomp.getLimParams

Compute parameters for critical limits based on calibration results
ellipse

Create ellipse on the current plot
pls.getxdecomp

Compute object with decomposition of x-values
getRegcoeffs.regmodel

Regression coefficients for PLS model'
hotelling.prob

Calculate probabilities for distance values and given parameters using Hotelling T2 distribution
employ.constraint

Applies constraint to a dataset
plotLoadings.pca

Loadings plot for PCA model
getLabelsAsValues

Create labels from data values
mda.getattr

Get data attributes
mcrpure

Multivariate curve resolution based on pure variables
mda.im2data

Convert image to data matrix
getConvexHull

Compute coordinates of a closed convex hull for data points
mda.setattr

Set data attributes
ldecomp.getQLimits

Compute critical limits for orthogonal distances (Q)
getProbabilities

Get class belonging probability
mdaplotyy

Create line plot with double y-axis
mcrals.ols

Ordinary least squares
jm.prob

Calculate probabilities for distance values and given parameters using Hotelling T2 distribution
getVIPScores.pls

VIP scores for PLS model
getProbabilities.pca

Probabilities for residual distances
summary.pcares

Summary method for PCA results object
plotMisclassified

Misclassification ratio plot
mda.subset

A wrapper for subset() method with proper set of attributed
as.matrix.plsdares

as.matrix method for PLS-DA results
plotCooman.simcam

Cooman's plot for SIMCAM model
ldecomp.getDistances

Compute score and residual distances
as.matrix.plsres

as.matrix method for PLS results
plot.ipls

Overview plot for iPLS results
mda.show

Wrapper for show() method
plotCumVariance.mcr

Show plot with cumulative explained variance
hotelling.crit

Calculate critical limits for distance values using Hotelling T2 distribution
plotContributions

Plot resolved contributions
mdaplot

Plotting function for a single set of objects
plotSelection.ipls

iPLS performance plot
plotPredictions

Predictions plot
plot.mcr

Plot summary for MCR model
mdaplotg.showLegend

Show legend for mdaplotg
mda.purge

Removes excluded (hidden) rows and colmns from data
mda.setimbg

Remove background pixels from image data
mda.exclcols

Exclude/hide columns in a dataset
plotCumVariance

Variance plot
mda.inclrows

include/unhide the excluded rows
plotRMSE.ipls

RMSE development plot
crossval

Generate sequence of indices for cross-validation
categorize.pca

Categorize PCA results based on orthogonal and score distances.
ddrobust.param

Calculates critical limits for distance values using Data Driven robust approach
pca.mvreplace

Replace missing values in data
categorize

Categorize PCA results
getCalibrationData.simcam

Get calibration data
plotWeights.pls

X loadings plot for PLS
getMainTitle

Get main title
pinv

Pseudo-inverse matrix
plotCumVariance.ldecomp

Cumulative explained variance plot
getDataLabels

Create a vector with labels for plot series
plotCumVariance.pca

Cumulative explained variance plot for PCA model
plotQDoF

Degrees of freedom plot for orthogonal distance (Nh)
plotXCumVariance.pls

Cumulative explained X variance plot for PLS
ldecomp.getVariances

Compute explained variance
ldecomp

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

Plot lines
getPlotColors

Define colors for plot series
ldecomp.getT2Limits

Compute critical limits for score distances (T2)
plotYCumVariance.plsres

Explained cumulative Y variance plot for PLS results
jm.crit

Calculate critical limits for distance values using Jackson-Mudholkar approach
plot.simcam

Model overview plot for SIMCAM
plotPuritySpectra

Plot purity spectra
mdaplot.plotAxes

Create axes plane
mdaplotg

Plotting function for several plot series
selectCompNum.pca

Select optimal number of components for PCA model
plot.pcares

Plot method for PCA results object
mdatools

Package for Multivariate Data Analysis (Chemometrics)
ipls.forward

Runs the forward iPLS algorithm
getProbabilities.simca

Probabilities of class belonging for PCA/SIMCA results
imshow

show image data as an image
mcrals.cal

Identifies pure variables
people

People data
plotModelDistance.simcam

Model distance plot for SIMCAM model
mda.purgeRows

Removes excluded (hidden) rows from data
plotConvexHull

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

Correlation plot for randomization test results
plotSensitivity

Sensitivity plot
plot.plsdares

Overview plot for PLS-DA results
plotSpecificity.classres

Specificity plot for classification results
pca

Principal Component Analysis
plotRegcoeffs

Regression coefficients plot
getRes

Return list with valid results
plotXYLoadings

X loadings plot
plotModelDistance

Model distance plot
plotDiscriminationPower.simcam

Discrimination power plot for SIMCAM model
mdaplotg.getLegend

Create and return vector with legend values
mda.cbind

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

Show plot with resolved contributions
plotPurity

Plot purity values
plotPointsShape

Add confidence ellipse or convex hull for group of points
mdaplotg.getYLim

Compute y-axis limits for mdaplotg
mda.exclrows

Exclude/hide rows in a dataset
plotResiduals.regres

Residuals plot for regression results
plotExtreme.pca

Extreme plot
mdaplot.getXTicks

Prepare xticks for plot
mdaplot.showColorbar

Plot colorbar
pca.cal

PCA model calibration
pca.svd

Singular Values Decomposition based PCA algorithm
mda.rbind

A wrapper for rbind() method with proper set of attributes
plot.classres

Plot function for classification results
plotRMSE

RMSE plot
plot.simcamres

Model overview plot for SIMCAM results
mdaplot.getYAxisLim

Calculate limits for y-axis.
ipls.backward

Runs the backward iPLS algorithm
plotVariance

Variance plot
plotMisclassified.classmodel

Misclassified ratio plot for classification model
plot.plsda

Model overview plot for PLS-DA
plotXCumVariance.plsres

Explained cumulative X variance plot for PLS results
plotPredictions.classres

Prediction plot for classification results
mdaplot.getYTickLabels

Prepare yticklabels for plot
plotYCumVariance.pls

Cumulative explained Y variance plot for PLS
plotSelectivityRatio.pls

Selectivity ratio plot for PLS model
pca.getB

Low-dimensional approximation of data matrix X
plotSelection

Selected intervals plot
plotDensity

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

Show plot series as bars
plotYResiduals

Y residuals plot
plotMisclassified.classres

Misclassified ratio plot for classification results
predict.pca

PCA predictions
plotHist

Statistic histogram
plotXLoadings

X loadings plot
plotSpecificity.classmodel

Specificity plot for classification model
plotT2DoF

Degrees of freedom plot for score distance (Nh)
plotPredictions.classmodel

Predictions plot for classification model
pls.getLimitsCoordinates

Compute coordinates of lines or curves with critical limits
pls.simpls

SIMPLS algorithm
summary.ldecomp

Summary statistics for linear decomposition
plotPuritySpectra.mcrpure

Purity spectra plot
mdaplotg.prepareData

Prepare data for mdaplotg
setDistanceLimits

Set residual distance limits
predict.pls

PLS predictions
plotXVariance.plsres

Explained X variance plot for PLS results
plotCooman

Cooman's plot
plotVIPScores

VIP scores plot
plsdares

PLS-DA results
print.pca

Print method for PCA model object
selectCompNum

Select optimal number of components for a model
pcares

Results of PCA decomposition
plotPerformance.classres

Performance plot for classification results
plotXLoadings.pls

X loadings plot for PLS
as.matrix.classres

as.matrix method for classification results
pellets

Image data
plotXScores.pls

X scores plot for PLS
plotRMSE.regres

RMSE plot for regression results
plotVariance.ldecomp

Explained variance plot
plotScatter

Show plot series as set of points
plotVariance.mcr

Show plot with explained variance
plotSensitivity.classmodel

Sensitivity plot for classification model
pls

Partial Least Squares regression
plotPredictions.regres

Predictions plot for regression results
plotHist.randtest

Histogram plot for randomization test results
plotPerformance

Classification performance plot
setDistanceLimits.pca

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

SIMCA predictions
plotSelectivityRatio

Selectivity ratio plot
plotCooman.simcamres

Cooman's plot for SIMCAM results
plotYResiduals.regmodel

Y residuals plot for regression model
plotXCumVariance

X cumulative variance plot
plotBiplot

Biplot
plotProbabilities

Plot for class belonging probability
randtest

Randomization test for PLS regression
prep.snv

Standard Normal Variate transformation
plotPurity.mcrpure

Purity values plot
prep.msc

Multiplicative Scatter Correction transformation
pls.cal

PLS model calibration
plotScores.ldecomp

Scores plot
plsres

PLS results
regcoeffs.getStats

Distribution statistics for regression coeffificents
summary.classres

Summary statistics about classification result object
regres

Regression results
plotPredictions.regmodel

Predictions plot for regression model
plotDiscriminationPower

Discrimination power plot
mdaplot.areColors

Check color values
as.matrix.ldecomp

as.matrix method for ldecomp object
regcoeffs

Regression coefficients
plotHotellingEllipse

Hotelling ellipse
plotPerformance.classmodel

Performance plot for classification model
plotVIPScores.pls

VIP scores plot for PLS model
plotScores.pca

Scores plot for PCA model
print.pcares

Print method for PCA results object
plotYResiduals.plsres

Y residuals plot for PLS results
constraintNorm

Method for normalization constraint
prep.varsel

Variable selection
plotModellingPower

Modelling power plot
prep.transform

Transformation
plotLines

Show plot series as set of lines
plotXYResiduals.plsres

Residual distance plot
plotXYResiduals.pls

Residual XY-distance plot
plotYVariance.plsres

Explained Y variance plot for PLS results
plotLoadings

Loadings plot
plotDistDoF

Degrees of freedom plot for both distances
plotXScores.plsres

X scores plot for PLS results
predict.plsda

PLS-DA predictions
plotXVariance.pls

Explained X variance plot for PLS
plotYCumVariance

Y cumulative variance plot
summary.plsdares

Summary method for PLS-DA results object
pls.simplsold

SIMPLS algorithm (old implementation)
plotseries

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

Y variance plot
setDistanceLimits.pls

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

Runs selected PLS algorithm
summary.regcoeffs

Summary method for regcoeffs object
selectCompNum.pls

Select optimal number of components for PLS model
simcares

Results of SIMCA one-class classification
constraintNonNegativity

Method for non-negativity constraint
plotScores

Scores plot
plotRMSERatio

Plot for ratio RMSEC/RMSECV vs RMSECV
plsda

Partial Least Squares Discriminant Analysis
vipscores

VIP scores for PLS model
getSelectedComponents

Get selected components
prep.norm

Normalization
plotProbabilities.classres

Plot for class belonging probability
plotResiduals.pca

Residuals distance plot for PCA model
chisq.prob

Calculate probabilities for distance values using Chi-square distribution
print.regmodel

Print method for PLS model object
classify.plsda

PLS-DA classification
plotSpectra

Plot resolved spectra
plotRMSE.regmodel

RMSE plot for regression model
print.mcrpure

Print method for mcrpure object
simdata

Spectral data of polyaromatic hydrocarbons mixing
regres.bias

Prediction bias
plotBiplot.pca

PCA biplot
selratio

Selectivity ratio calculation
summary.pls

Summary method for PLS model object
plotXResiduals.plsres

X residuals plot for PLS results
plotSpecificity

Specificity plot
plotSensitivity.classres

Sensitivity plot for classification results
plotErrorbars

Show plot series as error bars
fprintf

Imitation of fprinf() function
plot.regres

Plot method for regression results
ldecomp.plotResiduals

Residuals distance plot for a set of ldecomp objects
print.mcrals

Print method for mcrpure object
plotXYLoadings.pls

XY loadings plot for PLS
ipls

Variable selection with interval PLS
summary.plsres

summary method for PLS results object
plotXYScores

XY scores plot
plotXYResiduals

Plot for XY-residuals
repmat

Replicate matric x
prepCalData

Prepares calibration data
plotRegressionLine

Add regression line for data points
mcr

General class for Multivariate Curve Resolution model
regres.err

Error of prediction
plotYVariance.pls

Explained Y variance plot for PLS
pls.getxscores

Compute matrix with X-scores
predict.mcrals

MCR ALS predictions
pls.getydecomp

Compute object with decomposition of y-values
mdaplot.formatValues

Format vector with numeric values
plotVariance.plsres

Explained X variance plot for PLS results
simca

SIMCA one-class classification
plotPredictions.simcamres

Prediction plot for SIMCAM results
simcam

SIMCA multiclass classification
print.regcoeffs

print method for regression coefficients class
summary.ipls

Summary for iPLS results
mdaplotg.getXLim

Compute x-axis limits for mdaplotg
pca.nipals

NIPALS based PCA algorithm
pca.run

Runs one of the selected PCA methods
plotWeights

Plot for PLS weights
summary.mcrals

Summary method for mcrals object
plotXVariance

X variance plot
plotXYScores.plsres

XY scores plot for PLS results
preparePlotData

Take dataset and prepare them for plot
summary.simcam

Summary method for SIMCAM model object
print.regres

print method for regression results object
plotXScores

X scores plot
prep.list

Shows information about all implemented preprocessing methods.
prep.alsbasecorr

Baseline correction using asymetric least squares
plot.simca

Model overview plot for SIMCA
splitExcludedData

Split the excluded part of data
regres.slope

Slope
print.simcamres

Print method for SIMCAM results object
plotConfidenceEllipse

Add confidence ellipse for groups of points on scatter plot
plotResiduals.ldecomp

Residual distance plot
prep.autoscale

Autoscale values
summary.simcares

Summary method for SIMCA results object
print.ldecomp

Print method for linear decomposition
plotExtreme

Shows extreme plot for SIMCA model
plotPredictions.simcam

Predictions plot for SIMCAM model
plotRegcoeffs.regmodel

Regression coefficient plot for regression model
print.randtest

Print method for randtest object
splitPlotData

Split dataset to x and y values depending on plot type
summary.randtest

Summary method for randtest object
summary.regmodel

Summary method for regression model object
print.ipls

Print method for iPLS
pls.getyscores

Compute and orthogonalize matrix with Y-scores
summary.simcamres

Summary method for SIMCAM results object
pls.getZLimits

Compute critical limits for orthogonal distances (Q)
regress.addattrs

Add names and attributes to matrix with statistics
plotVariance.pls

Variance plot for PLS
simcam.getPerformanceStats

Performance statistics for SIMCAM model
print.simcares

Print method for SIMCA results object
pls.getpredictions

Compute predictions for response values
print.pls

Print method for PLS model object
plotResiduals

Residuals plot
unmix.mcrpure

Unmix spectral data using pure variables estimated before
summary.regres

summary method for regression results object
plotXResiduals

X residuals plot
plotVariance.pca

Explained variance plot for PCA model
predict.simcam

SIMCA multiple classes predictions
prep

Class for preprocessing object
plotSpectra.mcr

Show plot with resolved spectra
prep.generic

Generic function for preprocessing
print.plsda

Print method for PLS-DA model object
print.plsdares

Print method for PLS-DA results object
plotXResiduals.pls

Residual distance plot for decomposition of X data
showLabels

Show labels on plot
print.classres

Print information about classification result object
plotXYScores.pls

XY scores plot for PLS
showDistanceLimits

Show residual distance limits
regres.r2

Determination coefficient
summary.plsda

Summary method for PLS-DA model object
predict.mcrpure

MCR predictions
simcamres

Results of SIMCA multiclass classification
print.simca

Print method for SIMCA model object
showPredictions

Predictions
regres.rmse

RMSE
showPredictions.classres

Show predicted class values
prep.ref2km

Kubelka-Munk transformation
prep.savgol

Savytzky-Golay filter
summary.mcrpure

Summary method for mcrpure object
print.plsres

print method for PLS results object
print.simcam

Print method for SIMCAM model object
summary.simca

Summary method for SIMCA model object
summary.pca

Summary method for PCA model object