Chemometrics


Julien Wist / 2017 / Universidad del Valle
Andrés Bernal / 2017 / ???

An up-to-date version of this notebook can be found here: https://github.com/jwist/chemometrics/


In [1]:
options(repr.plot.width=4, repr.plot.height=4)

In [3]:
# we load a few packages
library(ggplot2)
library(corrplot)
library(reshape2)
library(caret)
library(MASS) # for LDA
library(klaR) # for pls
library(pls)
library(e1071)# for pls
library(pROC) # for pls
library(vegan)
require(scales)
require(gridExtra);

Let's load some IR/NIR data


In [4]:
load(url('https://github.com/jwist/chemometrics/raw/master/datasets/Coffee-IR-binned.rda'))

In [5]:
load(url('https://github.com/jwist/chemometrics/raw/master/datasets/Coffee-IR-ppm-binned.rda'))

In [8]:
load(url('https://github.com/jwist/chemometrics/raw/master/datasets/Coffee-NIR-binned.rda'))

In [9]:
load(url('https://github.com/jwist/chemometrics/raw/master/datasets/CoffeeiIR.rda'))

look at the data


In [10]:
ls()


  1. 'allIRs'
  2. 'irscale'
  3. 'nirdev2scale'
  4. 'ppm1'

In [26]:
names(allIRs)


  1. 'nmr'
  2. 'ir'
  3. 'nir'
  4. 'metadata'

In [27]:
dim(allIRs$nir)


  1. 85
  2. 900

In [33]:
options(repr.plot.width=8, repr.plot.height=3)
plot(nirdev2scale, allIRs$nir[1,], type='l', xlab='freq', ylab='relative intensity')



In [59]:
matplot(t(allIRs$nir), type='l')



In [34]:
dim(allIRs$ir)


  1. 85
  2. 1037

In [35]:
options(repr.plot.width=8, repr.plot.height=3)
plot(irscale, allIRs$ir[1,], type='l', xlab='freq', ylab='relative intensity')



In [58]:
matplot(t(allIRs$ir), type='l')


a look to the metadata


In [36]:
allIRs$metadata


