Performing a Two-Way ANOVA with Blocks using R Studio
I’ll upload one data in R.
install.packages("readr")
library (readr)
github="https://raw.githubusercontent.com/agronomy4future/r_code/main/corn_grain_yield.csv"
dataA=data.frame(read_csv(url(github),show_col_types = FALSE))
variety reps nitrogen grain_yield
1 CV1 1 N1 16.59
2 CV1 2 N1 16.59
3 CV1 3 N1 15.91
4 CV1 4 N1 17.57
5 CV1 5 N1 16.40
6 CV1 6 N1 16.20
7 CV1 7 N1 18.45
8 CV1 8 N1 14.35
9 CV1 9 N1 13.27
10 CV1 10 N1 16.15
.
.
.
I have 10 corn varieties and want to analyze the impact of nitrogen treatments (N0 and N1), variety, and their interaction on grain yield. Since replicates are considered as blocks, I will conduct a two-way ANOVA analysis with blocks as the statistical model.
The statistical model for two-way ANOVA with blocks is as follows:
yijk = μ + αi + βj + δij + γk + εijk where yijk: observed values for treatment (ij; i = factor 1, j = factor 2) and replicates (k) μ: grand mean of observed values αi: treatment effect of factor 1 βj: treatment effect of factor 2 δij: interaction effect between factor 1 (i) and factor 2 (j) γk: block effect εijk: residuals
Based on the statistical model for two-way ANOVA with blocks, we can conduct the analysis using R. Below is an example code:
anova2way= aov (grain_yield ~ nitrogen + variety + nitrogen:variety + factor(reps), data=dataA)
summary(anova2way)
Df Sum Sq Mean Sq F value Pr(>F)
nitrogen 1 41.93 41.93 50.352 3.27e-11 ***
variety 9 134.23 14.91 17.912 < 2e-16 ***
factor(reps) 9 9.38 1.04 1.252 0.267
nitrogen:variety 9 150.41 16.71 20.072 < 2e-16 ***
Residuals 171 142.38 0.83
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
© 2022 – 2023 https://agronomy4future.com