pacman::p_load(pacman,dplyr,GGally,ggplot2,ggthemes,ggvis,httr,lubridate,plotly,rio,rmarkdown,shiny,stringr,tidyr,tidyverse,lattice,caret,pls,MASS,yarrr,psych,ggcorrplot,GGally,CCA,CCP,rpart,rpart.plot)
library(tidyverse)
library(rpart)
library(rpart.plot)
library(caret)
library("rio")

Generación de los datos

A partir de las 16 análisis de las muestras en la columna polar, se generaron 8 “réplicas” de cada análisis añadiendo un ruido blanco calculado con la función rnorm(n,mean=0,sd=1)0.01valores de tal manera que se generen pequeñas variaciones a los mismos.

Al final tenemos un juego de 144 filas=8*16+16

Estos datos se guardaron en el excel=CCADatosTest.xlsx

mm1<-import("CCADatosTest.xlsx")
atributo<-mm1["Aroma"]
mm<-mm1[,1:87]
mm["Aroma"]<-round(atributo,1)

## Se clasifican cada muestra de acuerdo al valor de la columna Aroma como: Bajo,Medi,Alto,Excelente

d<-(max(mm$Aroma)-min(mm$Aroma))/4
d1<-min(mm$Aroma)+d
d2<-min(mm$Aroma)+d*2
d3<-min(mm$Aroma)+d*3
breakpoints=seq(min(mm$Aroma),max(mm$Aroma),d)
breakpoints<-c(-Inf, d1, d2,d3, Inf)

classified<-cut(mm$Aroma,breaks=breakpoints,labels=c("Bajo","Medio","Alto","Excelente"))
mm$Aroma<-factor(classified)

Clasificación de las muestras usando el algoritmo de Arbol de decisión

## Se realizaran 100 corridas del algoritmo
for(i in 1:10){
print(paste0("CORRIDA ",i))

training2 <- sample_frac(mm, .7)    ## conjunto de entrenamiento 70% de las muestras escogidas al azar
test2 <- setdiff(mm, training2)     ## Conjunto de prueba, el remanente de las muestras
arbol_2 <- rpart(formula = Aroma ~ ., data = training2,control = rpart.control(cp = 0.06, xval = 35, minsplit = 5))
prediccion_2 <- predict(arbol_2, newdata = test2, type = "class")
rpart.plot(arbol_2)
# Cálculo de la matriz de confución
c<-confusionMatrix(prediccion_2, test2[["Aroma"]])
print(c)
# Nombre de las variables utilizadas en el el árbol de decisión
v<-arbol_2$frame$var[arbol_2$frame$var != "<leaf>"]

print(paste0("VARIABLES:",paste(v,collapse=",")))
new_string <- paste(v, collapse = "*")
df2<-data.frame(Aroma=test2$Aroma,pred=prediccion_2)


f<-paste0("Aroma~",new_string) %>% as.formula   #Calcula fórmula de regresión

metodo<-lm(f,data=mm1)
#summary(metodo)
plot(metodo$fitted.values,mm1$Aroma,xlim=c(7.8,9.0),ylim=c(7.8,9.0),main=paste0("VARIABLES:",paste(v,collapse=",")))
abline(0,1,col="blue")
print(summary(metodo))
print("--------------------------------------------------------------------------------------")
}
## [1] "CORRIDA 1"

## Confusion Matrix and Statistics
## 
##            Reference
## Prediction  Bajo Medio Alto Excelente
##   Bajo         1     0    0         0
##   Medio        2    11    3         0
##   Alto         1     2   16         3
##   Excelente    0     0    2         2
## 
## Overall Statistics
##                                           
##                Accuracy : 0.6977          
##                  95% CI : (0.5387, 0.8282)
##     No Information Rate : 0.4884          
##     P-Value [Acc > NIR] : 0.004445        
##                                           
##                   Kappa : 0.516           
##                                           
##  Mcnemar's Test P-Value : NA              
## 
## Statistics by Class:
## 
##                      Class: Bajo Class: Medio Class: Alto Class: Excelente
## Sensitivity              0.25000       0.8462      0.7619          0.40000
## Specificity              1.00000       0.8333      0.7273          0.94737
## Pos Pred Value           1.00000       0.6875      0.7273          0.50000
## Neg Pred Value           0.92857       0.9259      0.7619          0.92308
## Prevalence               0.09302       0.3023      0.4884          0.11628
## Detection Rate           0.02326       0.2558      0.3721          0.04651
## Detection Prevalence     0.02326       0.3721      0.5116          0.09302
## Balanced Accuracy        0.62500       0.8397      0.7446          0.67368
## [1] "VARIABLES:A7,A78,A38,A8"

## 
## Call:
## lm(formula = f, data = mm1)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.258575 -0.047685  0.001222  0.058135  0.195944 
## 
## Coefficients:
##                 Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   -1.613e+02  4.050e+01  -3.983 0.000113 ***
## A7             1.183e+03  2.940e+02   4.023 9.77e-05 ***
## A78            2.482e+01  5.928e+00   4.188 5.20e-05 ***
## A38            2.140e+01  5.699e+00   3.756 0.000261 ***
## A8             2.551e+03  6.479e+02   3.936 0.000135 ***
## A7:A78        -1.726e+02  4.316e+01  -3.998 0.000107 ***
## A7:A38        -1.461e+02  4.147e+01  -3.522 0.000594 ***
## A78:A38       -3.147e+00  8.307e-01  -3.788 0.000233 ***
## A7:A8         -1.826e+04  4.679e+03  -3.901 0.000154 ***
## A78:A8        -3.707e+02  9.251e+01  -4.007 0.000104 ***
## A38:A8        -3.190e+02  9.034e+01  -3.531 0.000577 ***
## A7:A78:A38     2.143e+01  6.062e+00   3.535 0.000569 ***
## A7:A78:A8      2.639e+03  6.704e+02   3.936 0.000135 ***
## A7:A38:A8      2.245e+03  6.509e+02   3.448 0.000764 ***
## A78:A38:A8     4.645e+01  1.287e+01   3.611 0.000437 ***
## A7:A78:A38:A8 -3.249e+02  9.302e+01  -3.492 0.000658 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.08905 on 128 degrees of freedom
## Multiple R-squared:  0.6995, Adjusted R-squared:  0.6643 
## F-statistic: 19.86 on 15 and 128 DF,  p-value: < 2.2e-16
## 
## [1] "--------------------------------------------------------------------------------------"
## [1] "CORRIDA 2"

## Confusion Matrix and Statistics
## 
##            Reference
## Prediction  Bajo Medio Alto Excelente
##   Bajo         3     1    0         0
##   Medio        2     6    1         0
##   Alto         1     5   19         2
##   Excelente    0     0    1         2
## 
## Overall Statistics
##                                           
##                Accuracy : 0.6977          
##                  95% CI : (0.5387, 0.8282)
##     No Information Rate : 0.4884          
##     P-Value [Acc > NIR] : 0.004445        
##                                           
##                   Kappa : 0.5088          
##                                           
##  Mcnemar's Test P-Value : NA              
## 
## Statistics by Class:
## 
##                      Class: Bajo Class: Medio Class: Alto Class: Excelente
## Sensitivity              0.50000       0.5000      0.9048          0.50000
## Specificity              0.97297       0.9032      0.6364          0.97436
## Pos Pred Value           0.75000       0.6667      0.7037          0.66667
## Neg Pred Value           0.92308       0.8235      0.8750          0.95000
## Prevalence               0.13953       0.2791      0.4884          0.09302
## Detection Rate           0.06977       0.1395      0.4419          0.04651
## Detection Prevalence     0.09302       0.2093      0.6279          0.06977
## Balanced Accuracy        0.73649       0.7016      0.7706          0.73718
## [1] "VARIABLES:A7,A38,A32,A60"

## 
## Call:
## lm(formula = f, data = mm1)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -0.37254 -0.04850  0.00803  0.05135  0.20848 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)
## (Intercept)     -55.124     69.387  -0.794    0.428
## A7              485.307    574.811   0.844    0.400
## A38               9.310      9.416   0.989    0.325
## A32              28.784     27.502   1.047    0.297
## A60             140.612    158.680   0.886    0.377
## A7:A38          -70.502     78.530  -0.898    0.371
## A7:A32         -217.242    231.057  -0.940    0.349
## A38:A32          -4.407      3.776  -1.167    0.245
## A7:A60         -987.373   1237.865  -0.798    0.427
## A38:A60         -22.041     21.987  -1.002    0.318
## A32:A60         -68.002     66.167  -1.028    0.306
## A7:A38:A32       33.085     31.915   1.037    0.302
## A7:A38:A60      155.708    173.155   0.899    0.370
## A7:A32:A60      474.834    516.814   0.919    0.360
## A38:A32:A60      10.862      9.243   1.175    0.242
## A7:A38:A32:A60  -76.602     72.925  -1.050    0.296
## 
## Residual standard error: 0.08778 on 128 degrees of freedom
## Multiple R-squared:  0.708,  Adjusted R-squared:  0.6738 
## F-statistic: 20.69 on 15 and 128 DF,  p-value: < 2.2e-16
## 
## [1] "--------------------------------------------------------------------------------------"
## [1] "CORRIDA 3"

