#Asignatura: Diseæ¼ã¸±os Experimentales
#Facultad : Ingenieræ¼ã¹¤a Estadistica e Informatica
#Universidad Nacional del Altiplano
library(knitr)
## Warning: package 'knitr' was built under R version 3.6.3
library(readxl)
## Warning: package 'readxl' was built under R version 3.6.3
DCAU <- read_excel("DCAU.xlsx")
DCAU
## # A tibble: 30 x 2
## ph Frutas
## <dbl> <chr>
## 1 3.34 Mandarina
## 2 3.22 Mandarina
## 3 3.63 Mandarina
## 4 3.33 Mandarina
## 5 3.62 Mandarina
## 6 3.26 Mandarina
## 7 3.57 Mandarina
## 8 3.23 Mandarina
## 9 3.69 Mandarina
## 10 3.28 Mandarina
## # ... with 20 more rows
head(DCAU)
## # A tibble: 6 x 2
## ph Frutas
## <dbl> <chr>
## 1 3.34 Mandarina
## 2 3.22 Mandarina
## 3 3.63 Mandarina
## 4 3.33 Mandarina
## 5 3.62 Mandarina
## 6 3.26 Mandarina
str(DCAU)
## tibble [30 x 2] (S3: tbl_df/tbl/data.frame)
## $ ph : num [1:30] 3.34 3.22 3.63 3.33 3.62 3.26 3.57 3.23 3.69 3.28 ...
## $ Frutas: chr [1:30] "Mandarina" "Mandarina" "Mandarina" "Mandarina" ...
View(DCAU)
DCAU$Frutas <- factor(DCAU$Frutas)
DCAU$ph <- as.numeric(DCAU$ph)
head(DCAU)
## # A tibble: 6 x 2
## ph Frutas
## <dbl> <fct>
## 1 3.34 Mandarina
## 2 3.22 Mandarina
## 3 3.63 Mandarina
## 4 3.33 Mandarina
## 5 3.62 Mandarina
## 6 3.26 Mandarina
str(DCAU)
## tibble [30 x 2] (S3: tbl_df/tbl/data.frame)
## $ ph : num [1:30] 3.34 3.22 3.63 3.33 3.62 3.26 3.57 3.23 3.69 3.28 ...
## $ Frutas: Factor w/ 3 levels "Fresa","Mandarina",..: 2 2 2 2 2 2 2 2 2 2 ...
#Graficos-Homogeneidad
library(ggplot2)
ggplot(DCAU) + geom_bar(aes(Frutas, fill = Frutas))

#Tabla ANOVA
fit<-aov(ph~Frutas, data=DCAU)
summary(fit)
## Df Sum Sq Mean Sq F value Pr(>F)
## Frutas 2 0.1054 0.05272 2.961 0.0688 .
## Residuals 27 0.4808 0.01781
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#Prueba de Shaphiro-Wilk
shapiro.test(residuals(fit))
##
## Shapiro-Wilk normality test
##
## data: residuals(fit)
## W = 0.95515, p-value = 0.2317
#Grafico-Normalidad
library(car)
## Warning: package 'car' was built under R version 3.6.3
## Loading required package: carData
## Warning: package 'carData' was built under R version 3.6.3
qqPlot(fit)
## [1] 3 9
mtext("By:Amarillas", side = 3, adj = 1, family = "mono")

#Prueba de Bartlett
bartlett.test(ph~Frutas, data=DCAU)
##
## Bartlett test of homogeneity of variances
##
## data: ph by Frutas
## Bartlett's K-squared = 6.0217, df = 2, p-value = 0.04925
#Grafico-Cajas
boxplot(ph~Frutas,data=DCAU, col=c("green","blue","orange"), main="Diagrama de Cajas de los Jugos de Frutas")
mtext("By:Amarillas", side = 3, adj = 1, family = "mono")

#Grupos
library(agricolae)
## Warning: package 'agricolae' was built under R version 3.6.3
Grupos1 <- LSD.test(fit, "Frutas", group = T, console = T);
##
## Study: fit ~ "Frutas"
##
## LSD t Test for ph
##
## Mean Square Error: 0.01780815
##
## Frutas, means and individual ( 95 %) CI
##
## ph std r LCL UCL Min Max
## Fresa 3.433 0.1066719 10 3.346413 3.519587 3.32 3.60
## Mandarina 3.417 0.1871452 10 3.330413 3.503587 3.22 3.69
## Piña 3.550 0.0837987 10 3.463413 3.636587 3.40 3.67
##
## Alpha: 0.05 ; DF Error: 27
## Critical Value of t: 2.051831
##
## least Significant Difference: 0.122452
##
## Treatments with the same letter are not significantly different.
##
## ph groups
## Piña 3.550 a
## Fresa 3.433 ab
## Mandarina 3.417 b
Grupos2 <- LSD.test(fit, "Frutas", group = F, console = T)
##
## Study: fit ~ "Frutas"
##
## LSD t Test for ph
##
## Mean Square Error: 0.01780815
##
## Frutas, means and individual ( 95 %) CI
##
## ph std r LCL UCL Min Max
## Fresa 3.433 0.1066719 10 3.346413 3.519587 3.32 3.60
## Mandarina 3.417 0.1871452 10 3.330413 3.503587 3.22 3.69
## Piña 3.550 0.0837987 10 3.463413 3.636587 3.40 3.67
##
## Alpha: 0.05 ; DF Error: 27
## Critical Value of t: 2.051831
##
## Comparison between treatments means
##
## difference pvalue signif. LCL UCL
## Fresa - Mandarina 0.016 0.7907 -0.106452 0.138451994
## Fresa - Piña -0.117 0.0603 . -0.239452 0.005451994
## Mandarina - Piña -0.133 0.0344 * -0.255452 -0.010548006
#Prueba-Bonferroni-Ducan
LSD.test(fit, "Frutas", p.adj= "bonferroni",console=TRUE) -> bon;
##
## Study: fit ~ "Frutas"
##
## LSD t Test for ph
## P value adjustment method: bonferroni
##
## Mean Square Error: 0.01780815
##
## Frutas, means and individual ( 95 %) CI
##
## ph std r LCL UCL Min Max
## Fresa 3.433 0.1066719 10 3.346413 3.519587 3.32 3.60
## Mandarina 3.417 0.1871452 10 3.330413 3.503587 3.22 3.69
## Piña 3.550 0.0837987 10 3.463413 3.636587 3.40 3.67
##
## Alpha: 0.05 ; DF Error: 27
## Critical Value of t: 2.552459
##
## Minimum Significant Difference: 0.1523292
##
## Treatments with the same letter are not significantly different.
##
## ph groups
## Piña 3.550 a
## Fresa 3.433 a
## Mandarina 3.417 a
duncan.test(fit, "Frutas",console=TRUE)
##
## Study: fit ~ "Frutas"
##
## Duncan's new multiple range test
## for ph
##
## Mean Square Error: 0.01780815
##
## Frutas, means
##
## ph std r Min Max
## Fresa 3.433 0.1066719 10 3.32 3.60
## Mandarina 3.417 0.1871452 10 3.22 3.69
## Piña 3.550 0.0837987 10 3.40 3.67
##
## Alpha: 0.05 ; DF Error: 27
##
## Critical Range
## 2 3
## 0.1224520 0.1286526
##
## Means with the same letter are not significantly different.
##
## ph groups
## Piña 3.550 a
## Fresa 3.433 ab
## Mandarina 3.417 b