ANOVA de una vía, problema del cultivo. La pregunta de investigación es si el tipo de semilla, o el fertilizante, o ambos, tienen impacto en el crecimiento del cultivo.
El problema es como mejorar el rendimiento del cultivo (Growth) y hay duda razonable de que el tipo de semilla, el fertilizante, o ambos, afecten dicho rendimiento; por lo tanto, un experimento que involucre ambos factores (semilla y fertilizante) y que mida el crecimiento (growth) relacionado con cada combinación daría información útil.
¿El fertilizante y el tipo de semilla afectan el rendimiento del cultivo?
El fertilizante interactúa con la semilla incrementando el redimiento.
Las hipótesis estadísticas que representan esta pregunta pueden ser:
\(H0: \mu_{A402}=\mu_{B894}=\mu_{C9652}\)
# Tabla de datos (stacked)
Semilla <- as.factor(c("A402","B894","C9652","A402","B894","C9652",
"A402","B894","C9652","A402","B894","C9652","A402","B894","C9652"))
Fert <- as.factor(c(1,1,1,2,2,2,3,3,3,4,4,4,5,5,5))
Growth <- c(106,110,95,95,99,87,94,100,99,103,104,99,100,105,95)
Crops <- data.frame(Semilla,Fert,Growth)
Crops
m1 <- lm(Growth~Semilla,Crops)
m2 <- lm(Growth~Fert,Crops)
anova (m1)
Analysis of Variance Table
Response: Growth
Df Sum Sq Mean Sq F value Pr(>F)
Semilla 2 185.2 92.6 3.9914 0.0469 *
Residuals 12 278.4 23.2
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
anova (m2)
Analysis of Variance Table
Response: Growth
Df Sum Sq Mean Sq F value Pr(>F)
Fert 4 183.6 45.9 1.6393 0.2395
Residuals 10 280.0 28.0
m3 <- lm(Growth~Semilla:Fert+Semilla+Fert,Crops)
anova (m3)
Warning in anova.lm(m3) :
ANOVA F-tests on an essentially perfect fit are unreliable
Analysis of Variance Table
Response: Growth
Df Sum Sq Mean Sq F value Pr(>F)
Semilla 2 185.2 92.60 NaN NaN
Fert 4 183.6 45.90 NaN NaN
Semilla:Fert 8 94.8 11.85 NaN NaN
Residuals 0 0.0 NaN
m4 <- lm(Growth~Semilla+Fert,Crops)
anova (m4) #Anova tipo I
Analysis of Variance Table
Response: Growth
Df Sum Sq Mean Sq F value Pr(>F)
Semilla 2 185.2 92.60 7.8143 0.01314 *
Fert 4 183.6 45.90 3.8734 0.04891 *
Residuals 8 94.8 11.85
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
summary (m4)
Call:
lm(formula = Growth ~ Semilla + Fert, data = Crops)
Residuals:
Min 1Q Median 3Q Max
-4.267 -2.033 0.800 1.267 5.733
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 103.867 2.352 44.169 7.62e-11 ***
SemillaB894 4.000 2.177 1.837 0.10348
SemillaC9652 -4.600 2.177 -2.113 0.06757 .
Fert2 -10.000 2.811 -3.558 0.00742 **
Fert3 -6.000 2.811 -2.135 0.06531 .
Fert4 -1.667 2.811 -0.593 0.56958
Fert5 -3.667 2.811 -1.305 0.22833
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 3.442 on 8 degrees of freedom
Multiple R-squared: 0.7955, Adjusted R-squared: 0.6421
F-statistic: 5.187 on 6 and 8 DF, p-value: 0.01838
library (car)
Anova(m4, type="II")
Anova Table (Type II tests)
Response: Growth
Sum Sq Df F value Pr(>F)
Semilla 185.2 2 7.8143 0.01314 *
Fert 183.6 4 3.8734 0.04891 *
Residuals 94.8 8
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Anova(m4, type="III")
Anova Table (Type III tests)
Response: Growth
Sum Sq Df F value Pr(>F)
(Intercept) 23117.8 1 1950.8652 7.619e-11 ***
Semilla 185.2 2 7.8143 0.01314 *
Fert 183.6 4 3.8734 0.04891 *
Residuals 94.8 8
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
library (effects) #Graficar intervalos descriptivos
plot (allEffects(m4))
allEffects(m4)
model: Growth ~ Semilla + Fert
Semilla effect
Semilla
A402 B894 C9652
99.6 103.6 95.0
Fert effect
Fert
1 2 3 4 5
103.66667 93.66667 97.66667 102.00000 100.00000
# Verificar la normalidad de los residuos con el algoritmo de Shapiro
plot(m4,2)
shapiro.test(residuals(m4))
Shapiro-Wilk normality test
data: residuals(m4)
W = 0.95396, p-value = 0.5889
Resumen de estadísticos descriptivos para la Semilla
library(dplyr)
group_by(Crops, Semilla) %>%
summarise(
count = n(),
mean = mean(Growth, na.rm = TRUE),
sd = sd(Growth, na.rm = TRUE)
)
Ejercicio 1. Calcula los estadísticos descriptivos del Fertilizante.
library(dplyr)
group_by(Crops, Fert) %>%
summarise(
count = n(),
mean = mean(Growth, na.rm = TRUE),
sd = sd(Growth, na.rm = TRUE)
)
Verificar el supuesto de homogeneidad de las varianzas.
bartlett.test(Growth~Fert,Crops)
Bartlett test of homogeneity of variances
data: Growth by Fert
Bartlett's K-squared = 2.4018, df = 4, p-value = 0.6623
bartlett.test(Growth~Semilla,Crops)
Bartlett test of homogeneity of variances
data: Growth by Semilla
Bartlett's K-squared = 0.089024, df = 2, p-value = 0.9565