## Confusion Matrix and Statistics
## 
##            Reference
## Prediction  Bajo Medio Alto Excelente
##   Bajo         4     1    0         0
##   Medio        3     9    2         1
##   Alto         0     4   12         0
##   Excelente    0     2    3         2
## 
## Overall Statistics
##                                           
##                Accuracy : 0.6279          
##                  95% CI : (0.4673, 0.7702)
##     No Information Rate : 0.3953          
##     P-Value [Acc > NIR] : 0.001726        
##                                           
##                   Kappa : 0.4629          
##                                           
##  Mcnemar's Test P-Value : NA              
## 
## Statistics by Class:
## 
##                      Class: Bajo Class: Medio Class: Alto Class: Excelente
## Sensitivity              0.57143       0.5625      0.7059          0.66667
## Specificity              0.97222       0.7778      0.8462          0.87500
## Pos Pred Value           0.80000       0.6000      0.7500          0.28571
## Neg Pred Value           0.92105       0.7500      0.8148          0.97222
## Prevalence               0.16279       0.3721      0.3953          0.06977
## Detection Rate           0.09302       0.2093      0.2791          0.04651
## Detection Prevalence     0.11628       0.3488      0.3721          0.16279
## Balanced Accuracy        0.77183       0.6701      0.7760          0.77083
## [1] "VARIABLES:A7,A38,A28,A29,A40"

## 
## Call:
## lm(formula = f, data = mm1)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.233252 -0.035559  0.000377  0.043289  0.153485 
## 
## Coefficients:
##                      Estimate Std. Error t value Pr(>|t|)
## (Intercept)        -5.785e+01  1.716e+02  -0.337    0.737
## A7                  6.509e+02  1.612e+03   0.404    0.687
## A38                 8.023e+00  2.492e+01   0.322    0.748
## A28                 4.479e+02  1.367e+03   0.328    0.744
## A29                 2.203e+03  3.243e+03   0.679    0.498
## A40                 1.311e+02  2.384e+02   0.550    0.583
## A7:A38             -8.236e+01  2.297e+02  -0.359    0.721
## A7:A28             -3.918e+03  1.291e+04  -0.304    0.762
## A38:A28            -5.861e+01  2.016e+02  -0.291    0.772
## A7:A29             -1.918e+04  2.974e+04  -0.645    0.520
## A38:A29            -2.322e+02  4.691e+02  -0.495    0.622
## A28:A29            -1.432e+04  2.369e+04  -0.604    0.547
## A7:A40             -1.148e+03  2.292e+03  -0.501    0.617
## A38:A40            -1.717e+01  3.503e+01  -0.490    0.625
## A28:A40            -9.050e+02  1.992e+03  -0.454    0.650
## A29:A40            -3.394e+03  4.846e+03  -0.700    0.485
## A7:A38:A28          5.320e+02  1.871e+03   0.284    0.777
## A7:A38:A29          2.120e+03  4.275e+03   0.496    0.621
## A7:A28:A29          1.173e+05  2.194e+05   0.535    0.594
## A38:A28:A29         1.509e+03  3.441e+03   0.438    0.662
## A7:A38:A40          1.534e+02  3.298e+02   0.465    0.643
## A7:A28:A40          7.100e+03  1.936e+04   0.367    0.715
## A38:A28:A40         1.264e+02  2.950e+02   0.429    0.669
## A7:A29:A40          2.825e+04  4.446e+04   0.635    0.526
## A38:A29:A40         3.774e+02  7.041e+02   0.536    0.593
## A28:A29:A40         2.234e+04  3.642e+04   0.613    0.541
## A7:A38:A28:A29     -1.293e+04  3.167e+04  -0.408    0.684
## A7:A38:A28:A40     -1.019e+03  2.814e+03  -0.362    0.718
## A7:A38:A29:A40     -3.239e+03  6.428e+03  -0.504    0.615
## A7:A28:A29:A40     -1.741e+05  3.390e+05  -0.514    0.608
## A38:A28:A29:A40    -2.533e+03  5.294e+03  -0.478    0.633
## A7:A38:A28:A29:A40  2.031e+04  4.901e+04   0.414    0.679
## 
## Residual standard error: 0.07613 on 112 degrees of freedom
## Multiple R-squared:  0.8078, Adjusted R-squared:  0.7546 
## F-statistic: 15.19 on 31 and 112 DF,  p-value: < 2.2e-16
## 
## [1] "--------------------------------------------------------------------------------------"
## [1] "CORRIDA 4"

## Confusion Matrix and Statistics
## 
##            Reference
## Prediction  Bajo Medio Alto Excelente
##   Bajo         4     2    0         0
##   Medio        0     5    1         0
##   Alto         0     7   18         4
##   Excelente    0     0    0         2
## 
## Overall Statistics
##                                           
##                Accuracy : 0.6744          
##                  95% CI : (0.5146, 0.8092)
##     No Information Rate : 0.4419          
##     P-Value [Acc > NIR] : 0.001777        
##                                           
##                   Kappa : 0.489           
##                                           
##  Mcnemar's Test P-Value : NA              
## 
## Statistics by Class:
## 
##                      Class: Bajo Class: Medio Class: Alto Class: Excelente
## Sensitivity              1.00000       0.3571      0.9474          0.33333
## Specificity              0.94872       0.9655      0.5417          1.00000
## Pos Pred Value           0.66667       0.8333      0.6207          1.00000
## Neg Pred Value           1.00000       0.7568      0.9286          0.90244
## Prevalence               0.09302       0.3256      0.4419          0.13953
## Detection Rate           0.09302       0.1163      0.4186          0.04651
## Detection Prevalence     0.13953       0.1395      0.6744          0.04651
## Balanced Accuracy        0.97436       0.6613      0.7445          0.66667
## [1] "VARIABLES:A7,A78,A8,A32,A60,A29"