IDdateReceptionnamecountrydepartmentcityspeciescompositionpresentationbeneficioTypefermentationTypedryingdryingTimecertificationcertificationTypecolorTemp.roastingX.Humidity.Sinarspecies1groups
1AC1160 Feb 2012 Rove100-14 India NA NA Robusta 100 tostado molido y verde molido unknown NA NA NA NA NA NA NA NA -1 Robusta
4AC1161 Feb 2012 Rove100-15 Indonesia NA NA Robusta 100 tostado molido y verde molido unknown NA NA NA NA NA NA NA NA -1 Robusta
7AC1162 Feb 2012 Rove100-16 Vietnam NA NA Robusta 100 tostado molido y verde molido unknown NA NA NA NA NA NA NA NA -1 Robusta
10AC1163 Feb 2012 Rove100-17 Vietnam NA NA Robusta 100 tostado molido y verde molido unknown NA NA NA NA NA NA NA NA -1 Robusta
13AC1164 Feb 2012 Rove100-18 Indonesia NA NA Robusta 100 tostado molido y verde molido unknown NA NA NA NA NA NA NA NA -1 Robusta
16AC1168 Mar 2012 TPAAH12002 Colombia Tolima Ibague 100% ARABICA COLOMBIA 0 tostado molido y verde molido h NA NA NA NA NA NA NA NA 1 Colombia
22AC1170 Mar 2012 TCHAH12003 Colombia Tolima Ibague 100% ARABICA COLOMBIA 0 tostado molido y verde molido h NA NA NA NA NA NA NA NA 1 Colombia
25AC1171 Mar 2012 TICOAH12008 Colombia Tolima Ibague 100% ARABICA COLOMBIA 0 tostado molido y verde molido h NA NA NA NA NA NA NA NA 1 Colombia
28AC1198 290312 BRAAS12062 Brazil NA NA Arabica 0 verde molido y tostado molido finos NA NA NA NA NA NA NA NA 1 Brazil
37AC1201 290312 HPAAH12051 Colombia Huila Palestina 100% ARABICA COLOMBIA 0 tostado molido y verde molido h NA NA NA NA NA NA NA NA 1 Colombia
40AC1204 290312 BRAAS12063 Brazil NA NA Arabica 0 verde molido y tostado molido finos NA NA NA NA NA NA NA NA 1 Brazil
43AC1205 290312 HSMAH12053 Colombia Huila Santa María 100% ARABICA COLOMBIA 0 tostado molido y verde molido h NA NA NA NA NA NA NA NA 1 Colombia
46AC1206 290312 HPAAH12049 Colombia Huila Paicol 100% ARABICA COLOMBIA 0 tostado molido y verde molido h NA NA NA NA NA NA NA NA 1 Colombia
52AC1208 290312 HCOAH12050 Colombia Huila Colombia 100% ARABICA COLOMBIA 0 tostado molido y verde molido h NA NA NA NA NA NA NA NA 1 Colombia
58AC1212 290312 MSMAH12043 Colombia Magdalena Santa Marta 100% ARABICA COLOMBIA 0 verde molido h NA NA NA NA NA NA NA NA 1 Colombia
61AC1213 290312 BRAAS12064 Brazil NA NA Arabica 0 verde molido y tostado molido finos NA NA NA NA NA NA NA NA 1 Brazil
64AC1216 290312 HNAAH12057 Colombia Huila Nataga 100% ARABICA COLOMBIA 0 tostado molido y verde molido h NA NA NA NA NA NA NA NA 1 Colombia
67AC1217 290312 HTEAH12048 Colombia Huila Tesalia 100% ARABICA COLOMBIA 0 tostado molido y verde molido h NA NA NA NA NA NA NA NA 1 Colombia
76AC1234 Jun2012 TANRS11078 Tanzania NA NA Robusta 100 verde molido y tostado molido finos NA NA NA NA NA NA NA NA -1 Robusta
79AC1241 Jun2012 NBUAH12031 Colombia Narino Buesaco 100% ARABICA COLOMBIA 0 verde molido y tostado molido finoh NA NA NA NA NA NA NA NA 1 Colombia
85AC1243 Jun2012 NTAAH12033 Colombia Narino Taminango 100% ARABICA COLOMBIA 0 verde molido y tostado molido finoh NA NA NA NA NA NA NA NA 1 Colombia
88AC1246 Jun2012 NTBAH12036 Colombia Narino Tablon 100% ARABICA COLOMBIA 0 verde molido y tostado molido finoh NA NA NA NA NA NA NA NA 1 Colombia
91AC1247 Jun2012 NROAH12037 Colombia Narino Rosario 100% ARABICA COLOMBIA 0 verde molido y tostado molido finoh NA NA NA NA NA NA NA NA 1 Colombia
94AC1248 Jun2012 NSJAH12038 Colombia Narino San Jose 100% ARABICA COLOMBIA 0 verde molido y tostado molido finoh NA NA NA NA NA NA NA NA 1 Colombia
97AC1250 Jun2012 VIERS11068 Vietnam NA NA Robusta 100 verde molido y tostado molido finos NA NA NA NA NA NA NA NA -1 Robusta
100AC1251 Jun2012 CAMRS11069 Cameroon NA NA Robusta 100 verde molido y tostado molido finos NA NA NA NA NA NA NA NA -1 Robusta
103AC1252 Jun2012 TOGRS11070 Togo NA NA Robusta 100 verde molido y tostado molido finos NA NA NA NA NA NA NA NA -1 Robusta
106AC1256 Jun2012 INDRH11073 India NA NA Robusta 100 verde molido y tostado molido finoh NA NA NA NA NA NA NA NA -1 Robusta
109AC1258 Jun2012 UGARS11075 Uganda NA NA Robusta 100 verde molido y tostado molido finos NA NA NA NA NA NA NA NA -1 Robusta
112AC1260 Jun2012 SUMRS11077 Indonesia Sumatra NA Robusta 100 verde molido y tostado molido finos NA NA NA NA NA NA NA NA -1 Robusta
201AC1347 80812 GUAAH12165 Guatemala Maracaturra NA Arabica 0 verde molido y tostado molido finoh NA NA NA NA NA NA NA NA 1 Others
204AC1348 80812 GUAAH12166 Guatemala Hueltuetenango NA Arabica 0 verde molido y tostado molido finoh NA NA NA NA NA NA NA NA 1 Others
207AC1349 80812 GUAAH12167 Guatemala Atitlan NA Arabica 0 verde molido y tostado molido finoh NA NA NA NA NA NA NA NA 1 Others
210AC1353 80812 CTIAH12172 Colombia Cauca Timbio 100% ARABICA COLOMBIA 0 verde molido y tostado molido finoh NA NA NA NA NA NA NA NA 1 Colombia
213AC1354 80812 CPIAH12173 Colombia Cauca Piendamo 100% ARABICA COLOMBIA 0 verde molido y tostado molido finoh NA NA NA NA NA NA NA NA 1 Colombia
216AC1355 80812 CPIAH12174 Colombia Cauca Piendamo 100% ARABICA COLOMBIA 0 verde molido y tostado molido finoh NA NA NA NA NA NA NA NA 1 Colombia
219AC1356 80812 CPIAH12175 Colombia Cauca Piendamo 100% ARABICA COLOMBIA 0 verde molido y tostado molido finoh NA NA NA NA NA NA NA NA 1 Colombia
222AC1358 80812 CPIAH12177 Colombia Cauca Piendamo 100% ARABICA COLOMBIA 0 verde molido y tostado molido finoh NA NA NA NA NA NA NA NA 1 Colombia
225AC1375 180213 BRAA?12187 Brazil NA NA Arabica 0 tostado molido fino unknown NA NA NA NA NA NA NA NA 1 Brazil
231AC1377 180213 PERAH12189 Peru NA NA Arabica 0 tostado molido fino h NA NA NA NA NA NA NA NA 1 Peru
234AC1379 180213 CRIAH12191 Costa Rica NA NA Arabica 0 tostado molido fino h NA NA NA NA NA NA NA NA 1 Others
240AC1382 180213 GUAAH12194 Guatemala Hueltuetenango NA Arabica 0 tostado molido fino h NA NA NA NA NA NA NA NA 1 Others
243AC1387 180213 PERAH12199 Peru NA NA Arabica 0 tostado molido fino h NA NA NA NA NA NA NA NA 1 Peru
246AC1388 180213 PERAH12200 Peru NA NA Arabica 0 tostado molido fino h NA NA NA NA NA NA NA NA 1 Peru
249AC1389 180213 VIERS12201 Vietnam NA NA Robusta 100 tostado molido fino s NA NA NA NA NA NA NA NA -1 Robusta
252AC1394 180213 GUALH12206 Guatemala NA NA Arabica 0 tostado molido fino h NA NA NA NA NA NA NA NA 1 Others
255AC1395 180213 GUALH12207 Guatemala NA NA Arabica 0 tostado molido fino h NA NA NA NA NA NA NA NA 1 Others
261AC1404 190313 GUAAH12213 Guatemala NA NA Arabica 0 tostado molido fino h NA NA NA NA NA NA NA NA 1 Others
264AC1405 190313 GUAAH12214 Guatemala NA NA Arabica 0 tostado molido fino h NA NA NA NA NA NA NA NA 1 Others
267AC1406 190313 BRAA?12215 Brazil NA NA Arabica 0 tostado molido fino unknown NA NA NA NA NA NA NA NA 1 Brazil
270AC1407 190313 PERAH12216 Peru NA NA Arabica 0 tostado molido fino h NA NA NA NA NA NA NA NA 1 Peru
273AC1409 190313 CRIAH12218 Costa Rica NA NA Arabica 0 tostado molido fino h NA NA NA NA NA NA NA NA 1 Others
276AC1412 190313 PERAH12221 Peru NA NA Arabica 0 tostado molido fino h NA NA NA NA NA NA NA NA 1 Peru
279AC1413 190313 GUAAH12222 Guatemala NA NA Arabica 0 tostado molido fino h NA NA NA NA NA NA NA NA 1 Others
288AC1421 90413 GUAAH12231 Guatemala NA NA Arabica 0 tostado molido fino h NA NA NA NA NA NA NA NA 1 Others
291AC1424 90413 CRIAH12234 Costa Rica NA NA Arabica 0 tostado molido fino h NA NA NA NA NA NA NA NA 1 Others
297AC1428 90413 PERAH13239 Peru NA NA Arabica 0 tostado molido fino h NA NA NA NA NA NA NA NA 1 Peru
303AC1432 90413 GUAAH13236 Guatemala NA NA Arabica 0 tostado molido fino h NA NA NA NA NA NA NA NA 1 Others
306AC1436 150413 CPOAH13245 Colombia Cauca Popayan 100% ARABICA COLOMBIA 0 tostado molido fino h NA NA NA NA NA NA NA NA 1 Colombia
309AC1437 150413 CINAH13246 Colombia Cauca Inza 100% ARABICA COLOMBIA 0 tostado molido fino h NA NA NA NA NA NA NA NA 1 Colombia

