library(readxl)
library(outliers)
datos = read_excel("//cloud//project//pesofrescopa.xlsx", sheet = 1)
tratamiento<- as.factor(datos$tratamiento)
bloque<- as.factor(datos$bloque)
sujeto<- as.factor(datos$sujeto)
dca1<-aov(datos$pesofresco~tratamiento+bloque+Error(sujeto)) 
dca1
## 
## Call:
## aov(formula = datos$pesofresco ~ tratamiento + bloque + Error(sujeto))
## 
## Grand Mean: 2.8675
## 
## Stratum 1: sujeto
## 
## Terms:
##                 tratamiento    bloque Residuals
## Sum of Squares    26.184900  1.288225  0.445275
## Deg. of Freedom           3         1         3
## 
## Residual standard error: 0.3852597
## Estimated effects may be unbalanced
## 
## Stratum 2: Within
## 
## Terms:
##                 Residuals
## Sum of Squares     2.6123
## Deg. of Freedom         8
## 
## Residual standard error: 0.5714346
summary(dca1)
## 
## Error: sujeto
##             Df Sum Sq Mean Sq F value  Pr(>F)   
## tratamiento  3 26.185   8.728  58.806 0.00365 **
## bloque       1  1.288   1.288   8.679 0.06022 . 
## Residuals    3  0.445   0.148                   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Error: Within
##           Df Sum Sq Mean Sq F value Pr(>F)
## Residuals  8  2.612  0.3265
x <-dca1$sujeto$residuals  
y <-dca1$Within$residuals

sc.error.a <-sum(x^2)       #SUMA DE CUADRADOS DEL ERROR EXPERIMENTAL
sc.error.b <-sum(y^2)       #SUMA DE CUADRADOS DEL ERROR MUESTRAL

format(x, big.mark = ",")
##              2              3              4              5              6 
## "-0.237500000" "-0.313212521" " 0.442949395" " 0.194480076" "-0.238188476" 
##              7              8 
## "-0.001636634" " 0.001889822"
dca2<-aov(datos$pesofresco~tratamiento+bloque+sujeto%in%bloque%in%tratamiento)
summary(dca2)
##                           Df Sum Sq Mean Sq F value  Pr(>F)    
## tratamiento                3 26.185   8.728  26.730 0.00016 ***
## bloque                     1  1.288   1.288   3.945 0.08225 .  
## tratamiento:bloque:sujeto  3  0.445   0.148   0.455 0.72132    
## Residuals                  8  2.612   0.327                    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
mod1 = aov(datos$pesofresco ~ tratamiento*bloque, datos)
sum1<-summary(mod1)
sum1 <- unlist(sum1)
sum1 = sum1[9]
summary(mod1)
##                    Df Sum Sq Mean Sq F value  Pr(>F)    
## tratamiento         3 26.185   8.728  26.730 0.00016 ***
## bloque              1  1.288   1.288   3.945 0.08225 .  
## tratamiento:bloque  3  0.445   0.148   0.455 0.72132    
## Residuals           8  2.612   0.327                    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
TukeyHSD(mod1, "tratamiento")
## Warning in replications(paste("~", xx), data = mf): non-factors ignored: bloque
## Warning in replications(paste("~", xx), data = mf): non-factors ignored:
## tratamiento, bloque
##   Tukey multiple comparisons of means
##     95% family-wise confidence level
## 
## Fit: aov(formula = datos$pesofresco ~ tratamiento * bloque, data = datos)
## 
## $tratamiento
##         diff        lwr        upr     p adj
## T2-T1 -2.825 -4.1189593 -1.5310407 0.0005184
## T3-T1 -3.165 -4.4589593 -1.8710407 0.0002338
## T4-T1 -2.820 -4.1139593 -1.5260407 0.0005247
## T3-T2 -0.340 -1.6339593  0.9539593 0.8336662
## T4-T2  0.005 -1.2889593  1.2989593 0.9999993
## T4-T3  0.345 -0.9489593  1.6389593 0.8278266
library(agricolae)
duncan.test(mod1, 'tratamiento', console = T)
## 
## Study: mod1 ~ "tratamiento"
## 
## Duncan's new multiple range test
## for datos$pesofresco 
## 
## Mean Square Error:  0.3265375 
## 
## tratamiento,  means
## 
##    datos.pesofresco       std r        se  Min  Max    Q25   Q50    Q75
## T1            5.070 0.7841343 4 0.2857173 4.18 5.82 4.5325 5.140 5.6775
## T2            2.245 0.7001190 4 0.2857173 1.63 3.14 1.7200 2.105 2.6300
## T3            1.905 0.4403408 4 0.2857173 1.27 2.28 1.8100 2.035 2.1300
## T4            2.250 0.3868678 4 0.2857173 1.81 2.73 2.0425 2.230 2.4375
## 
## Alpha: 0.05 ; DF Error: 8 
## 
## Critical Range
##         2         3         4 
## 0.9317762 0.9709988 0.9929221 
## 
## Means with the same letter are not significantly different.
## 
##    datos$pesofresco groups
## T1            5.070      a
## T4            2.250      b
## T2            2.245      b
## T3            1.905      b