## 
## Call:
## lm(formula = f, data = mm1)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -0.17197 -0.03347 -0.00554  0.02865  0.15251 
## 
## Coefficients:
##                         Estimate Std. Error t value Pr(>|t|)
## (Intercept)           -1.610e+03  4.124e+03  -0.390    0.697
## A7                     7.154e+03  3.673e+04   0.195    0.846
## A78                    2.584e+02  5.867e+02   0.440    0.661
## A8                     3.135e+04  6.719e+04   0.467    0.642
## A32                    4.771e+02  1.809e+03   0.264    0.793
## A60                    1.183e+03  1.047e+04   0.113    0.910
## A29                    1.737e+04  6.450e+04   0.269    0.788
## A7:A78                -1.369e+03  5.215e+03  -0.262    0.794
## A7:A8                 -1.076e+05  5.578e+05  -0.193    0.848
## A78:A8                -4.686e+03  9.601e+03  -0.488    0.627
## A7:A32                -6.431e+02  1.629e+04  -0.039    0.969
## A78:A32               -8.160e+01  2.578e+02  -0.317    0.752
## A8:A32                -1.159e+04  2.935e+04  -0.395    0.694
## A7:A60                 1.657e+04  9.369e+04   0.177    0.860
## A78:A60               -2.435e+02  1.476e+03  -0.165    0.869
## A8:A60                -7.229e+04  1.659e+05  -0.436    0.664
## A32:A60               -3.148e+01  4.694e+03  -0.007    0.995
## A7:A29                -8.837e+04  5.665e+05  -0.156    0.876
## A78:A29               -2.645e+03  9.125e+03  -0.290    0.773
## A8:A29                -6.072e+05  1.104e+06  -0.550    0.584
## A32:A29               -5.518e+03  2.810e+04  -0.196    0.845
## A60:A29               -7.519e+03  1.550e+05  -0.049    0.961
## A7:A78:A8              1.910e+04  7.964e+04   0.240    0.811
## A7:A78:A32             2.598e+02  2.317e+03   0.112    0.911
## A7:A8:A32              2.022e+04  2.457e+05   0.082    0.935
## A78:A8:A32             1.764e+03  4.195e+03   0.421    0.675
## A7:A78:A60            -1.445e+03  1.316e+04  -0.110    0.913
## A7:A8:A60              7.997e+04  1.384e+06   0.058    0.954
## A78:A8:A60             1.107e+04  2.339e+04   0.473    0.637
## A7:A32:A60            -1.243e+04  4.228e+04  -0.294    0.769
## A78:A32:A60            4.125e+01  6.636e+02   0.062    0.951
## A8:A32:A60             2.671e+04  7.426e+04   0.360    0.720
## A7:A78:A29             1.567e+04  8.014e+04   0.195    0.845
## A7:A8:A29              2.704e+06  8.938e+06   0.303    0.763
## A78:A8:A29             8.244e+04  1.577e+05   0.523    0.603
## A7:A32:A29             1.137e+04  2.482e+05   0.046    0.964
## A78:A32:A29            8.539e+02  3.985e+03   0.214    0.831
## A8:A32:A29             2.534e+05  4.842e+05   0.523    0.602
## A7:A60:A29            -2.636e+05  1.380e+06  -0.191    0.849
## A78:A60:A29            1.590e+03  2.166e+04   0.073    0.942
## A8:A60:A29             1.757e+06  2.513e+06   0.699    0.487
## A32:A60:A29           -1.377e+03  6.941e+04  -0.020    0.984
## A7:A78:A8:A32         -4.687e+03  3.510e+04  -0.134    0.894
## A7:A78:A8:A60         -2.245e+04  1.947e+05  -0.115    0.909
## A7:A78:A32:A60         1.332e+03  5.952e+03   0.224    0.823
## A7:A8:A32:A60          2.392e+04  6.226e+05   0.038    0.969
## A78:A8:A32:A60        -4.193e+03  1.048e+04  -0.400    0.690
## A7:A78:A8:A29         -3.863e+05  1.278e+06  -0.302    0.763
## A7:A78:A32:A29        -2.999e+03  3.521e+04  -0.085    0.932
## A7:A8:A32:A29         -9.228e+05  3.928e+06  -0.235    0.815
## A78:A8:A32:A29        -3.414e+04  6.919e+04  -0.493    0.623
## A7:A78:A60:A29         2.917e+04  1.929e+05   0.151    0.880
## A7:A8:A60:A29         -6.087e+06  2.061e+07  -0.295    0.769
## A78:A8:A60:A29        -2.431e+05  3.519e+05  -0.691    0.492
## A7:A32:A60:A29         1.743e+05  6.196e+05   0.281    0.779
## A78:A32:A60:A29       -3.716e+01  9.720e+03  -0.004    0.997
## A8:A32:A60:A29        -7.336e+05  1.129e+06  -0.650    0.518
## A7:A78:A8:A32:A60      1.859e+03  8.770e+04   0.021    0.983
## A7:A78:A8:A32:A29      1.313e+05  5.621e+05   0.234    0.816
## A7:A78:A8:A60:A29      8.919e+05  2.890e+06   0.309    0.758
## A7:A78:A32:A60:A29    -2.096e+04  8.680e+04  -0.242    0.810
## A7:A8:A32:A60:A29      2.052e+06  9.266e+06   0.221    0.825
## A78:A8:A32:A60:A29     1.013e+05  1.581e+05   0.641    0.523
## A7:A78:A8:A32:A60:A29 -3.041e+05  1.300e+06  -0.234    0.816
## 
## Residual standard error: 0.0737 on 80 degrees of freedom
## Multiple R-squared:  0.8714, Adjusted R-squared:  0.7701 
## F-statistic: 8.601 on 63 and 80 DF,  p-value: < 2.2e-16
## 
## [1] "--------------------------------------------------------------------------------------"
## [1] "CORRIDA 5"

## Confusion Matrix and Statistics
## 
##            Reference
## Prediction  Bajo Medio Alto Excelente
##   Bajo         0     2    1         0
##   Medio        1     4    3         0
##   Alto         1     8   18         5
##   Excelente    0     0    0         0
## 
## Overall Statistics
##                                           
##                Accuracy : 0.5116          
##                  95% CI : (0.3546, 0.6669)
##     No Information Rate : 0.5116          
##     P-Value [Acc > NIR] : 0.561           
##                                           
##                   Kappa : 0.1207          
##                                           
##  Mcnemar's Test P-Value : NA              
## 
## Statistics by Class:
## 
##                      Class: Bajo Class: Medio Class: Alto Class: Excelente
## Sensitivity              0.00000      0.28571      0.8182           0.0000
## Specificity              0.92683      0.86207      0.3333           1.0000
## Pos Pred Value           0.00000      0.50000      0.5625              NaN
## Neg Pred Value           0.95000      0.71429      0.6364           0.8837
## Prevalence               0.04651      0.32558      0.5116           0.1163
## Detection Rate           0.00000      0.09302      0.4186           0.0000
## Detection Prevalence     0.06977      0.18605      0.7442           0.0000
## Balanced Accuracy        0.46341      0.57389      0.5758           0.5000
## [1] "VARIABLES:A7,A58"

## 
## Call:
## lm(formula = f, data = mm1)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.316203 -0.075412 -0.002746  0.072063  0.297423 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  7.78090    0.09777  79.581  < 2e-16 ***
## A7           4.91816    0.76921   6.394 2.25e-09 ***
## A58         -0.20070    0.17669  -1.136    0.258    
## A7:A58       1.07825    1.26528   0.852    0.396    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.115 on 140 degrees of freedom
## Multiple R-squared:  0.4517, Adjusted R-squared:   0.44 
## F-statistic: 38.45 on 3 and 140 DF,  p-value: < 2.2e-16
## 
## [1] "--------------------------------------------------------------------------------------"
## [1] "CORRIDA 6"

## Confusion Matrix and Statistics
## 
##            Reference
## Prediction  Bajo Medio Alto Excelente
##   Bajo         2     1    0         0
##   Medio        1    10    3         0
##   Alto         0     1   19         4
##   Excelente    0     0    2         0
## 
## Overall Statistics
##                                           
##                Accuracy : 0.7209          
##                  95% CI : (0.5633, 0.8467)
##     No Information Rate : 0.5581          
##     P-Value [Acc > NIR] : 0.02131         
##                                           
##                   Kappa : 0.5257          
##                                           
##  Mcnemar's Test P-Value : NA              
## 
## Statistics by Class:
## 
##                      Class: Bajo Class: Medio Class: Alto Class: Excelente
## Sensitivity              0.66667       0.8333      0.7917          0.00000
## Specificity              0.97500       0.8710      0.7368          0.94872
## Pos Pred Value           0.66667       0.7143      0.7917          0.00000
## Neg Pred Value           0.97500       0.9310      0.7368          0.90244
## Prevalence               0.06977       0.2791      0.5581          0.09302
## Detection Rate           0.04651       0.2326      0.4419          0.00000
## Detection Prevalence     0.06977       0.3256      0.5581          0.04651
## Balanced Accuracy        0.82083       0.8522      0.7643          0.47436
## [1] "VARIABLES:A7,A38,A60,A69,A77"

## 
## Call:
## lm(formula = f, data = mm1)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.228769 -0.038779  0.005626  0.043149  0.158399 
## 
## Coefficients:
##                     Estimate Std. Error t value Pr(>|t|)
## (Intercept)           127.27     676.68   0.188    0.851
## A7                  -1313.77    5270.61  -0.249    0.804
## A38                   -19.69      94.72  -0.208    0.836
## A60                  -109.81    1112.18  -0.099    0.922
## A69                  -432.05    2891.62  -0.149    0.881
## A77                  -214.88    1058.48  -0.203    0.839
## A7:A38                206.20     737.35   0.280    0.780
## A7:A60               1761.35    8808.54   0.200    0.842
## A38:A60                18.69     156.69   0.119    0.905
## A7:A69               5968.36   22709.43   0.263    0.793
## A38:A69                79.76     400.14   0.199    0.842
## A60:A69               241.00    4721.54   0.051    0.959
## A7:A77               2400.90    8172.78   0.294    0.769
## A38:A77                34.01     149.17   0.228    0.820
## A60:A77               149.49    1787.91   0.084    0.934
## A69:A77               792.75    4513.87   0.176    0.861
## A7:A38:A60           -271.73    1240.65  -0.219    0.827
## A7:A38:A69           -979.12    3140.07  -0.312    0.756
## A7:A60:A69          -7710.50   37794.81  -0.204    0.839
## A38:A60:A69           -59.74     659.06  -0.091    0.928
## A7:A38:A77           -363.76    1151.82  -0.316    0.753
## A7:A60:A77          -2879.73   13990.52  -0.206    0.837
## A38:A60:A77           -24.23     253.99  -0.095    0.924
## A7:A69:A77         -10654.43   35258.83  -0.302    0.763
## A38:A69:A77          -140.12     628.92  -0.223    0.824
## A60:A69:A77          -306.18    7579.99  -0.040    0.968
## A7:A38:A60:A69       1283.34    5271.83   0.243    0.808
## A7:A38:A60:A77        427.30    1988.32   0.215    0.830
## A7:A38:A69:A77       1708.07    4909.54   0.348    0.729
## A7:A60:A69:A77      12555.45   60180.53   0.209    0.835
## A38:A60:A69:A77        80.38    1066.51   0.075    0.940
## A7:A38:A60:A69:A77  -2054.79    8463.65  -0.243    0.809
## 
## Residual standard error: 0.07616 on 112 degrees of freedom
## Multiple R-squared:  0.8077, Adjusted R-squared:  0.7544 
## F-statistic: 15.17 on 31 and 112 DF,  p-value: < 2.2e-16
## 
## [1] "--------------------------------------------------------------------------------------"
## [1] "CORRIDA 7"