In [40]:
allIRs$metadata$species


  1. Robusta
  2. Robusta
  3. Robusta
  4. Robusta
  5. Robusta
  6. 100% ARABICA COLOMBIA
  7. 100% ARABICA COLOMBIA
  8. 100% ARABICA COLOMBIA
  9. Arabica
  10. 100% ARABICA COLOMBIA
  11. Arabica
  12. 100% ARABICA COLOMBIA
  13. 100% ARABICA COLOMBIA
  14. 100% ARABICA COLOMBIA
  15. 100% ARABICA COLOMBIA
  16. Arabica
  17. 100% ARABICA COLOMBIA
  18. 100% ARABICA COLOMBIA
  19. Robusta
  20. 100% ARABICA COLOMBIA
  21. 100% ARABICA COLOMBIA
  22. 100% ARABICA COLOMBIA
  23. 100% ARABICA COLOMBIA
  24. 100% ARABICA COLOMBIA
  25. Robusta
  26. Robusta
  27. Robusta
  28. Robusta
  29. Robusta
  30. Robusta
  31. Arabica
  32. Robusta
  33. Robusta
  34. Robusta
  35. Arabica
  36. Arabica
  37. Arabica
  38. 100% ARABICA COLOMBIA
  39. 100% ARABICA COLOMBIA
  40. 100% ARABICA COLOMBIA
  41. 100% ARABICA COLOMBIA
  42. 100% ARABICA COLOMBIA
  43. 100% ARABICA COLOMBIA
  44. 100% ARABICA COLOMBIA
  45. 100% ARABICA COLOMBIA
  46. Arabica
  47. Arabica
  48. Arabica
  49. Arabica
  50. Robusta
  51. Robusta
  52. Arabica
  53. Arabica
  54. Robusta
  55. Arabica
  56. Arabica
  57. Arabica
  58. Arabica
  59. 100% ARABICA COLOMBIA
  60. 100% ARABICA COLOMBIA
  61. 100% ARABICA COLOMBIA
  62. 100% ARABICA COLOMBIA
  63. 100% ARABICA COLOMBIA
  64. Arabica
  65. Arabica
  66. Arabica
  67. Arabica
  68. Arabica
  69. Arabica
  70. Robusta
  71. Arabica
  72. Arabica
  73. Arabica
  74. Arabica
  75. Arabica
  76. Arabica
  77. Arabica
  78. Arabica
  79. Arabica
  80. Arabica
  81. Arabica
  82. Arabica
  83. Arabica
  84. 100% ARABICA COLOMBIA
  85. 100% ARABICA COLOMBIA

