DiseƱo Parcelas Dividas

library(readxl)
## Warning: package 'readxl' was built under R version 4.0.5
df = Datos_Tarea_Abril_10 <- read_excel("D:/Users/Usuario/Desktop/Trabajos Diseno/Datos Tarea Abril 10.xlsx");df 
## # A tibble: 72 x 4
##    Nitrogeno Variedad Repeticion Rendimiento
##        <dbl> <chr>    <chr>            <dbl>
##  1         0 IR8      I                 4.43
##  2         0 IR8      II                4.48
##  3         0 IR8      III               3.85
##  4         0 IR5      I                 3.94
##  5         0 IR5      II                5.31
##  6         0 IR5      III               3.66
##  7         0 C4 - 63  I                 3.46
##  8         0 C4 - 63  II                2.94
##  9         0 C4 - 63  III               3.14
## 10         0 Peta     I                 4.13
## # ... with 62 more rows
Nivel=Datos_Tarea_Abril_10$Nitrogeno
Nivel=as.factor(Nivel)
Var=Datos_Tarea_Abril_10$Variedad
Rep=Datos_Tarea_Abril_10$Repeticion
Rep = as.factor(Rep)
Rend=Datos_Tarea_Abril_10$Rendimiento
library(collapsibleTree)
collapsibleTreeSummary(df, hierarchy = c('Nitrogeno','Variedad', 'Repeticion', 'Rendimiento'))
library(lattice)
bwplot(Rend~Var|Nivel+Rep,Datos_Tarea_Abril_10,xlab="",pch=20)

medias = tapply(Rend, list(Var,Nivel),mean); medias
##                0       60    90      120      150      180
## C4 - 63 3.183333 5.442667 5.994 6.014000 6.687333 6.065333
## IR5     4.306000 5.982000 6.259 6.895000 6.950667 6.540333
## IR8     4.252667 5.672000 6.400 6.732667 7.563333 8.700667
## Peta    4.481333 4.816000 4.812 3.816000 2.046667 1.880667
desviacion = tapply(Rend, list(Var,Nivel),sd); desviacion
##                 0        60        90       120       150       180
## C4 - 63 0.2624525 0.6257454 0.2605763 0.3114290 0.3806328 0.9168737
## IR5     0.8844275 0.4704211 0.3369822 0.2972087 0.6334172 0.7415891
## IR8     0.3495445 0.6701313 0.3144773 0.3004818 0.2791726 0.2154654
## Peta    0.3550005 0.3265088 0.8315455 1.1414570 0.6801539 0.4490984
cv = (desviacion*100)/medias; cv
##                 0        60        90       120       150       180
## C4 - 63  8.244582 11.497037  4.347285  5.178400  5.691847 15.116625
## IR5     20.539422  7.863943  5.383962  4.310496  9.113042 11.338704
## IR8      8.219418 11.814727  4.913709  4.463043  3.691132  2.476424
## Peta     7.921760  6.779668 17.280664 29.912394 33.232275 23.879742

#Analisis de Varanza

mod_ParcelasDiv= aov(Rend ~ Var*Nivel + Error(Rep:Var),data = df)
## Warning in aov(Rend ~ Var * Nivel + Error(Rep:Var), data = df): Error() model is
## singular
summary(mod_ParcelasDiv)
## 
## Error: Rep:Var
##           Df Sum Sq Mean Sq F value   Pr(>F)    
## Var        3  89.89  29.963   106.6 8.66e-07 ***
## Residuals  8   2.25   0.281                     
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Error: Within
##           Df Sum Sq Mean Sq F value   Pr(>F)    
## Nivel      5  30.43   6.086   18.96 1.25e-09 ***
## Var:Nivel 15  69.34   4.623   14.40 1.21e-11 ***
## Residuals 40  12.84   0.321                     
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
mod_2 = aov(Rend ~ Var*Nivel + Rep:Var,data = df)
summary(mod_2)
##             Df Sum Sq Mean Sq F value   Pr(>F)    
## Var          3  89.89  29.963  93.359  < 2e-16 ***
## Nivel        5  30.43   6.086  18.962 1.25e-09 ***
## Var:Nivel   15  69.34   4.623  14.404 1.21e-11 ***
## Var:Rep      8   2.25   0.281   0.876    0.545    
## Residuals   40  12.84   0.321                     
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

#Analisis de Medias