## Confusion Matrix and Statistics
## 
##            Reference
## Prediction  Bajo Medio Alto Excelente
##   Bajo         4     1    0         0
##   Medio        1     9    3         0
##   Alto         1     3   17         1
##   Excelente    0     0    1         2
## 
## Overall Statistics
##                                           
##                Accuracy : 0.7442          
##                  95% CI : (0.5883, 0.8648)
##     No Information Rate : 0.4884          
##     P-Value [Acc > NIR] : 0.0005691       
##                                           
##                   Kappa : 0.5988          
##                                           
##  Mcnemar's Test P-Value : NA              
## 
## Statistics by Class:
## 
##                      Class: Bajo Class: Medio Class: Alto Class: Excelente
## Sensitivity              0.66667       0.6923      0.8095          0.66667
## Specificity              0.97297       0.8667      0.7727          0.97500
## Pos Pred Value           0.80000       0.6923      0.7727          0.66667
## Neg Pred Value           0.94737       0.8667      0.8095          0.97500
## Prevalence               0.13953       0.3023      0.4884          0.06977
## Detection Rate           0.09302       0.2093      0.3953          0.04651
## Detection Prevalence     0.11628       0.3023      0.5116          0.06977
## Balanced Accuracy        0.81982       0.7795      0.7911          0.82083
## [1] "VARIABLES:A7,A38,A60,A63"

## 
## Call:
## lm(formula = f, data = mm1)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -0.29292 -0.03804  0.00788  0.04612  0.22087 
## 
## Coefficients:
##                 Estimate Std. Error t value Pr(>|t|)  
## (Intercept)       49.461     19.073   2.593   0.0106 *
## A7              -346.549    151.135  -2.293   0.0235 *
## A38               -5.552      2.701  -2.056   0.0418 *
## A60             -102.765     44.787  -2.295   0.0234 *
## A63             -138.563     58.288  -2.377   0.0189 *
## A7:A38            46.753     21.285   2.196   0.0299 *
## A7:A60           835.983    346.589   2.412   0.0173 *
## A38:A60           14.217      6.398   2.222   0.0280 *
## A7:A63          1195.575    463.614   2.579   0.0110 *
## A38:A63           17.977      8.171   2.200   0.0296 *
## A60:A63          311.977    134.489   2.320   0.0219 *
## A7:A38:A60      -116.223     49.556  -2.345   0.0206 *
## A7:A38:A63      -155.008     64.723  -2.395   0.0181 *
## A7:A60:A63     -2615.981   1050.512  -2.490   0.0140 *
## A38:A60:A63      -42.137     19.100  -2.206   0.0292 *
## A7:A38:A60:A63   354.526    149.282   2.375   0.0190 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.07929 on 128 degrees of freedom
## Multiple R-squared:  0.7618, Adjusted R-squared:  0.7338 
## F-statistic: 27.28 on 15 and 128 DF,  p-value: < 2.2e-16
## 
## [1] "--------------------------------------------------------------------------------------"
## [1] "CORRIDA 8"

## Confusion Matrix and Statistics
## 
##            Reference
## Prediction  Bajo Medio Alto Excelente
##   Bajo         3     0    0         0
##   Medio        1    10    2         0
##   Alto         1     4   17         1
##   Excelente    0     0    3         1
## 
## Overall Statistics
##                                           
##                Accuracy : 0.7209          
##                  95% CI : (0.5633, 0.8467)
##     No Information Rate : 0.5116          
##     P-Value [Acc > NIR] : 0.004255        
##                                           
##                   Kappa : 0.5466          
##                                           
##  Mcnemar's Test P-Value : NA              
## 
## Statistics by Class:
## 
##                      Class: Bajo Class: Medio Class: Alto Class: Excelente
## Sensitivity              0.60000       0.7143      0.7727          0.50000
## Specificity              1.00000       0.8966      0.7143          0.92683
## Pos Pred Value           1.00000       0.7692      0.7391          0.25000
## Neg Pred Value           0.95000       0.8667      0.7500          0.97436
## Prevalence               0.11628       0.3256      0.5116          0.04651
## Detection Rate           0.06977       0.2326      0.3953          0.02326
## Detection Prevalence     0.06977       0.3023      0.5349          0.09302
## Balanced Accuracy        0.80000       0.8054      0.7435          0.71341
## [1] "VARIABLES:A7,A78,A32,A24"

## 
## Call:
## lm(formula = f, data = mm1)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.301248 -0.055140 -0.002056  0.055171  0.232031 
## 
## Coefficients:
##                 Estimate Std. Error t value Pr(>|t|)
## (Intercept)      213.501    177.754   1.201    0.232
## A7             -1942.277   1584.812  -1.226    0.223
## A78              -31.004     24.980  -1.241    0.217
## A32              -68.987     70.082  -0.984    0.327
## A24              -73.892     57.972  -1.275    0.205
## A7:A78           296.296    225.301   1.315    0.191
## A7:A32           703.826    653.222   1.077    0.283
## A78:A32           10.726      9.976   1.075    0.284
## A7:A24           685.396    528.973   1.296    0.197
## A78:A24           11.144      8.186   1.361    0.176
## A32:A24           26.074     22.974   1.135    0.259
## A7:A78:A32      -109.684     93.851  -1.169    0.245
## A7:A78:A24      -104.304     75.343  -1.384    0.169
## A7:A32:A24      -255.907    219.310  -1.167    0.245
## A78:A32:A24       -4.030      3.284  -1.227    0.222
## A7:A78:A32:A24    39.702     31.536   1.259    0.210
## 
## Residual standard error: 0.09533 on 128 degrees of freedom
## Multiple R-squared:  0.6557, Adjusted R-squared:  0.6153 
## F-statistic: 16.25 on 15 and 128 DF,  p-value: < 2.2e-16
## 
## [1] "--------------------------------------------------------------------------------------"
## [1] "CORRIDA 9"

## Confusion Matrix and Statistics
## 
##            Reference
## Prediction  Bajo Medio Alto Excelente
##   Bajo         5     0    0         0
##   Medio        1     6    0         0
##   Alto         0     6   18         3
##   Excelente    0     0    1         3
## 
## Overall Statistics
##                                           
##                Accuracy : 0.7442          
##                  95% CI : (0.5883, 0.8648)
##     No Information Rate : 0.4419          
##     P-Value [Acc > NIR] : 5.628e-05       
##                                           
##                   Kappa : 0.6052          
##                                           
##  Mcnemar's Test P-Value : NA              
## 
## Statistics by Class:
## 
##                      Class: Bajo Class: Medio Class: Alto Class: Excelente
## Sensitivity               0.8333       0.5000      0.9474          0.50000
## Specificity               1.0000       0.9677      0.6250          0.97297
## Pos Pred Value            1.0000       0.8571      0.6667          0.75000
## Neg Pred Value            0.9737       0.8333      0.9375          0.92308
## Prevalence                0.1395       0.2791      0.4419          0.13953
## Detection Rate            0.1163       0.1395      0.4186          0.06977
## Detection Prevalence      0.1163       0.1628      0.6279          0.09302
## Balanced Accuracy         0.9167       0.7339      0.7862          0.73649
## [1] "VARIABLES:A7,A78,A8,A38,A60"