In [43]:
duplicated(allIRs$metadata$ID)


  1. FALSE
  2. FALSE
  3. FALSE
  4. FALSE
  5. FALSE
  6. FALSE
  7. FALSE
  8. FALSE
  9. FALSE
  10. FALSE
  11. FALSE
  12. FALSE
  13. FALSE
  14. FALSE
  15. FALSE
  16. FALSE
  17. FALSE
  18. FALSE
  19. FALSE
  20. FALSE
  21. FALSE
  22. FALSE
  23. FALSE
  24. FALSE
  25. FALSE
  26. FALSE
  27. FALSE
  28. FALSE
  29. FALSE
  30. FALSE
  31. FALSE
  32. FALSE
  33. FALSE
  34. FALSE
  35. FALSE
  36. FALSE
  37. FALSE
  38. FALSE
  39. FALSE
  40. FALSE
  41. FALSE
  42. FALSE
  43. FALSE
  44. FALSE
  45. FALSE
  46. FALSE
  47. FALSE
  48. FALSE
  49. FALSE
  50. FALSE
  51. FALSE
  52. FALSE
  53. FALSE
  54. FALSE
  55. FALSE
  56. FALSE
  57. FALSE
  58. FALSE
  59. FALSE
  60. FALSE
  61. FALSE
  62. FALSE
  63. FALSE
  64. FALSE
  65. FALSE
  66. FALSE
  67. FALSE
  68. FALSE
  69. FALSE
  70. FALSE
  71. FALSE
  72. FALSE
  73. FALSE
  74. FALSE
  75. FALSE
  76. FALSE
  77. FALSE
  78. FALSE
  79. FALSE
  80. FALSE
  81. FALSE
  82. FALSE
  83. FALSE
  84. FALSE
  85. FALSE

save colors by groups


In [ ]:
levels(allIRs$metadata$species) <- c(1,2,3)
groupColors = factor(allIRs$metadata$species)
levels(allIRs$metadata$species) <- c("AC", "A", "R")

In [78]:
matplot(t(allIRs$ir), type='l', col=groupColors)


defining a few functions


In [37]:
Deriv1 <- function(x,y)
{
  y.prime <- diff(y) / diff(x)
  x.prime <- x[-length(x)] + diff(x)/2
  list(shift = x.prime,
       intensity = y.prime)
}

In [38]:
#function for computation of second derivative
Deriv2 <- function(x,y)
{
  h <- x[2] - x[1]
  Range <- 2:(length(x)-1)  # Drop first and last points
  list(shift = x[Range],
       intensity = (y[Range+1] - 2*y[Range] + y[Range-1]) / h^2)
}

In [39]:
plot.with.error.bars <- function(x, matrix, col = "black",
                                 ylim = range(c(apply(matrix, 2, mean) - apply(matrix, 2, sd),
                                                apply(matrix, 2, mean) + apply(matrix, 2, sd))), ...){
  avg <- apply(matrix,2,mean)
  sdev <- apply(matrix,2,sd)
  plot(x, avg, col = col, ylim = ylim, ...)
  arrows(x, avg - sdev, x, avg + sdev, length=0.05, angle=90, code=3, col = col)
}