library(agricolae)
## Warning: package 'agricolae' was built under R version 4.0.5
HSD_test = with(df, HSD.test (Rend, Nivel
          , DFerror = 40,MSerror = 0.321));HSD_test
## $statistics
##   MSerror Df     Mean       CV       MSD
##     0.321 40 5.478903 10.34091 0.6921034
## 
## $parameters
##    test name.t ntr StudentizedRange alpha
##   Tukey  Nivel   6         4.231644  0.05
## 
## $means
##         Rend       std  r   Min   Max    Q25   Q50     Q75
## 0   4.055833 0.6960603 12 2.944 5.314 3.6110 4.035 4.47900
## 120 5.864417 1.3902291 12 2.774 7.139 5.6030 6.416 6.75550
## 150 5.812000 2.3373706 12 1.414 7.848 5.4315 6.628 7.35550
## 180 5.796750 2.6364221 12 1.380 8.832 4.6720 6.117 7.65325
## 60  5.478167 0.6417666 12 4.604 6.502 5.0665 5.487 5.89450
## 90  5.866250 0.7771952 12 4.146 6.704 5.7390 6.045 6.28800
## 
## $comparison
## NULL
## 
## $groups
##         Rend groups
## 90  5.866250      a
## 120 5.864417      a
## 150 5.812000      a
## 180 5.796750      a
## 60  5.478167      a
## 0   4.055833      b
## 
## attr(,"class")
## [1] "group"
HSD_test = with(df, HSD.test (Rend, Var, DFerror = 40,MSerror = 0.321));HSD_test
## $statistics
##   MSerror Df     Mean       CV       MSD
##     0.321 40 5.478903 10.34091 0.5062138
## 
## $parameters
##    test name.t ntr StudentizedRange alpha
##   Tukey    Var   4         3.790685  0.05
## 
## $means
##             Rend      std  r   Min   Max    Q25   Q50    Q75
## C4 - 63 5.564444 1.235991 18 2.944 7.122 5.4990 5.836 6.3010
## IR5     6.155500 1.048227 18 3.660 7.682 5.8950 6.365 6.6300
## IR8     6.553556 1.476074 18 3.850 8.832 5.5825 6.571 7.4865
## Peta    3.642111 1.396858 18 1.380 5.744 2.3775 4.136 4.6400
## 
## $comparison
## NULL
## 
## $groups
##             Rend groups
## IR8     6.553556      a
## IR5     6.155500      a
## C4 - 63 5.564444      b
## Peta    3.642111      c
## 
## attr(,"class")
## [1] "group"

#Evaluación de Supuestos

TukeyHSD(mod_2, "Nivel");TukeyHSD
##   Tukey multiple comparisons of means
##     95% family-wise confidence level
## 
## Fit: aov(formula = Rend ~ Var * Nivel + Rep:Var, data = df)
## 
## $Nivel
##                 diff        lwr       upr     p adj
## 60-0     1.422333333  0.7302935 2.1143732 0.0000042
## 90-0     1.810416667  1.1183768 2.5024565 0.0000000
## 120-0    1.808583333  1.1165435 2.5006232 0.0000000
## 150-0    1.756166667  1.0641268 2.4482065 0.0000000
## 180-0    1.740916667  1.0488768 2.4329565 0.0000001
## 90-60    0.388083333 -0.3039565 1.0801232 0.5537702
## 120-60   0.386250000 -0.3057898 1.0782898 0.5588036
## 150-60   0.333833333 -0.3582065 1.0258732 0.7008666
## 180-60   0.318583333 -0.3734565 1.0106232 0.7398849
## 120-90  -0.001833333 -0.6938732 0.6902065 1.0000000
## 150-90  -0.054250000 -0.7462898 0.6377898 0.9998948
## 180-90  -0.069500000 -0.7615398 0.6225398 0.9996448
## 150-120 -0.052416667 -0.7444565 0.6396232 0.9999112
## 180-120 -0.067666667 -0.7597065 0.6243732 0.9996883
## 180-150 -0.015250000 -0.7072898 0.6767898 0.9999998
## function (x, which, ordered = FALSE, conf.level = 0.95, ...) 
## UseMethod("TukeyHSD")
## <bytecode: 0x0000000013a67db0>
## <environment: namespace:stats>
shapiro.test(mod_2$residuals)
## 
##  Shapiro-Wilk normality test
## 
## data:  mod_2$residuals
## W = 0.96954, p-value = 0.07792
plot(mod_2,1)

plot(mod_2,2)