## 
## Call:
## lm(formula = f, data = mm1)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.248568 -0.035466  0.003573  0.040377  0.176826 
## 
## Coefficients:
##                     Estimate Std. Error t value Pr(>|t|)
## (Intercept)         -246.554    506.351  -0.487    0.627
## A7                  1693.360   3837.519   0.441    0.660
## A78                   30.667     71.403   0.429    0.668
## A8                  8801.925   9541.259   0.923    0.358
## A38                   32.180     74.053   0.435    0.665
## A60                  402.467    980.807   0.410    0.682
## A7:A78              -200.911    549.331  -0.366    0.715
## A7:A8             -69943.997  73319.533  -0.954    0.342
## A78:A8             -1115.148   1336.494  -0.834    0.406
## A7:A38              -194.493    559.303  -0.348    0.729
## A78:A38               -3.802     10.415  -0.365    0.716
## A8:A38             -1216.647   1362.524  -0.893    0.374
## A7:A60             -2587.904   7454.287  -0.347    0.729
## A78:A60              -46.610    138.082  -0.338    0.736
## A8:A60            -14414.532  17260.617  -0.835    0.405
## A38:A60              -49.710    140.395  -0.354    0.724
## A7:A78:A8           8959.368  10370.506   0.864    0.389
## A7:A78:A38            22.130     79.720   0.278    0.782
## A7:A8:A38           9361.962  10420.694   0.898    0.371
## A78:A8:A38           153.561    190.514   0.806    0.422
## A7:A78:A60           291.667   1066.343   0.274    0.785
## A7:A8:A60         112756.847 132523.064   0.851    0.397
## A78:A8:A60          1794.820   2413.752   0.744    0.459
## A7:A38:A60           286.904   1062.844   0.270    0.788
## A78:A38:A60            5.604     19.730   0.284    0.777
## A8:A38:A60          1979.567   2433.632   0.813    0.418
## A7:A78:A8:A38      -1190.689   1470.111  -0.810    0.420
## A7:A78:A8:A60     -14218.088  18744.998  -0.759    0.450
## A7:A78:A38:A60       -30.289    151.615  -0.200    0.842
## A7:A8:A38:A60     -15007.269  18597.631  -0.807    0.421
## A78:A8:A38:A60      -245.396    339.913  -0.722    0.472
## A7:A78:A8:A38:A60   1877.460   2625.824   0.715    0.476
## 
## Residual standard error: 0.07622 on 112 degrees of freedom
## Multiple R-squared:  0.8074, Adjusted R-squared:  0.7541 
## F-statistic: 15.14 on 31 and 112 DF,  p-value: < 2.2e-16
## 
## [1] "--------------------------------------------------------------------------------------"
## [1] "CORRIDA 10"

## Confusion Matrix and Statistics
## 
##            Reference
## Prediction  Bajo Medio Alto Excelente
##   Bajo         3     0    0         0
##   Medio        1     5    5         0
##   Alto         1     3   23         2
##   Excelente    0     0    0         0
## 
## Overall Statistics
##                                           
##                Accuracy : 0.7209          
##                  95% CI : (0.5633, 0.8467)
##     No Information Rate : 0.6512          
##     P-Value [Acc > NIR] : 0.2138          
##                                           
##                   Kappa : 0.4475          
##                                           
##  Mcnemar's Test P-Value : NA              
## 
## Statistics by Class:
## 
##                      Class: Bajo Class: Medio Class: Alto Class: Excelente
## Sensitivity              0.60000       0.6250      0.8214          0.00000
## Specificity              1.00000       0.8286      0.6000          1.00000
## Pos Pred Value           1.00000       0.4545      0.7931              NaN
## Neg Pred Value           0.95000       0.9062      0.6429          0.95349
## Prevalence               0.11628       0.1860      0.6512          0.04651
## Detection Rate           0.06977       0.1163      0.5349          0.00000
## Detection Prevalence     0.06977       0.2558      0.6744          0.00000
## Balanced Accuracy        0.80000       0.7268      0.7107          0.50000
## [1] "VARIABLES:A7,A38,A46,A32"

## 
## Call:
## lm(formula = f, data = mm1)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.231151 -0.040608  0.004273  0.048691  0.166996 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)
## (Intercept)      59.975     97.860   0.613    0.541
## A7             -523.771    714.873  -0.733    0.465
## A38              -7.220     14.246  -0.507    0.613
## A46             -34.130     43.807  -0.779    0.437
## A32             -38.430     41.749  -0.921    0.359
## A7:A38           70.486    104.125   0.677    0.500
## A7:A46          349.810    321.398   1.088    0.278
## A38:A46           4.476      6.347   0.705    0.482
## A7:A32          351.638    305.283   1.152    0.252
## A38:A32           5.261      6.087   0.864    0.389
## A46:A32          21.899     18.752   1.168    0.245
## A7:A38:A46      -45.019     46.527  -0.968    0.335
## A7:A38:A32      -47.284     44.539  -1.062    0.290
## A7:A46:A32     -208.486    137.983  -1.511    0.133
## A38:A46:A32      -2.892      2.719  -1.064    0.290
## A7:A38:A46:A32   27.208     19.984   1.362    0.176
## 
## Residual standard error: 0.07658 on 128 degrees of freedom
## Multiple R-squared:  0.7777, Adjusted R-squared:  0.7517 
## F-statistic: 29.86 on 15 and 128 DF,  p-value: < 2.2e-16
## 
## [1] "--------------------------------------------------------------------------------------"
## Se toman en cuenta solo las interacciones doble y triples

metodo<-lm(Aroma~(A7 + A78 + A8 + A28 + A2 + A76 + A5 + A30) + 
             (A7:A78 + A7:A8 + A7:A28 + A7:A2 + A7:A76 + A7:A5 + A7:A30 +
              A78:A8 + A78:A28 + A78:A2 + A78:A76 + A78:A5 + A78:A30 +
              A8:A28 + A8:A2 + A8:A76 + A8:A5 + A8:A30 +
              A28:A2 + A28:A76 + A28:A5 + A28:A30 +
              A2:A76 + A2:A5 + A2:A30 +
              A76:A5 + A76:A30 +
              A5:A30) +
             (A7:A78:A8 + A7:A78:A28 + A7:A78:A2 + A7:A78:A76 + A7:A78:A5 + A7:A78:A30 +
              A7:A8:A28 + A7:A8:A2 + A7:A8:A76 + A7:A8:A5 + A7:A8:A30 +
              A7:A28:A2 + A7:A28:A76 + A7:A28:A5 + A7:A28:A30 +
              A7:A2:A76 + A7:A2:A5 + A7:A2:A30 +
              A7:A76:A5 + A7:A76:A30 +
              A7:A5:A30 +
              A78:A8:A28 + A78:A8:A2 + A78:A8:A76 + A78:A8:A5 + A78:A8:A30 +
              A78:A28:A2 + A78:A28:A76 + A78:A28:A5 + A78:A28:A30 +
              A78:A2:A76 + A78:A2:A5 + A78:A2:A30 +
              A78:A76:A5 + A78:A76:A30 +
              A78:A5:A30 +
              A8:A28:A2 + A8:A28:A76 + A8:A28:A5 + A8:A28:A30 +
              A8:A2:A76 + A8:A2:A5 + A8:A2:A30 +
              A8:A76:A5 + A8:A76:A30 +
              A8:A5:A30 +
              A28:A2:A76 + A28:A2:A5 + A28:A2:A30 +
              A28:A76:A5 + A28:A76:A30 +
              A28:A5:A30 +
              A2:A76:A5 + A2:A76:A30 +
              A2:A5:A30 +
              A76:A5:A30), data=mm1)
#summary(metodo)
plot(metodo$fitted.values,mm1$Aroma,xlim=c(7.8,9.0),ylim=c(7.8,9.0))
abline(0,1,col="blue")