muestreo 2

library(readxl)
library(outliers)
datos = read_excel("//cloud//project//pesofrescopa2.xlsx", sheet = 1)
tratamiento<- as.factor(datos$tratamiento)
bloque<- as.factor(datos$bloque)
sujeto<- as.factor(datos$sujeto)
dca2<-aov(datos$pesofresco2~tratamiento+bloque+Error(sujeto)) 
dca2
## 
## Call:
## aov(formula = datos$pesofresco2 ~ tratamiento + bloque + Error(sujeto))
## 
## Grand Mean: 3.498125
## 
## Stratum 1: sujeto
## 
## Terms:
##                 tratamiento   bloque Residuals
## Sum of Squares     42.10867  0.07426   1.73647
## Deg. of Freedom           3        1         3
## 
## Residual standard error: 0.7608041
## Estimated effects may be unbalanced
## 
## Stratum 2: Within
## 
## Terms:
##                 Residuals
## Sum of Squares    5.60625
## Deg. of Freedom         8
## 
## Residual standard error: 0.8371268
summary(dca2)
## 
## Error: sujeto
##             Df Sum Sq Mean Sq F value Pr(>F)  
## tratamiento  3  42.11  14.036  24.250 0.0132 *
## bloque       1   0.07   0.074   0.128 0.7439  
## Residuals    3   1.74   0.579                 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Error: Within
##           Df Sum Sq Mean Sq F value Pr(>F)
## Residuals  8  5.606  0.7008
x <-dca2$sujeto$residuals  
y <-dca2$Within$residuals

sc.error.a <-sum(x^2)       #SUMA DE CUADRADOS DEL ERROR EXPERIMENTAL
sc.error.b <-sum(y^2)       #SUMA DE CUADRADOS DEL ERROR MUESTRAL