In [114]:
osc.lims <- function(predictors, responses, nComp, accuracy = 1e-5, maxit = 100){
   
  X<-as.matrix(predictors)
  Y<-as.matrix(responses)
  ###Create output arrays
  xscores <- c()
  yscores <- c()
  xweights <- c()
  xloadings <- c()
  yweights <- c()
  B <- c()
  coefficients <- array(0, c(dim(X)[2], dim(Y)[2], nComp));
  
  ###Variables for loop control
  iterations <- c();
  deltas <- c();
  
  #if (dim(Y)[2] == 1){
  #  maxit <- 1;
  #}
  
  ###loop on components (aka latent variables)
  for (j in 1:nComp) {
    u <- matrix(Y[,1],ncol=1) #/ sqrt(sum(Y * Y)); #initial guess for Y score #/ sqrt(sum(Y * Y)) is apparently not necessary, double check
    
    delta = 1000000;
    lastt = NULL;
    iteration = 0;
    
    while (delta > accuracy && iteration < maxit){
      iteration = iteration + 1
      t=prcomp(X,scale=FALSE,center=FALSE)$x
      tnew = 1 -  (Y%*%solve(t(Y)%*%(Y))%*%t(Y))%*%t  
      w = ginv(X) %*% tnew # / c(crossprod(u)); # X weight is X transposed projected on y score# denominator is unnecessary since we normalize next
      t = (X %*% w) #/ c(crossprod(w));
      
      p = t(t(t)%*%X) %*% (ginv(t%*%tnew))
      
      if (!is.null(lastt)){
        delta = sqrt(c(crossprod(t - lastt)));
      }
      lastt = t;
    }
    
    iterations = c(iterations, iteration);
    deltas = c(deltas, delta);
    
    ##Save current component results        
    xweights = cbind(xweights, w);
    xscores = cbind(xscores, t);
    xloadings = cbind(xloadings, p);
    #B = c(B,b);
    #coefficients[,,j] = ginv(t(xloadings)) %*% (B * t(yweights));
    
    ##Deflate
    E = X- t%*%t(p)
  }

  ###return results
  result <- list("xweights" = xweights,"xscores" = xscores,
                 "xloadings" = xloadings, "X"=E,"iterations" = iterations, "deltas" = deltas);
  
  ### results is of a class for multivariate regression models (testing)
  class(result) = "model";
  result;
}

In [115]:
osc <- osc.lims(as.matrix(allIRs$ir), as.matrix(as.numeric(allIRs$metadata$species)), nComp=2, accuracy = 1e-5, maxit = 100)

In [126]:
Y <- as.matrix(as.numeric(allIRs$metadata$species))

In [135]:
solve(t(Y)%*%(Y))


0.002898551

In [131]:
(Y%*%solve(t(Y)%*%(Y))%*%t(Y))