print(summary(metodo))
## 
## Call:
## lm(formula = Aroma ~ (A7 + A78 + A8 + A28 + A2 + A76 + A5 + A30) + 
##     (A7:A78 + A7:A8 + A7:A28 + A7:A2 + A7:A76 + A7:A5 + A7:A30 + 
##         A78:A8 + A78:A28 + A78:A2 + A78:A76 + A78:A5 + A78:A30 + 
##         A8:A28 + A8:A2 + A8:A76 + A8:A5 + A8:A30 + A28:A2 + A28:A76 + 
##         A28:A5 + A28:A30 + A2:A76 + A2:A5 + A2:A30 + A76:A5 + 
##         A76:A30 + A5:A30) + (A7:A78:A8 + A7:A78:A28 + A7:A78:A2 + 
##     A7:A78:A76 + A7:A78:A5 + A7:A78:A30 + A7:A8:A28 + A7:A8:A2 + 
##     A7:A8:A76 + A7:A8:A5 + A7:A8:A30 + A7:A28:A2 + A7:A28:A76 + 
##     A7:A28:A5 + A7:A28:A30 + A7:A2:A76 + A7:A2:A5 + A7:A2:A30 + 
##     A7:A76:A5 + A7:A76:A30 + A7:A5:A30 + A78:A8:A28 + A78:A8:A2 + 
##     A78:A8:A76 + A78:A8:A5 + A78:A8:A30 + A78:A28:A2 + A78:A28:A76 + 
##     A78:A28:A5 + A78:A28:A30 + A78:A2:A76 + A78:A2:A5 + A78:A2:A30 + 
##     A78:A76:A5 + A78:A76:A30 + A78:A5:A30 + A8:A28:A2 + A8:A28:A76 + 
##     A8:A28:A5 + A8:A28:A30 + A8:A2:A76 + A8:A2:A5 + A8:A2:A30 + 
##     A8:A76:A5 + A8:A76:A30 + A8:A5:A30 + A28:A2:A76 + A28:A2:A5 + 
##     A28:A2:A30 + A28:A76:A5 + A28:A76:A30 + A28:A5:A30 + A2:A76:A5 + 
##     A2:A76:A30 + A2:A5:A30 + A76:A5:A30), data = mm1)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.141682 -0.026633  0.004847  0.027674  0.130727 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)  
## (Intercept) -4.387e+02  3.856e+02  -1.138   0.2606  
## A7          -4.437e+01  2.173e+03  -0.020   0.9838  
## A78          7.030e+01  5.520e+01   1.273   0.2086  
## A8          -7.030e+01  4.283e+03  -0.016   0.9870  
## A28         -4.282e+02  1.580e+03  -0.271   0.7874  
## A2           3.077e+03  2.704e+03   1.138   0.2605  
## A76         -1.051e+02  8.051e+01  -1.305   0.1977  
## A5           2.331e+03  1.448e+03   1.610   0.1136  
## A30          1.455e+02  1.331e+02   1.093   0.2795  
## A7:A78      -7.658e+01  2.967e+02  -0.258   0.7974  
## A7:A8        4.345e+02  1.930e+04   0.023   0.9821  
## A7:A28       7.942e+03  7.098e+03   1.119   0.2684  
## A7:A2       -1.443e+03  1.454e+04  -0.099   0.9213  
## A7:A76       3.830e+02  4.431e+02   0.865   0.3914  
## A7:A5       -9.185e+03  7.285e+03  -1.261   0.2131  
## A7:A30       9.194e+02  6.110e+02   1.505   0.1386  
## A78:A8       2.609e+02  4.591e+02   0.568   0.5724  
## A78:A28     -2.664e+01  2.700e+02  -0.099   0.9218  
## A78:A2      -5.836e+02  3.069e+02  -1.902   0.0629 .
## A78:A76      5.590e+00  9.430e+00   0.593   0.5559  
## A78:A5      -2.952e+02  1.603e+02  -1.842   0.0713 .
## A78:A30     -2.484e+01  1.942e+01  -1.279   0.2068  
## A8:A28       5.653e+02  7.739e+03   0.073   0.9421  
## A8:A2       -1.540e+04  1.310e+04  -1.176   0.2452  
## A8:A76       1.967e+02  6.617e+02   0.297   0.7675  
## A8:A5       -2.514e+03  3.641e+03  -0.690   0.4930  
## A8:A30      -1.538e+02  1.335e+03  -0.115   0.9088  
## A28:A2      -2.255e+03  4.558e+03  -0.495   0.6229  
## A28:A76     -2.068e+01  1.333e+02  -0.155   0.8773  
## A28:A5      -8.582e+02  2.780e+03  -0.309   0.7588  
## A28:A30      1.848e+02  5.912e+02   0.313   0.7559  
## A2:A76       3.491e+02  4.209e+02   0.830   0.4107  
## A2:A5        4.589e+03  5.697e+03   0.805   0.4243  
## A2:A30      -1.107e+03  1.043e+03  -1.062   0.2934  
## A76:A5       1.504e+02  2.513e+02   0.598   0.5522  
## A76:A30      3.550e+01  2.949e+01   1.204   0.2343  
## A5:A30      -9.124e+02  6.049e+02  -1.508   0.1376  
## A7:A78:A8   -1.011e+03  1.782e+03  -0.567   0.5731  
## A7:A78:A28  -2.816e+02  9.045e+02  -0.311   0.7568  
## A7:A78:A2    1.044e+03  1.365e+03   0.764   0.4481  
## A7:A78:A76  -3.368e+01  3.585e+01  -0.940   0.3518  
## A7:A78:A5    1.106e+03  7.193e+02   1.538   0.1303  
## A7:A78:A30  -7.054e+01  7.443e+01  -0.948   0.3477  
## A7:A8:A28    4.666e+03  1.843e+04   0.253   0.8011  
## A7:A8:A2    -5.311e+03  5.336e+04  -0.100   0.9211  
## A7:A8:A76    9.299e+02  1.629e+03   0.571   0.5707  
## A7:A8:A5     1.942e+04  1.256e+04   1.546   0.1282  
## A7:A8:A30    6.528e+02  5.173e+03   0.126   0.9001  
## A7:A28:A2    4.936e+03  1.729e+04   0.285   0.7765  
## A7:A28:A76  -1.629e+02  6.698e+02  -0.243   0.8088  
## A7:A28:A5    3.047e+03  7.745e+03   0.393   0.6956  
## A7:A28:A30  -3.969e+03  1.574e+03  -2.522   0.0148 *
## A7:A2:A76   -8.662e+02  1.036e+03  -0.836   0.4069  
## A7:A2:A5    -3.336e+02  2.354e+04  -0.014   0.9887  
## A7:A2:A30   -2.577e+03  3.948e+03  -0.653   0.5168  
## A7:A76:A5   -8.989e+02  6.450e+02  -1.394   0.1695  
## A7:A76:A30   3.298e+01  1.252e+02   0.263   0.7933  
## A7:A5:A30    4.465e+02  2.354e+03   0.190   0.8503  
## A78:A8:A28  -2.794e+02  1.024e+03  -0.273   0.7861  
## A78:A8:A2    1.429e+03  1.109e+03   1.288   0.2034  
## A78:A8:A76  -4.254e+01  6.157e+01  -0.691   0.4928  
## A78:A8:A5   -2.597e+02  3.271e+02  -0.794   0.4309  
## A78:A8:A30  -7.318e+01  1.096e+02  -0.668   0.5074  
## A78:A28:A2   3.018e+02  3.880e+02   0.778   0.4403  
## A78:A28:A76 -2.588e-03  1.479e+01   0.000   0.9999  
## A78:A28:A5   9.015e+01  2.138e+02   0.422   0.6750  
## A78:A28:A30  2.720e+01  1.076e+02   0.253   0.8014  
## A78:A2:A76   2.385e+01  3.471e+01   0.687   0.4950  
## A78:A2:A5   -3.764e+02  5.410e+02  -0.696   0.4897  
## A78:A2:A30   2.113e+02  1.113e+02   1.899   0.0633 .
## A78:A76:A5   1.385e+01  2.186e+01   0.634   0.5292  
## A78:A76:A30 -2.051e+00  2.900e+00  -0.707   0.4827  
## A78:A5:A30   1.042e+02  5.341e+01   1.951   0.0566 .
## A8:A28:A2   -2.115e+04  2.149e+04  -0.984   0.3296  
## A8:A28:A76   6.732e+02  7.021e+02   0.959   0.3421  
## A8:A28:A5   -1.047e+04  5.731e+03  -1.828   0.0734 .
## A8:A28:A30   1.735e+03  2.014e+03   0.862   0.3929  
## A8:A2:A76    1.789e+03  1.407e+03   1.272   0.2093  
## A8:A2:A5    -2.537e+03  9.901e+03  -0.256   0.7988  
## A8:A2:A30    3.207e+03  3.824e+03   0.839   0.4056  
## A8:A76:A5    2.094e+02  3.696e+02   0.567   0.5734  
## A8:A76:A30  -8.464e+01  1.309e+02  -0.647   0.5207  
## A8:A5:A30    1.548e+03  8.790e+02   1.761   0.0842 .
## A28:A2:A76   1.118e+03  5.167e+02   2.164   0.0352 *
## A28:A2:A5    1.501e+03  7.164e+03   0.210   0.8348  
## A28:A2:A30  -6.335e+02  1.299e+03  -0.488   0.6279  
## A28:A76:A5  -1.505e+02  2.387e+02  -0.630   0.5312  
## A28:A76:A30 -1.599e+01  4.500e+01  -0.355   0.7237  
## A28:A5:A30   3.545e+02  9.666e+02   0.367   0.7153  
## A2:A76:A5   -1.447e+03  7.699e+02  -1.879   0.0659 .
## A2:A76:A30  -1.682e+02  1.010e+02  -1.665   0.1020  
## A2:A5:A30    8.886e+00  1.783e+03   0.005   0.9960  
## A76:A5:A30  -4.018e+01  5.260e+01  -0.764   0.4485  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.07551 on 51 degrees of freedom
## Multiple R-squared:  0.9139, Adjusted R-squared:  0.7586 
## F-statistic: 5.885 on 92 and 51 DF,  p-value: 1.536e-10
## Se toman en cuenta todas las interacciones posibles entre las 8 variables
new_string="A7*A78*A8*A28*A2*A76*A5"
f<-paste0("Aroma~",new_string) %>% as.formula   #Calcula fórmula de regresión