format(x, big.mark = ",")
##            2            3            4            5            6            7 
## "-0.0337500" "-0.1133050" " 0.1602375" " 0.6316650" "-0.7736284" "-0.5474541" 
##            8 
## " 0.6321456"
dca3<-aov(datos$pesofresco2~tratamiento+bloque+sujeto%in%bloque%in%tratamiento)
summary(dca3)
##                           Df Sum Sq Mean Sq F value   Pr(>F)    
## tratamiento                3  42.11  14.036  20.029 0.000446 ***
## bloque                     1   0.07   0.074   0.106 0.753140    
## tratamiento:bloque:sujeto  3   1.74   0.579   0.826 0.515609    
## Residuals                  8   5.61   0.701                     
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
mod2 = aov(datos$pesofresco2 ~ tratamiento*bloque, datos)
sum2<-summary(mod1)
sum2 <- unlist(sum1)
sum2 = sum1[9]
summary(mod2)
##                    Df Sum Sq Mean Sq F value   Pr(>F)    
## tratamiento         3  42.11  14.036  20.029 0.000446 ***
## bloque              1   0.07   0.074   0.106 0.753140    
## tratamiento:bloque  3   1.74   0.579   0.826 0.515609    
## Residuals           8   5.61   0.701                     
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
TukeyHSD(mod2, "tratamiento")
## Warning in replications(paste("~", xx), data = mf): non-factors ignored: bloque
## Warning in replications(paste("~", xx), data = mf): non-factors ignored:
## tratamiento, bloque
##   Tukey multiple comparisons of means
##     95% family-wise confidence level
## 
## Fit: aov(formula = datos$pesofresco2 ~ tratamiento * bloque, data = datos)
## 
## $tratamiento
##          diff        lwr       upr     p adj
## T2-T1 -4.2950 -6.1905939 -2.399406 0.0004007
## T3-T1 -3.2275 -5.1230939 -1.331906 0.0026986
## T4-T1 -3.3450 -5.2405939 -1.449406 0.0021477
## T3-T2  1.0675 -0.8280939  2.963094 0.3382784
## T4-T2  0.9500 -0.9455939  2.845594 0.4275581
## T4-T3 -0.1175 -2.0130939  1.778094 0.9969979
library(agricolae)
duncan.test(mod2, 'tratamiento', console = T)
## 
## Study: mod2 ~ "tratamiento"
## 
## Duncan's new multiple range test
## for datos$pesofresco2 
## 
## Mean Square Error:  0.7007813 
## 
## tratamiento,  means
## 
##    datos.pesofresco2       std r        se  Min  Max    Q25   Q50    Q75
## T1            6.2150 1.1816514 4 0.4185634 5.10 7.50 5.2725 6.130 7.0725
## T2            1.9200 0.1293574 4 0.4185634 1.81 2.08 1.8175 1.895 1.9975
## T3            2.9875 0.7403321 4 0.4185634 2.10 3.83 2.5800 3.010 3.4175
## T4            2.8700 0.7149825 4 0.4185634 2.25 3.89 2.4750 2.670 3.0650
## 
## Alpha: 0.05 ; DF Error: 8 
## 
## Critical Range
##        2        3        4 
## 1.365012 1.422471 1.454588 
## 
## Means with the same letter are not significantly different.
## 
##    datos$pesofresco2 groups
## T1            6.2150      a
## T3            2.9875      b
## T4            2.8700      b
## T2            1.9200      b

Muestreo 3

library(readxl)
library(outliers)
datos = read_excel("//cloud//project//pesofrescopa2.xlsx", sheet = 1)
tratamiento<- as.factor(datos$tratamiento)
bloque<- as.factor(datos$bloque)
sujeto<- as.factor(datos$sujeto)
dca2<-aov(datos$pesofresco2~tratamiento+bloque+Error(sujeto)) 
dca2
## 
## Call:
## aov(formula = datos$pesofresco2 ~ tratamiento + bloque + Error(sujeto))
## 
## Grand Mean: 3.498125
## 
## Stratum 1: sujeto
## 
## Terms:
##                 tratamiento   bloque Residuals
## Sum of Squares     42.10867  0.07426   1.73647
## Deg. of Freedom           3        1         3
## 
## Residual standard error: 0.7608041
## Estimated effects may be unbalanced
## 
## Stratum 2: Within
## 
## Terms:
##                 Residuals
## Sum of Squares    5.60625
## Deg. of Freedom         8
## 
## Residual standard error: 0.8371268
summary(dca2)
## 
## Error: sujeto
##             Df Sum Sq Mean Sq F value Pr(>F)  
## tratamiento  3  42.11  14.036  24.250 0.0132 *
## bloque       1   0.07   0.074   0.128 0.7439  
## Residuals    3   1.74   0.579                 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Error: Within
##           Df Sum Sq Mean Sq F value Pr(>F)
## Residuals  8  5.606  0.7008
x <-dca2$sujeto$residuals  
y <-dca2$Within$residuals

