Chemometric functions in Excel Oxana Rodionova & Alexey Pomerantsev Semenov Institute of Chemical Physics rcs@chph.ras.ru 01.12.08
Distance Learning Course in Chemometrics for Technological and Natural-Science Mastership Education Unfulfilled need in chemometric education in Russia Low number of qualified specialists in chemometrics Large distances, e.g. Moscow – Barnaul is about 3000 km No modern chemometrics books in Russian No available chemometric software No support from officials: government, Academy, etc 3000 km Easy available everywhere => INTERNET Interactive layout: all calculations should be clear and repeatable Web friendly environment for the calculations => EXCEL Necessity to make and use our own (free) software => EXCEL Add-In 4000 km Barnaul 01.12.08
Chemometric calculations in Excel Provides user with all possibilities of Excel interface, worksheet calculations, worksheet functions, charts, etc. VBA helps to simplify routine work All calculations are made "on the fly“ and very fast 01.12.08
Installation http://rcs.chph.ras.ru/down/sacs.zip Chemometrics.dll put in your Windows folder (C:\WINDOWS\) Chemometrics. xla put in the AddInn folder (C:\Documents and Settings\ <User>\Application Data\ Microsoft\AddIns\) Load Chemometrics.xla by < Excel Options> <Add-Ins> in the open Workbook 01.12.08
Matrix calculations in Excel ={TRANSPOSE(B6:F10)} Ctrl-Shift-Enter B6:F10 Barr ={MMULT(B6:F10,TRANSPOSE(Barr))} 01.12.08
Principal Component Analysis (PCA) Initial data = + × Error matrix E I J A Score matrix T I Loading matrix X P J A PT J A I J X=TPT+E 01.12.08
Chemometrics XLA. PCA Scores Xcal Xtst Centering AND/OR weighting ={ScoresPCA(Xcal,5,1,Xtst)} nPC 01.12.08
Chemometrics XLA. PCA Loadings Xcal Excel worksheet function =TRANSPOSE(LoadingsPCA(Xcal,5,1))} nPC Centering AND/OR weighting 01.12.08
List of chemometric functions PCA ScoresPCA <for calibration or test samples> LoadingsPCA PLS ScoresPLS <X-scores for calibration or test samples> UScoresPLS <Y-scores for calibration or test samples> LoadingsPLS <P-loadings> WLoadingsPLS QLoadingsPLS PLS2 ScoresPLS2 <X-scores for calibration or test samples> UScoresPLS2 <Y-scores for calibration or test samples> LoadingsPLS2 <P-loadings> WLoadingsPLS2 QLoadingsPLS2 Options: Centering AND/OR scaling Number of PCs 01.12.08
X data (calibration set) ScoresPCA X data (calibration set) ScoresPCA (rMatrix [, nPCs] [,nCentWeightX] [, rMatrixNew] ) Number of PC (A) Test set centering and/or scaling 1 centering 2 scaling 3 both X[IJ] T[I A] 01.12.08
10% -out cross-validation Validation Rules If rMatrixNew is omitted then only calibration scores are calculated If rMatrixNew is specified then only test scores are calculated If rMatrixNew coincides with rMatrix then cross-validation is calculated 10% -out cross-validation 01.12.08
X data (calibration set) LoadingsPCA X data (calibration set) LoadingsPCA (rMatrix [, nPCs] [,nCentWeightX]) Number of PC (A) centering and/or scaling 1 centering 2 scaling 3 both X[IJ] P[J A] 01.12.08
Explorative Data Analysis Case study 1: People 01.12.08
People 01.12.08
Dataset in Excel Workbook (People.xls) Number of objects (n) = 32 Number of variables (m) = 12 01.12.08
Data Preprocessing Aim: to transform the data into the most suitable form for data analysis 01.12.08
Autoscaling mean centering scaling autoscaling + = 01.12.08
People: Scores & Loadings (PC1 vs. PC2) “Map of Samples” “Map of Variables” 01.12.08
People: Scores & Loadings (PC1 vs. PC3) Loading plot Score plot 01.12.08
Case study 2: HPLC-DAD 01.12.08
Measurements 01.12.08
Dataset in Excel Workbook 01.12.08
If we observe X can we predict C and S ? Pure compounds A and B If we observe X can we predict C and S ? X=CST+E 01.12.08
Score plot A B 01.12.08
Conclusions from the Score Plot 1. Linear regions = Pure compounds 2. Curved line= Co-elution 3. Closer to the origin = Lower intensity 4. Number of bends = Number of different compounds 01.12.08
Factor analysis vs. PCA analysis X E1 + = C ST × 2 J I X E2 + = T PT × A J I 01.12.08
Scores and Loadings 01.12.08
Procrustes transformation X ≈ CST X ≈ TPT I = RRT = Identity matrix X ≈ T(RRT)PT = (TR)(PR)T C ≈ TR S ≈ PR R = Rstretch ×Rrotation ^ ^ 01.12.08
Scores Transformation Stretching Rotation 01.12.08
Procrustes analysis results 01.12.08
Conclusions Scaling and centering is problem dependent In this example number of PCs = Number of different compounds 01.12.08
Regression 01.12.08
Principal Component Regression (PCR) 1 t A ... P T X 1) PCA y T a = + e 2) MLR 01.12.08
Projection on Latent Structures (PLS) Q U P T W p 1 t A ... X u 1 A ... q t Y w 1 t A ... 01.12.08
Projection on Latent Structures (PLS) B = + e Y 01.12.08
PLS and PLS2 b = + e y T 1 PLS B = + E Y T M PLS2 01.12.08
ScoresPLS X[IJ], Y[I1] T[IA] X data (calibration set) Y data (calibration set) ScoresPLS (rMatrixX, rMatrixY [, nPCs] [, nCentWeightX] [, nCentWeightY] [, rMatrixXNew]) Number of PC (A) X Test set centering and/or scaling of X 1 centering 2 scaling 3 both centering and/or scaling of Y 1 centering 2 scaling 3 both X[IJ], Y[I1] T[IA] 01.12.08
UScoresPLS X[IJ] , Y[I1] U[I A] X data (calibration set) Y data (calibration set) UScoresPLS (rMatrixX, rMatrixY [, nPCs] [, nCentWeightX] [, nCentWeightY] [, rMatrixXNew] [, rMatrixYNew]) Number of PC (A) X Test set Y Test set centering and/or scaling of X 1 centering 2 scaling 3 both centering and/or scaling of Y 1 centering 2 scaling 3 both X[IJ] , Y[I1] U[I A] 01.12.08
WLoadingsPLS X[IJ] , Y[I1] W[J A] X data (calibration set) Y data (calibration set) WLoadingsPLS (rMatrixX, rMatrixY [, nPCs] [, nCentWeightX] [, nCentWeightY]) Number of PC (A) centering and/or scaling of X 1 centering 2 scaling 3 both centering and/or scaling of Y 1 centering 2 scaling 3 both X[IJ] , Y[I1] W[J A] 01.12.08
LoadingsPLS X[IJ] , Y[I1] P[JA] X data (calibration set) Y data (calibration set) LoadingsPLS (rMatrixX, rMatrixY [, nPCs] [, nCentWeightX] [, nCentWeightY]) Number of PC (A) centering and/or scaling of X 1 centering 2 scaling 3 both centering and/or scaling of Y 1 centering 2 scaling 3 both X[IJ] , Y[I1] P[JA] 01.12.08
QLoadingsPLS X[IJ], Y[I1] Q[1 A] X data (calibration set) Y data (calibration set) QLoadingsPLS (rMatrixX, rMatrixY [, nPCs] [, nCentWeightX] [, nCentWeightY]) Number of PC (A) centering and/or scaling of X 1 centering 2 scaling 3 both centering and/or scaling of Y 1 centering 2 scaling 3 both X[IJ], Y[I1] Q[1 A] 01.12.08
ScoresPLS2 X[IJ], Y[IK] T[I A] X data (calibration set) Y data (calibration set) ScoresPLS2 (rMatrixX, rMatrixY [, nPCs] [, nCentWeightX] [, nCentWeightY] [, rMatrixXNew]) Number of PC (A) X Test set centering and/or scaling of X 1 centering 2 scaling 3 both centering and/or scaling of Y 1 centering 2 scaling 3 both X[IJ], Y[IK] T[I A] 01.12.08
UScoresPLS2 X[IJ], Y[IK] U[I A] X data (calibration set) Y data (calibration set) UScoresPLS2 (rMatrixX, rMatrixY [, nPCs] [, nCentWeightX] [, nCentWeightY] [, rMatrixXNew] [, rMatrixYNew]) Number of PC (A) X Test set Y Test set centering and/or scaling of X 1 centering 2 scaling 3 both centering and/or scaling of Y 1 centering 2 scaling 3 both X[IJ], Y[IK] U[I A] 01.12.08
LoadingsPLS2 WLoadingsPLS2 QLoadingsPLS2 X data (calibration set) Y data (calibration set) LoadingsPLS2 (rMatrixX, rMatrixY [, nPCs] [, nCentWeightX] [, nCentWeightY]) Number of PC (A) centering and/or scaling of X 1 centering 2 scaling 3 both centering and/or scaling of Y 1 centering 2 scaling 3 both X[IJ], Y[IK] P[J A] or W[J A] or Q[K A] 01.12.08
Seventh Winter Symposium on Chemometrics near Tula city, February 2010 100 km 01.12.08