metodo<-lm(f , data=mm1)
#summary(metodo)
plot(metodo$fitted.values,mm1$Aroma,xlim=c(7.8,9.0),ylim=c(7.8,9.0))
abline(0,1,col="blue")

print(summary(metodo))
## 
## Call:
## lm(formula = f, data = mm1)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.061747 -0.007725 -0.000113  0.008325  0.064410 
## 
## Coefficients: (1 not defined because of singularities)
##                           Estimate Std. Error t value Pr(>|t|)  
## (Intercept)                 -29222      19335  -1.511   0.1491  
## A7                          201143     141108   1.425   0.1721  
## A78                           4258       2837   1.501   0.1518  
## A8                          -92080     469870  -0.196   0.8470  
## A28                         200025     128296   1.559   0.1374  
## A2                          178440     379159   0.471   0.6439  
## A76                          27567      26507   1.040   0.3129  
## A5                          247067     138107   1.789   0.0915 .
## A7:A78                      -29194      20765  -1.406   0.1778  
## A7:A8                       671645    3399361   0.198   0.8457  
## A78:A8                       17214      62447   0.276   0.7861  
## A7:A28                    -1383930     928497  -1.491   0.1544  
## A78:A28                     -29770      19247  -1.547   0.1404  
## A8:A28                     1117298    3868399   0.289   0.7762  
## A7:A2                      -944927    2796746  -0.338   0.7396  
## A78:A2                      -26563      54515  -0.487   0.6323  
## A8:A2                      5491938    8163663   0.673   0.5102  
## A28:A2                     -767211    2804092  -0.274   0.7877  
## A7:A76                     -177733     223969  -0.794   0.4384  
## A78:A76                      -3687       3597  -1.025   0.3198  
## A8:A76                     -100583     409147  -0.246   0.8088  
## A28:A76                    -225678     207716  -1.086   0.2924  
## A2:A76                     -146549     267026  -0.549   0.5903  
## A7:A5                     -1751620    1022483  -1.713   0.1049  
## A78:A5                      -36824      20305  -1.814   0.0874 .
## A8:A5                      -784272    1782940  -0.440   0.6656  
## A28:A5                    -1788659     949742  -1.883   0.0769 .
## A2:A5                     -2272460    2489796  -0.913   0.3742  
## A76:A5                     -206128     119590  -1.724   0.1029  
## A7:A78:A8                  -127645     451402  -0.283   0.7808  
## A7:A78:A28                  205517     139347   1.475   0.1585  
## A7:A8:A28                 -6854558   28441475  -0.241   0.8124  
## A78:A8:A28                 -185259     519489  -0.357   0.7258  
## A7:A78:A2                   141050     403228   0.350   0.7308  
## A7:A8:A2                 -42865994   58640926  -0.731   0.4747  
## A78:A8:A2                  -837247    1094797  -0.765   0.4549  
## A7:A28:A2                  2529548   20743833   0.122   0.9044  
## A78:A28:A2                  123806     404204   0.306   0.7631  
## A8:A28:A2                -51820520   67475955  -0.768   0.4530  
## A7:A78:A76                   23768      30292   0.785   0.4435  
## A7:A8:A76                   518834    3351079   0.155   0.8788  
## A78:A8:A76                    7976      53607   0.149   0.8835  
## A7:A28:A76                 1592270    1810603   0.879   0.3914  
## A78:A28:A76                  30921      27893   1.109   0.2831  
## A8:A28:A76                  399590    3172425   0.126   0.9012  
## A7:A2:A76                   751914    2273110   0.331   0.7448  
## A78:A2:A76                   20287      37624   0.539   0.5967  
## A8:A2:A76                 -3162398    4004967  -0.790   0.4406  
## A28:A2:A76                 1304846    1889976   0.690   0.4993  
## A7:A78:A5                   260990     150302   1.736   0.1006  
## A7:A8:A5                   5426776   12755724   0.425   0.6759  
## A78:A8:A5                   116202     246878   0.471   0.6438  
## A7:A28:A5                 12615868    6903646   1.827   0.0852 .
## A78:A28:A5                  270532     141952   1.906   0.0737 .
## A8:A28:A5                  4886777   13449069   0.363   0.7208  
## A7:A2:A5                  14879473   18249591   0.815   0.4262  
## A78:A2:A5                   347338     361175   0.962   0.3497  
## A8:A2:A5                  -9630226   37197949  -0.259   0.7988  
## A28:A2:A5                 14731712   18525526   0.795   0.4375  
## A7:A76:A5                  1438582     955333   1.506   0.1505  
## A78:A76:A5                   28962      16558   1.749   0.0983 .
## A8:A76:A5                  1354858    1316702   1.029   0.3179  
## A28:A76:A5                 1713688     864771   1.982   0.0639 .
## A2:A76:A5                  1780815    1344545   1.324   0.2029  
## A7:A78:A8:A28              1179102    3822973   0.308   0.7615  
## A7:A78:A8:A2               6532362    7869771   0.830   0.4180  
## A7:A78:A28:A2              -446310    2987081  -0.149   0.8830  
## A7:A8:A28:A2             388453601  489444521   0.794   0.4383  
## A78:A8:A28:A2              7762105    9093111   0.854   0.4052  
## A7:A78:A8:A76               -31047     440103  -0.071   0.9446  
## A7:A78:A28:A76             -220676     242599  -0.910   0.3757  
## A7:A8:A28:A76             -2831267   26841808  -0.105   0.9172  
## A78:A8:A28:A76              -12999     412104  -0.032   0.9752  
## A7:A78:A2:A76              -108095     316936  -0.341   0.7372  
## A7:A8:A2:A76              26358203   32400900   0.814   0.4272  
## A78:A8:A2:A76               489369     521075   0.939   0.3608  
## A7:A28:A2:A76             -9831705   16695370  -0.589   0.5637  
## A78:A28:A2:A76             -192156     265356  -0.724   0.4788  
## A8:A28:A2:A76             34090638   25568935   1.333   0.2000  
## A7:A78:A8:A5               -799955    1769483  -0.452   0.6569  
## A7:A78:A28:A5             -1907303    1029924  -1.852   0.0815 .
## A7:A8:A28:A5             -37430264   96900888  -0.386   0.7041  
## A78:A8:A28:A5              -765383    1870096  -0.409   0.6874  
## A7:A78:A2:A5              -2287221    2649696  -0.863   0.4000  
## A7:A8:A2:A5               89112589  267598284   0.333   0.7432  
## A78:A8:A2:A5               1241819    5158356   0.241   0.8126  
## A7:A28:A2:A5             -90926389  135136331  -0.673   0.5101  
## A78:A28:A2:A5             -2314696    2695104  -0.859   0.4024  
## A8:A28:A2:A5             105688960  295244399   0.358   0.7248  
## A7:A78:A76:A5              -202603     131632  -1.539   0.1422  
## A7:A8:A76:A5              -9343703   10765316  -0.868   0.3975  
## A78:A8:A76:A5              -177220     176018  -1.007   0.3281  
## A7:A28:A76:A5            -12634401    7057774  -1.790   0.0913 .
## A78:A28:A76:A5             -244448     119485  -2.046   0.0566 .
## A8:A28:A76:A5            -10564296    8997438  -1.174   0.2565  
## A7:A2:A76:A5             -12055012   10395950  -1.160   0.2622  
## A78:A2:A76:A5              -260230     193625  -1.344   0.1966  
## A8:A2:A76:A5               1182659   10815517   0.109   0.9142  
## A28:A2:A76:A5            -15690819    9242383  -1.698   0.1078  
## A7:A78:A8:A28:A2         -58360583   65971953  -0.885   0.3887  
## A7:A78:A8:A28:A76           121821    3503159   0.035   0.9727  
## A7:A78:A8:A2:A76          -3943078    4223719  -0.934   0.3636  
## A7:A78:A28:A2:A76          1497806    2307799   0.649   0.5250  
## A7:A8:A28:A2:A76        -241572898  212506229  -1.137   0.2714  
## A78:A8:A28:A2:A76         -5040862    3204868  -1.573   0.1342  
## A7:A78:A8:A28:A5           5776612   13467787   0.429   0.6734  
## A7:A78:A8:A2:A5          -11803416   37188962  -0.317   0.7548  
## A7:A78:A28:A2:A5          14427108   19608765   0.736   0.4719  
## A7:A8:A28:A2:A5         -895010488 2136069067  -0.419   0.6805  
## A78:A8:A28:A2:A5         -13736578   40858042  -0.336   0.7408  
## A7:A78:A8:A76:A5           1226256    1437984   0.853   0.4056  
## A7:A78:A28:A76:A5          1810494     967062   1.872   0.0785 .
## A7:A8:A28:A76:A5          81481797   77640689   1.049   0.3087  
## A78:A8:A28:A76:A5          1417200    1170127   1.211   0.2424  
## A7:A78:A2:A76:A5           1782669    1491283   1.195   0.2483  
## A7:A8:A2:A76:A5          -18307351   84710973  -0.216   0.8315  
## A78:A8:A2:A76:A5           -156014    1525825  -0.102   0.9198  
## A7:A28:A2:A76:A5         120169733   69687374   1.724   0.1028  
## A78:A28:A2:A76:A5          2343377    1352120   1.733   0.1012  
## A8:A28:A2:A76:A5         -19968116   31163013  -0.641   0.5302  
## A7:A78:A8:A28:A2:A76      34941224   26648075   1.311   0.2072  
## A7:A78:A8:A28:A2:A5      119182401  295297127   0.404   0.6915  
## A7:A78:A8:A28:A76:A5     -11079174   10097918  -1.097   0.2879  
## A7:A78:A8:A2:A76:A5        2196919   11950091   0.184   0.8563  
## A7:A78:A28:A2:A76:A5     -18062444   10134080  -1.782   0.0926 .
## A7:A8:A28:A2:A76:A5       57386329  148402673   0.387   0.7038  
## A78:A8:A28:A2:A76:A5       2070056    4031236   0.514   0.6142  
## A7:A78:A8:A28:A2:A76:A5         NA         NA      NA       NA  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.05538 on 17 degrees of freedom
## Multiple R-squared:  0.9846, Adjusted R-squared:  0.8702 
## F-statistic: 8.606 on 126 and 17 DF,  p-value: 4.556e-06
mm0<-import("PolarCorrelation.xlsx")
nombres=names(mm0[,1:86])
codigo=c(gsub(" ","",paste("A",1:86)))
names(mm0)<-c(gsub(" ","",paste("A",1:86)),"Aroma","Flavor","Aftertaste","Acidity","Body","Balance","Overall")