sc.error.a <-sum(x^2)       #SUMA DE CUADRADOS DEL ERROR EXPERIMENTAL
sc.error.b <-sum(y^2)       #SUMA DE CUADRADOS DEL ERROR MUESTRAL

format(x, big.mark = ",")
##            2            3            4            5            6            7 
## "-0.0337500" "-0.1133050" " 0.1602375" " 0.6316650" "-0.7736284" "-0.5474541" 
##            8 
## " 0.6321456"
dca3<-aov(datos$pesofresco2~tratamiento+bloque+sujeto%in%bloque%in%tratamiento)
summary(dca3)
##                           Df Sum Sq Mean Sq F value   Pr(>F)    
## tratamiento                3  42.11  14.036  20.029 0.000446 ***
## bloque                     1   0.07   0.074   0.106 0.753140    
## tratamiento:bloque:sujeto  3   1.74   0.579   0.826 0.515609    
## Residuals                  8   5.61   0.701                     
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
mod2 = aov(datos$pesofresco2 ~ tratamiento*bloque, datos)
sum2<-summary(mod1)
sum2 <- unlist(sum1)
sum2 = sum1[9]
summary(mod2)
##                    Df Sum Sq Mean Sq F value   Pr(>F)    
## tratamiento         3  42.11  14.036  20.029 0.000446 ***
## bloque              1   0.07   0.074   0.106 0.753140    
## tratamiento:bloque  3   1.74   0.579   0.826 0.515609    
## Residuals           8   5.61   0.701                     
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
TukeyHSD(mod2, "tratamiento")
## Warning in replications(paste("~", xx), data = mf): non-factors ignored: bloque
## Warning in replications(paste("~", xx), data = mf): non-factors ignored:
## tratamiento, bloque
##   Tukey multiple comparisons of means
##     95% family-wise confidence level
## 
## Fit: aov(formula = datos$pesofresco2 ~ tratamiento * bloque, data = datos)
## 
## $tratamiento
##          diff        lwr       upr     p adj
## T2-T1 -4.2950 -6.1905939 -2.399406 0.0004007
## T3-T1 -3.2275 -5.1230939 -1.331906 0.0026986
## T4-T1 -3.3450 -5.2405939 -1.449406 0.0021477
## T3-T2  1.0675 -0.8280939  2.963094 0.3382784
## T4-T2  0.9500 -0.9455939  2.845594 0.4275581
## T4-T3 -0.1175 -2.0130939  1.778094 0.9969979
library(agricolae)
duncan.test(mod2, 'tratamiento', console = T)
## 
## Study: mod2 ~ "tratamiento"
## 
## Duncan's new multiple range test
## for datos$pesofresco2 
## 
## Mean Square Error:  0.7007813 
## 
## tratamiento,  means
## 
##    datos.pesofresco2       std r        se  Min  Max    Q25   Q50    Q75
## T1            6.2150 1.1816514 4 0.4185634 5.10 7.50 5.2725 6.130 7.0725
## T2            1.9200 0.1293574 4 0.4185634 1.81 2.08 1.8175 1.895 1.9975
## T3            2.9875 0.7403321 4 0.4185634 2.10 3.83 2.5800 3.010 3.4175
## T4            2.8700 0.7149825 4 0.4185634 2.25 3.89 2.4750 2.670 3.0650
## 
## Alpha: 0.05 ; DF Error: 8 
## 
## Critical Range
##        2        3        4 
## 1.365012 1.422471 1.454588 
## 
## Means with the same letter are not significantly different.
## 
##    datos$pesofresco2 groups
## T1            6.2150      a
## T3            2.9875      b
## T4            2.8700      b
## T2            1.9200      b