set.seed(22)
# area de daño foliar
area = c(rnorm(18, 3, 0.8),
rnorm(6, 0.2, 0.05))
inoculo = gl(4, 6, 24, paste0('D', 0:3))
dt = data.frame(area = round(sort(area), 3),
inoculo)
View(dt)
boxplot(dt$area~dt$inoculo)
\[H_0: \mu_{D0} = \mu_{D1}= \cdots = \mu_{D3}\]
mod_1 = aov (dt$area~dt$inoculo)
tb=summary(mod_1)
ifelse(unlist(tb)[9]<0.05,"Rechazo Ho", "No rechazo")
## Pr(>F)1
## "Rechazo Ho"
TukeyHSD(x=mod_1)
## Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = dt$area ~ dt$inoculo)
##
## $`dt$inoculo`
## diff lwr upr p adj
## D1-D0 2.3715000 1.84876038 2.894240 0.0000000
## D2-D0 2.8731667 2.35042705 3.395906 0.0000000
## D3-D0 4.0190000 3.49626038 4.541740 0.0000000
## D2-D1 0.5016667 -0.02107295 1.024406 0.0628165
## D3-D1 1.6475000 1.12476038 2.170240 0.0000001
## D3-D2 1.1458333 0.62309372 1.668573 0.0000299
\[y_{ij} = \mu + \tau_i + \epsilon_{ij}\] \[i=1,2,3,4~(inoculo)\] \[j=1,2,\cdots,6~(repeticiones)\]
\[H_0:~los~residuales~del~modelo~tienen~distribucion~normal\]
res=mod_1$residuals
res
## 1 2 3 4 5 6
## -0.056166667 -0.027166667 -0.009166667 -0.004166667 0.024833333 0.071833333
## 7 8 9 10 11 12
## -0.284666667 -0.180666667 -0.157666667 0.043333333 0.286333333 0.293333333
## 13 14 15 16 17 18
## -0.178333333 -0.115333333 -0.101333333 0.017666667 0.185666667 0.191666667
## 19 20 21 22 23 24
## -0.600166667 -0.505166667 -0.388166667 0.291833333 0.407833333 0.793833333
n=shapiro.test(res)
\[var~D_0 = var~D1 = \cdots = var~D4\]
bartlett.test(dt$area~dt$inoculo)
##
## Bartlett test of homogeneity of variances
##
## data: dt$area by dt$inoculo
## Bartlett's K-squared = 22.055, df = 3, p-value = 6.355e-05
Rechazo Ho, varianzas por grupo son distintas … No se cumple el supuesto de homocedasticidad …
mod_2 = oneway.test(dt$area~dt$inoculo)
mod_2
##
## One-way analysis of means (not assuming equal variances)
##
## data: dt$area and dt$inoculo
## F = 727.7, num df = 3.0000, denom df = 8.8951, p-value = 5.925e-11
kruskal.test(dt$area~dt$inoculo)
##
## Kruskal-Wallis rank sum test
##
## data: dt$area by dt$inoculo
## Kruskal-Wallis chi-squared = 21.6, df = 3, p-value = 7.9e-05
library(RVAideMemoire)
## *** Package RVAideMemoire v 0.9-81-2 ***
RVAideMemoire::perm.anova(dt$area~dt$inoculo, nperm =5000)
##
|
| | 0%
|
|= | 1%
|
|= | 2%
|
|== | 3%
|
|=== | 4%
|
|==== | 5%
|
|==== | 6%
|
|===== | 7%
|
|====== | 8%
|
|====== | 9%
|
|======= | 10%
|
|======== | 11%
|
|======== | 12%
|
|========= | 13%
|
|========== | 14%
|
|========== | 15%
|
|=========== | 16%
|
|============ | 17%
|
|============= | 18%
|
|============= | 19%
|
|============== | 20%
|
|=============== | 21%
|
|=============== | 22%
|
|================ | 23%
|
|================= | 24%
|
|================== | 25%
|
|================== | 26%
|
|=================== | 27%
|
|==================== | 28%
|
|==================== | 29%
|
|===================== | 30%
|
|====================== | 31%
|
|====================== | 32%
|
|======================= | 33%
|
|======================== | 34%
|
|======================== | 35%
|
|========================= | 36%
|
|========================== | 37%
|
|=========================== | 38%
|
|=========================== | 39%
|
|============================ | 40%
|
|============================= | 41%
|
|============================= | 42%
|
|============================== | 43%
|
|=============================== | 44%
|
|================================ | 45%
|
|================================ | 46%
|
|================================= | 47%
|
|================================== | 48%
|
|================================== | 49%
|
|=================================== | 50%
|
|==================================== | 51%
|
|==================================== | 52%
|
|===================================== | 53%
|
|====================================== | 54%
|
|====================================== | 55%
|
|======================================= | 56%
|
|======================================== | 57%
|
|========================================= | 58%
|
|========================================= | 59%
|
|========================================== | 60%
|
|=========================================== | 61%
|
|=========================================== | 62%
|
|============================================ | 63%
|
|============================================= | 64%
|
|============================================== | 65%
|
|============================================== | 66%
|
|=============================================== | 67%
|
|================================================ | 68%
|
|================================================ | 69%
|
|================================================= | 70%
|
|================================================== | 71%
|
|================================================== | 72%
|
|=================================================== | 73%
|
|==================================================== | 74%
|
|==================================================== | 75%
|
|===================================================== | 76%
|
|====================================================== | 77%
|
|======================================================= | 78%
|
|======================================================= | 79%
|
|======================================================== | 80%
|
|========================================================= | 81%
|
|========================================================= | 82%
|
|========================================================== | 83%
|
|=========================================================== | 84%
|
|============================================================ | 85%
|
|============================================================ | 86%
|
|============================================================= | 87%
|
|============================================================== | 88%
|
|============================================================== | 89%
|
|=============================================================== | 90%
|
|================================================================ | 91%
|
|================================================================ | 92%
|
|================================================================= | 93%
|
|================================================================== | 94%
|
|================================================================== | 95%
|
|=================================================================== | 96%
|
|==================================================================== | 97%
|
|===================================================================== | 98%
|
|===================================================================== | 99%
|
|======================================================================| 100%
## Permutation Analysis of Variance Table
##
## Response: dt$area
## 5000 permutations
## Sum Sq Df Mean Sq F value Pr(>F)
## dt$inoculo 51.465 3 17.1552 163.94 2e-04 ***
## Residuals 2.093 20 0.1046
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
dt_2 = dt
dt_2$area[15]=NA
library(car)
## Loading required package: carData
mod_5= Anova(lm(dt_2$area~dt_2$inoculo), type ="II")
mod_5
## Anova Table (Type II tests)
##
## Response: dt_2$area
## Sum Sq Df F value Pr(>F)
## dt_2$inoculo 51.261 3 156.04 1.464e-13 ***
## Residuals 2.081 19
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1