0.0260869570.0260869570.0260869570.0260869570.0260869570.0086956520.0086956520.0086956520.0173913040.0086956520.0173913040.0173913040.0173913040.0173913040.0173913040.0173913040.0173913040.0173913040.0086956520.008695652
0.0260869570.0260869570.0260869570.0260869570.0260869570.0086956520.0086956520.0086956520.0173913040.0086956520.0173913040.0173913040.0173913040.0173913040.0173913040.0173913040.0173913040.0173913040.0086956520.008695652
0.0260869570.0260869570.0260869570.0260869570.0260869570.0086956520.0086956520.0086956520.0173913040.0086956520.0173913040.0173913040.0173913040.0173913040.0173913040.0173913040.0173913040.0173913040.0086956520.008695652
0.0260869570.0260869570.0260869570.0260869570.0260869570.0086956520.0086956520.0086956520.0173913040.0086956520.0173913040.0173913040.0173913040.0173913040.0173913040.0173913040.0173913040.0173913040.0086956520.008695652
0.0260869570.0260869570.0260869570.0260869570.0260869570.0086956520.0086956520.0086956520.0173913040.0086956520.0173913040.0173913040.0173913040.0173913040.0173913040.0173913040.0173913040.0173913040.0086956520.008695652
0.0086956520.0086956520.0086956520.0086956520.0086956520.0028985510.0028985510.0028985510.0057971010.0028985510.0057971010.0057971010.0057971010.0057971010.0057971010.0057971010.0057971010.0057971010.0028985510.002898551
0.0086956520.0086956520.0086956520.0086956520.0086956520.0028985510.0028985510.0028985510.0057971010.0028985510.0057971010.0057971010.0057971010.0057971010.0057971010.0057971010.0057971010.0057971010.0028985510.002898551
0.0086956520.0086956520.0086956520.0086956520.0086956520.0028985510.0028985510.0028985510.0057971010.0028985510.0057971010.0057971010.0057971010.0057971010.0057971010.0057971010.0057971010.0057971010.0028985510.002898551
0.0173913040.0173913040.0173913040.0173913040.0173913040.0057971010.0057971010.0057971010.0115942030.0057971010.0115942030.0115942030.0115942030.0115942030.0115942030.0115942030.0115942030.0115942030.0057971010.005797101
0.0086956520.0086956520.0086956520.0086956520.0086956520.0028985510.0028985510.0028985510.0057971010.0028985510.0057971010.0057971010.0057971010.0057971010.0057971010.0057971010.0057971010.0057971010.0028985510.002898551
0.0173913040.0173913040.0173913040.0173913040.0173913040.0057971010.0057971010.0057971010.0115942030.0057971010.0115942030.0115942030.0115942030.0115942030.0115942030.0115942030.0115942030.0115942030.0057971010.005797101
0.0086956520.0086956520.0086956520.0086956520.0086956520.0028985510.0028985510.0028985510.0057971010.0028985510.0057971010.0057971010.0057971010.0057971010.0057971010.0057971010.0057971010.0057971010.0028985510.002898551
0.0086956520.0086956520.0086956520.0086956520.0086956520.0028985510.0028985510.0028985510.0057971010.0028985510.0057971010.0057971010.0057971010.0057971010.0057971010.0057971010.0057971010.0057971010.0028985510.002898551
0.0086956520.0086956520.0086956520.0086956520.0086956520.0028985510.0028985510.0028985510.0057971010.0028985510.0057971010.0057971010.0057971010.0057971010.0057971010.0057971010.0057971010.0057971010.0028985510.002898551
0.0086956520.0086956520.0086956520.0086956520.0086956520.0028985510.0028985510.0028985510.0057971010.0028985510.0057971010.0057971010.0057971010.0057971010.0057971010.0057971010.0057971010.0057971010.0028985510.002898551
0.0173913040.0173913040.0173913040.0173913040.0173913040.0057971010.0057971010.0057971010.0115942030.0057971010.0115942030.0115942030.0115942030.0115942030.0115942030.0115942030.0115942030.0115942030.0057971010.005797101
0.0086956520.0086956520.0086956520.0086956520.0086956520.0028985510.0028985510.0028985510.0057971010.0028985510.0057971010.0057971010.0057971010.0057971010.0057971010.0057971010.0057971010.0057971010.0028985510.002898551
0.0086956520.0086956520.0086956520.0086956520.0086956520.0028985510.0028985510.0028985510.0057971010.0028985510.0057971010.0057971010.0057971010.0057971010.0057971010.0057971010.0057971010.0057971010.0028985510.002898551
0.0260869570.0260869570.0260869570.0260869570.0260869570.0086956520.0086956520.0086956520.0173913040.0086956520.0173913040.0173913040.0173913040.0173913040.0173913040.0173913040.0173913040.0173913040.0086956520.008695652
0.0086956520.0086956520.0086956520.0086956520.0086956520.0028985510.0028985510.0028985510.0057971010.0028985510.0057971010.0057971010.0057971010.0057971010.0057971010.0057971010.0057971010.0057971010.0028985510.002898551
0.0086956520.0086956520.0086956520.0086956520.0086956520.0028985510.0028985510.0028985510.0057971010.0028985510.0057971010.0057971010.0057971010.0057971010.0057971010.0057971010.0057971010.0057971010.0028985510.002898551
0.0086956520.0086956520.0086956520.0086956520.0086956520.0028985510.0028985510.0028985510.0057971010.0028985510.0057971010.0057971010.0057971010.0057971010.0057971010.0057971010.0057971010.0057971010.0028985510.002898551
0.0086956520.0086956520.0086956520.0086956520.0086956520.0028985510.0028985510.0028985510.0057971010.0028985510.0057971010.0057971010.0057971010.0057971010.0057971010.0057971010.0057971010.0057971010.0028985510.002898551
0.0086956520.0086956520.0086956520.0086956520.0086956520.0028985510.0028985510.0028985510.0057971010.0028985510.0057971010.0057971010.0057971010.0057971010.0057971010.0057971010.0057971010.0057971010.0028985510.002898551
0.0260869570.0260869570.0260869570.0260869570.0260869570.0086956520.0086956520.0086956520.0173913040.0086956520.0173913040.0173913040.0173913040.0173913040.0173913040.0173913040.0173913040.0173913040.0086956520.008695652
0.0260869570.0260869570.0260869570.0260869570.0260869570.0086956520.0086956520.0086956520.0173913040.0086956520.0173913040.0173913040.0173913040.0173913040.0173913040.0173913040.0173913040.0173913040.0086956520.008695652
0.0260869570.0260869570.0260869570.0260869570.0260869570.0086956520.0086956520.0086956520.0173913040.0086956520.0173913040.0173913040.0173913040.0173913040.0173913040.0173913040.0173913040.0173913040.0086956520.008695652
0.0260869570.0260869570.0260869570.0260869570.0260869570.0086956520.0086956520.0086956520.0173913040.0086956520.0173913040.0173913040.0173913040.0173913040.0173913040.0173913040.0173913040.0173913040.0086956520.008695652
0.0260869570.0260869570.0260869570.0260869570.0260869570.0086956520.0086956520.0086956520.0173913040.0086956520.0173913040.0173913040.0173913040.0173913040.0173913040.0173913040.0173913040.0173913040.0086956520.008695652
0.0260869570.0260869570.0260869570.0260869570.0260869570.0086956520.0086956520.0086956520.0173913040.0086956520.0173913040.0173913040.0173913040.0173913040.0173913040.0173913040.0173913040.0173913040.0086956520.008695652
0.0173913040.0173913040.0173913040.0173913040.0173913040.0057971010.0057971010.0057971010.0115942030.0057971010.0115942030.0115942030.0115942030.0115942030.0115942030.0115942030.0115942030.0115942030.0057971010.005797101
0.0173913040.0173913040.0173913040.0173913040.0173913040.0057971010.0057971010.0057971010.0115942030.0057971010.0115942030.0115942030.0115942030.0115942030.0115942030.0115942030.0115942030.0115942030.0057971010.005797101
0.0173913040.0173913040.0173913040.0173913040.0173913040.0057971010.0057971010.0057971010.0115942030.0057971010.0115942030.0115942030.0115942030.0115942030.0115942030.0115942030.0115942030.0115942030.0057971010.005797101
0.0086956520.0086956520.0086956520.0086956520.0086956520.0028985510.0028985510.0028985510.0057971010.0028985510.0057971010.0057971010.0057971010.0057971010.0057971010.0057971010.0057971010.0057971010.0028985510.002898551
0.0086956520.0086956520.0086956520.0086956520.0086956520.0028985510.0028985510.0028985510.0057971010.0028985510.0057971010.0057971010.0057971010.0057971010.0057971010.0057971010.0057971010.0057971010.0028985510.002898551
0.0086956520.0086956520.0086956520.0086956520.0086956520.0028985510.0028985510.0028985510.0057971010.0028985510.0057971010.0057971010.0057971010.0057971010.0057971010.0057971010.0057971010.0057971010.0028985510.002898551
0.0086956520.0086956520.0086956520.0086956520.0086956520.0028985510.0028985510.0028985510.0057971010.0028985510.0057971010.0057971010.0057971010.0057971010.0057971010.0057971010.0057971010.0057971010.0028985510.002898551
0.0086956520.0086956520.0086956520.0086956520.0086956520.0028985510.0028985510.0028985510.0057971010.0028985510.0057971010.0057971010.0057971010.0057971010.0057971010.0057971010.0057971010.0057971010.0028985510.002898551
0.0173913040.0173913040.0173913040.0173913040.0173913040.0057971010.0057971010.0057971010.0115942030.0057971010.0115942030.0115942030.0115942030.0115942030.0115942030.0115942030.0115942030.0115942030.0057971010.005797101
0.0173913040.0173913040.0173913040.0173913040.0173913040.0057971010.0057971010.0057971010.0115942030.0057971010.0115942030.0115942030.0115942030.0115942030.0115942030.0115942030.0115942030.0115942030.0057971010.005797101
0.0173913040.0173913040.0173913040.0173913040.0173913040.0057971010.0057971010.0057971010.0115942030.0057971010.0115942030.0115942030.0115942030.0115942030.0115942030.0115942030.0115942030.0115942030.0057971010.005797101
0.0173913040.0173913040.0173913040.0173913040.0173913040.0057971010.0057971010.0057971010.0115942030.0057971010.0115942030.0115942030.0115942030.0115942030.0115942030.0115942030.0115942030.0115942030.0057971010.005797101
0.0173913040.0173913040.0173913040.0173913040.0173913040.0057971010.0057971010.0057971010.0115942030.0057971010.0115942030.0115942030.0115942030.0115942030.0115942030.0115942030.0115942030.0115942030.0057971010.005797101
0.0173913040.0173913040.0173913040.0173913040.0173913040.0057971010.0057971010.0057971010.0115942030.0057971010.0115942030.0115942030.0115942030.0115942030.0115942030.0115942030.0115942030.0115942030.0057971010.005797101
0.0260869570.0260869570.0260869570.0260869570.0260869570.0086956520.0086956520.0086956520.0173913040.0086956520.0173913040.0173913040.0173913040.0173913040.0173913040.0173913040.0173913040.0173913040.0086956520.008695652
0.0173913040.0173913040.0173913040.0173913040.0173913040.0057971010.0057971010.0057971010.0115942030.0057971010.0115942030.0115942030.0115942030.0115942030.0115942030.0115942030.0115942030.0115942030.0057971010.005797101
0.0173913040.0173913040.0173913040.0173913040.0173913040.0057971010.0057971010.0057971010.0115942030.0057971010.0115942030.0115942030.0115942030.0115942030.0115942030.0115942030.0115942030.0115942030.0057971010.005797101
0.0173913040.0173913040.0173913040.0173913040.0173913040.0057971010.0057971010.0057971010.0115942030.0057971010.0115942030.0115942030.0115942030.0115942030.0115942030.0115942030.0115942030.0115942030.0057971010.005797101
0.0173913040.0173913040.0173913040.0173913040.0173913040.0057971010.0057971010.0057971010.0115942030.0057971010.0115942030.0115942030.0115942030.0115942030.0115942030.0115942030.0115942030.0115942030.0057971010.005797101
0.0173913040.0173913040.0173913040.0173913040.0173913040.0057971010.0057971010.0057971010.0115942030.0057971010.0115942030.0115942030.0115942030.0115942030.0115942030.0115942030.0115942030.0115942030.0057971010.005797101
0.0173913040.0173913040.0173913040.0173913040.0173913040.0057971010.0057971010.0057971010.0115942030.0057971010.0115942030.0115942030.0115942030.0115942030.0115942030.0115942030.0115942030.0115942030.0057971010.005797101
0.0173913040.0173913040.0173913040.0173913040.0173913040.0057971010.0057971010.0057971010.0115942030.0057971010.0115942030.0115942030.0115942030.0115942030.0115942030.0115942030.0115942030.0115942030.0057971010.005797101
0.0173913040.0173913040.0173913040.0173913040.0173913040.0057971010.0057971010.0057971010.0115942030.0057971010.0115942030.0115942030.0115942030.0115942030.0115942030.0115942030.0115942030.0115942030.0057971010.005797101
0.0173913040.0173913040.0173913040.0173913040.0173913040.0057971010.0057971010.0057971010.0115942030.0057971010.0115942030.0115942030.0115942030.0115942030.0115942030.0115942030.0115942030.0115942030.0057971010.005797101
0.0173913040.0173913040.0173913040.0173913040.0173913040.0057971010.0057971010.0057971010.0115942030.0057971010.0115942030.0115942030.0115942030.0115942030.0115942030.0115942030.0115942030.0115942030.0057971010.005797101
0.0173913040.0173913040.0173913040.0173913040.0173913040.0057971010.0057971010.0057971010.0115942030.0057971010.0115942030.0115942030.0115942030.0115942030.0115942030.0115942030.0115942030.0115942030.0057971010.005797101
0.0173913040.0173913040.0173913040.0173913040.0173913040.0057971010.0057971010.0057971010.0115942030.0057971010.0115942030.0115942030.0115942030.0115942030.0115942030.0115942030.0115942030.0115942030.0057971010.005797101
0.0173913040.0173913040.0173913040.0173913040.0173913040.0057971010.0057971010.0057971010.0115942030.0057971010.0115942030.0115942030.0115942030.0115942030.0115942030.0115942030.0115942030.0115942030.0057971010.005797101
0.0086956520.0086956520.0086956520.0086956520.0086956520.0028985510.0028985510.0028985510.0057971010.0028985510.0057971010.0057971010.0057971010.0057971010.0057971010.0057971010.0057971010.0057971010.0028985510.002898551
0.0086956520.0086956520.0086956520.0086956520.0086956520.0028985510.0028985510.0028985510.0057971010.0028985510.0057971010.0057971010.0057971010.0057971010.0057971010.0057971010.0057971010.0057971010.0028985510.002898551

