En una empresa lechera se han tenido problemas con la viscosidad de cierta bebida de chocolate. Se cree que con tres ingredientes que se agregan en pequeñas cantidades se puede resol ver este problema, por lo que es necesario explorar la situación; para ello se corre un experimento 23 con dos réplicas. A continuación se aprecian los resultados obtenidos (Pulido & Vara Salazar, 2012):
| Ingrediente A | Ingrediente B | Ingrediente C | Viscocidad |
|---|---|---|---|
| -1 | -1 | -1 | 13.3, 13.9 |
| +1 | -1 | -1 | 14.7, 14.4 |
| -1 | +1 | -1 | 14.6, 14.9 |
| +1 | +1 | -1 | 14.3, 14.1 |
| -1 | -1 | +1 | 16.9, 17.2 |
| +1 | -1 | +1 | 15.5, 15.1 |
| -1 | +1 | +1 | 17.4, 17.1 |
| +1 | +1 | +1 | 18.9, 19.2 |
{
library(printr)
}
## Registered S3 method overwritten by 'printr':
## method from
## knit_print.data.frame rmarkdown
{
datos= read.table("dataset.txt", header =TRUE)
str(datos)
}
## 'data.frame': 16 obs. of 4 variables:
## $ Ingrediente_A: int -1 1 -1 1 -1 1 -1 1 -1 1 ...
## $ Ingrediente_B: int -1 -1 1 1 -1 -1 1 1 -1 -1 ...
## $ Ingrediente_C: int -1 -1 -1 -1 1 1 1 1 -1 -1 ...
## $ Viscocidad : num 13.3 14.7 14.6 14.3 16.9 15.5 17.4 18.9 13.9 14.4 ...
{
attach(datos)
}
head(datos, n=16)
| Ingrediente_A | Ingrediente_B | Ingrediente_C | Viscocidad |
|---|---|---|---|
| -1 | -1 | -1 | 13.3 |
| 1 | -1 | -1 | 14.7 |
| -1 | 1 | -1 | 14.6 |
| 1 | 1 | -1 | 14.3 |
| -1 | -1 | 1 | 16.9 |
| 1 | -1 | 1 | 15.5 |
| -1 | 1 | 1 | 17.4 |
| 1 | 1 | 1 | 18.9 |
| -1 | -1 | -1 | 13.9 |
| 1 | -1 | -1 | 14.4 |
| -1 | 1 | -1 | 14.9 |
| 1 | 1 | -1 | 14.1 |
| -1 | -1 | 1 | 17.2 |
| 1 | -1 | 1 | 15.1 |
| -1 | 1 | 1 | 17.1 |
| 1 | 1 | 1 | 19.2 |
{
modelo=lm(Viscocidad~(Ingrediente_A+Ingrediente_B+Ingrediente_C+Ingrediente_A*Ingrediente_B+Ingrediente_A*Ingrediente_C+Ingrediente_B*Ingrediente_C+Ingrediente_A*Ingrediente_B*Ingrediente_C))
summary(modelo)
}
##
## Call:
## lm(formula = Viscocidad ~ (Ingrediente_A + Ingrediente_B + Ingrediente_C +
## Ingrediente_A * Ingrediente_B + Ingrediente_A * Ingrediente_C +
## Ingrediente_B * Ingrediente_C + Ingrediente_A * Ingrediente_B *
## Ingrediente_C))
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.30 -0.15 0.00 0.15 0.30
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 15.71875 0.06281 250.252 < 2e-16
## Ingrediente_A 0.05625 0.06281 0.896 0.396647
## Ingrediente_B 0.59375 0.06281 9.453 1.29e-05
## Ingrediente_C 1.44375 0.06281 22.985 1.36e-08
## Ingrediente_A:Ingrediente_B 0.25625 0.06281 4.080 0.003536
## Ingrediente_A:Ingrediente_C -0.04375 0.06281 -0.697 0.505830
## Ingrediente_B:Ingrediente_C 0.39375 0.06281 6.269 0.000241
## Ingrediente_A:Ingrediente_B:Ingrediente_C 0.63125 0.06281 10.050 8.18e-06
##
## (Intercept) ***
## Ingrediente_A
## Ingrediente_B ***
## Ingrediente_C ***
## Ingrediente_A:Ingrediente_B **
## Ingrediente_A:Ingrediente_C
## Ingrediente_B:Ingrediente_C ***
## Ingrediente_A:Ingrediente_B:Ingrediente_C ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.2512 on 8 degrees of freedom
## Multiple R-squared: 0.9898, Adjusted R-squared: 0.9809
## F-statistic: 110.8 on 7 and 8 DF, p-value: 2.493e-07
library(FrF2)
experimento= FrF2(nruns= 4, nfactors = 3, factor.names = list(Ingrediente_A=c(-1,1),Ingrediente_B=c(-1,1),Ingrediente_C=c(-1,1)),replications= 4,randomize = FALSE)
experimento_respuesta=add.response(design=experimento,response = Viscocidad)
grafica_efectos_principales=MEPlot(experimento_respuesta, main= "Grafica de efectos individuales")
grafica_interacciones= IAPlot(experimento_respuesta, main= "Grafica de interacciones")
head(grafica_efectos_principales)
| Ingrediente_A | Ingrediente_B | Ingrediente_C | |
|---|---|---|---|
| - | 15.6625 | 15.1250 | 15.4625 |
| + | 15.7750 | 16.3125 | 15.9750 |
head(grafica_interacciones)
| Ingrediente_A:Ingrediente_B | Ingrediente_A:Ingrediente_C | Ingrediente_B:Ingrediente_C | |
|---|---|---|---|
| -:- | 15.325 | 16.000 | 14.925 |
| +:- | 14.925 | 14.925 | 16.000 |
| -:+ | 16.000 | 15.325 | 15.325 |
| +:+ | 16.625 | 16.625 | 16.625 |
Comentario: Como se puede observar existe una interacción entre los factores.Lo cual quiere decir que los ingredientes A,B y C si afectan la viscocidad de la leche, esto se observa en el valor valor_p <0.05 el cual es de significancia para este ejercicico.
anova=aov(modelo)
summary(anova)
## Df Sum Sq Mean Sq F value Pr(>F)
## Ingrediente_A 1 0.05 0.05 0.802 0.396647
## Ingrediente_B 1 5.64 5.64 89.356 1.29e-05
## Ingrediente_C 1 33.35 33.35 528.327 1.36e-08
## Ingrediente_A:Ingrediente_B 1 1.05 1.05 16.644 0.003536
## Ingrediente_A:Ingrediente_C 1 0.03 0.03 0.485 0.505830
## Ingrediente_B:Ingrediente_C 1 2.48 2.48 39.297 0.000241
## Ingrediente_A:Ingrediente_B:Ingrediente_C 1 6.38 6.38 101.000 8.18e-06
## Residuals 8 0.50 0.06
##
## Ingrediente_A
## Ingrediente_B ***
## Ingrediente_C ***
## Ingrediente_A:Ingrediente_B **
## Ingrediente_A:Ingrediente_C
## Ingrediente_B:Ingrediente_C ***
## Ingrediente_A:Ingrediente_B:Ingrediente_C ***
## Residuals
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Comentario: Los efectos significativos son los ingredientes B, C, AB, BC y ABC eso quiere decir que estos ingredientes si afectan a la viscosidad de la bebida.
Comentario: Como se observo anteriormente, si existen efectos significativos en los ingredientes con la viscocidad que se genera. Los ingredientes que mas demostraron interacciones son el Ingrediente B y el Ingrediente C con lo que se puede decir que estos afectan la viscocidad de la leche. Ahora bien el que mayor agrega viscocidad es el Ingrediente_C.
Comentario: Observando el ANOVA nos encontramos que los efectos mencionados son significativos de igual forma, por lo que no hay un tratamiento para que dichos efectos se puedan minimizar.
Para poder hacerlo, se hara una prueba de normalidad de shapiro;
\[H_0:{\sigma^2}={\sigma^2_j}=Costante\]
\[H_1:{\sigma^2}\,{\neq}\,{\sigma^2_j}\,{\neq}\,Costante\]
normalidad=shapiro.test(resid(modelo))
print(normalidad)
##
## Shapiro-Wilk normality test
##
## data: resid(modelo)
## W = 0.87343, p-value = 0.0307
qqnorm(resid(modelo),main= "Grafica de probabilidad para los residuales del modelo", xlab= "Cuantiles teoricos", ylab = "Cuantiles de muestra")
qqline(resid(modelo))
Comentario: Se observa que los Ingredientes A y B son que tienen una mayor viscocidad, por lo tanto representan un mayor impacto el la leche de chocolate.
Ahora se realizara una prueba de igualdad de varianzas de Bartlett
homocedasticidad=bartlett.test(resid(modelo),Ingrediente_A,Ingrediente_B,Ingrediente_C,data=experimento_respuesta)
print(homocedasticidad)
##
## Bartlett test of homogeneity of variances
##
## data: resid(modelo) and Ingrediente_A
## Bartlett's K-squared = 0.41308, df = 1, p-value = 0.5204
Comentario: Por ultimo se concluye que el modelo no es adecuado para poder explicar la viscocidad que se presenta en la leche de chocolate.