compuestos<-data.frame(codigo=codigo,nombre=nombres)
compuestos 
##    codigo                                                             nombre
## 1      A1                                                 1,2-Propanediamine
## 2      A2                                                       Acetaldehyde
## 3      A3                                             1-Propen-2-ol, acetate
## 4      A4                                                      Ethyl Acetate
## 5      A5                                                 Butanal, 2-methyl-
## 6      A6                                                            Ethanol
## 7      A7                                                    2,3-Butanedione
## 8      A8                              Butanoic acid, 2-methyl-, ethyl ester
## 9      A9                                                   2,3-Pentanedione
## 10    A10                              Butanoic acid, 3-methyl-, ethyl ester
## 11    A11 1,5-Heptadiene, 2,3,6-trimethyl- $$ 2,3,6-Trimethyl-1,5-heptadiene
## 12    A12                                      1-Butanol, 3-methyl-, acetate
## 13    A13                                                           p-Cresol
## 14    A14                                                      beta.-Myrcene
## 15    A15                                                           Limonene
## 16    A16                                                      Crotonic acid
## 17    A17                                               trans-.beta.-Ocimene
## 18    A18                                              Furfuryl methyl ether
## 19    A19                                                        cis-ocimeno
## 20    A20                                                  Pyrazine, methyl-
## 21    A21                                                         Terpinolen
## 22    A22                                                            Acetoin
## 23    A23                                                             Acetol
## 24    A24                                            Pyrazine, 2,5-dimethyl-
## 25    A25                                            Pyrazine, 2,6-dimethyl-
## 26    A26                                                   Pyrazine, ethyl-
## 27    A27                                            Pyrazine, 2,3-dimethyl-
## 28    A28                                              Glycidyl methyl ether
## 29    A29                            2,4,6-Octatriene, 2,6-dimethyl-, (E,Z)-
## 30    A30                                        Pyrazine, 2-ethyl-6-methyl-
## 31    A31                                         Pyrazine, 2-ethyl-5-methyl
## 32    A32                                               Pyrazine, trimethyl-
## 33    A33                                                      Vinylpyrazine
## 34    A34                                    Pyrazine, 3-ethyl-2,5-dimethyl-
## 35    A35                                                2,3-Diethylpyrazine
## 36    A36                                                2,6-Diethylpyrazine
## 37    A37                                       Pyrazine, 2-methyl-6-propyl-
## 38    A38                                                           Furfural
## 39    A39                                        Pyrazine, 2-methyl-6-vinyl-
## 40    A40                                    Pyrazine, 3,5-diethyl-2-methyl-
## 41    A41                                        2,5-dimethyl-3(2H)-furanone
## 42    A42                                           Ethanone, 1-(2-furanyl)-
## 43    A43                                    2,3,5-Trimethyl-6-ethylpyrazine
## 44    A44                                          2-Butanone, 3,3-dimethyl-
## 45    A45                                           2-Furanmethanol, acetate
## 46    A46                                                         LINALOOL L
## 47    A47                                                  5 METHYL FURFURAL
## 48    A48                                                     2,3-Butanediol
## 49    A49                                       Pyrazine, (1-methylethenyl)-
## 50    A50                          5H-5-Methyl-6,7-dihydrocyclopentapyrazine
## 51    A51                                              2-Furancarboxaldehyde
## 52    A52                             Ethanone, 1-(1-methyl-1H-pyrrol-2-yl)-
## 53    A53                                   2,3-Dimethyl-5-isopentylpyrazine
## 54    A54                                                    2-Furanmethanol
## 55    A55                                       Succinic acid, diethyl ester
## 56    A56                                1-(6-Methyl-2-pyrazinyl)-1-ethanone
## 57    A57                                           Butanoic acid, 3-methyl-
## 58    A58                                                  .alpha.-Terpineol
## 59    A59                                               cis- Geranyl acetate
## 60    A60                                           4(H)-Pyridine, N-acetyl-
## 61    A61                                                    Geranyl acetate
## 62    A62                                                  Methyl Salicylate
## 63    A63                                                       cis-Geraniol
## 64    A64                                   1H-Pyrrole, 1-(2-furanylmethyl)-
## 65    A65                                                           Geraniol
## 66    A66                                                           Mequinol
## 67    A67                            2-Cyclopenten-1-one, 3-ethyl-2-hydroxy-
## 68    A68                                         trans-Furfurylideneacetone
## 69    A69                           Benzeneacetaldehyde, .alpha.-ethylidene-
## 70    A70                                                             Maltol
## 71    A71                                      Ethanone, 1-(1H-pyrrol-2-yl)-
## 72    A72                                     4-Hydroxy-3-methylacetophenone
## 73    A73                                        1H-Pyrrole-2-carboxaldehyde
## 74    A74                                                    2-Pyrrolidinone
## 75    A75                                                    p-Ethylguaiacol
## 76    A76                                                           Furaneol
## 77    A77                             1H-Pyrrole-2-carboxaldehyde, 1-methyl-
## 78    A78                                                    4-vinylguaiacol
## 79    A79                                                      Palmitic acid
## 80    A80                4H-Pyran-4-one, 2,3-dihydro-3,5-dihydroxy-6-methyl-
## 81    A81                                                           Coumaran
## 82    A82                                                           Caffeine
## 83    A83                                                        3-Pyridinol
## 84    A84                                                             Indole
## 85    A85                                            5-Hydroxymethylfurfural
## 86    A86                                          Linoleic acid ethyl ester

Predicción de datos originales columna Polar

## Se toman en cuenta solo las interacciones doble y triples

metodo<-lm(Aroma~A7+A38+A54+A9+A49, data=mm0)
#summary(metodo)
plot(metodo$fitted.values,mm0$Aroma,xlim=c(7.8,9.0),ylim=c(7.8,9.0))
abline(0,1,col="blue")

print(summary(metodo))
## 
## Call:
## lm(formula = Aroma ~ A7 + A38 + A54 + A9 + A49, data = mm0)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -0.07772 -0.02801 -0.01162  0.02450  0.10982 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  8.83920    0.34800  25.400 2.05e-10 ***
## A7           5.44456    0.91058   5.979 0.000136 ***
## A38          0.02943    0.01215   2.423 0.035884 *  
## A54         -0.07932    0.02839  -2.794 0.018989 *  
## A9          -0.74445    0.37310  -1.995 0.073963 .  
## A49         -1.21023    0.36949  -3.275 0.008354 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.06417 on 10 degrees of freedom
## Multiple R-squared:  0.8621, Adjusted R-squared:  0.7931 
## F-statistic:  12.5 on 5 and 10 DF,  p-value: 0.0004877