In [ ]:


In [ ]:


In [116]:
summary(osc)


           Length Class  Mode   
xweights   176290 -none- numeric
xscores     14450 -none- numeric
xloadings  176290 -none- numeric
X           88145 AsIs   numeric
iterations      2 -none- numeric
deltas      14450 -none- numeric

In [117]:
dim(osc$xscores)


  1. 85
  2. 170

In [118]:
plot(osc$xscores[,1], osc$xscores[,2], col=groupColors)



In [119]:
dim(osc$xloadings)


  1. 1037
  2. 170

In [120]:
matplot(osc$xloadings, type='l', col=groupColors)



In [121]:
matplot(t(osc$X), type='l', col=groupColors)



In [77]:



  1. R
  2. R
  3. R
  4. R
  5. R
  6. AC
  7. AC
  8. AC
  9. A
  10. AC
  11. A
  12. AC
  13. AC
  14. AC
  15. AC
  16. A
  17. AC
  18. AC
  19. R
  20. AC
  21. AC
  22. AC
  23. AC
  24. AC
  25. R
  26. R
  27. R
  28. R
  29. R
  30. R
  31. A
  32. R
  33. R
  34. R
  35. A
  36. A
  37. A
  38. AC
  39. AC
  40. AC
  41. AC
  42. AC
  43. AC
  44. AC
  45. AC
  46. A
  47. A
  48. A
  49. A
  50. R
  51. R
  52. A
  53. A
  54. R
  55. A
  56. A
  57. A
  58. A
  59. AC
  60. AC
  61. AC
  62. AC
  63. AC
  64. A
  65. A
  66. A
  67. A
  68. A
  69. A
  70. R
  71. A
  72. A
  73. A
  74. A
  75. A
  76. A
  77. A
  78. A
  79. A
  80. A
  81. A
  82. A
  83. A
  84. AC
  85. AC

In [ ]:


In [ ]: