Skip to contents

Analysis of variance for a two-factor factorial experiment in a randomized complete block design (when replication is given) or a completely randomized design, with SEm, SEd and CD for both main effects and the interaction, and letter groupings for factor means and treatment combinations.

Usage

anova_factorial(
  data,
  response,
  factor1,
  factor2,
  replication = NULL,
  posthoc = "lsd",
  alpha = 0.05,
  verbose = TRUE
)

Arguments

data

Data frame containing the data.

response

Name of the response variable.

factor1

Name of the first factor (A).

factor2

Name of the second factor (B).

replication

Name of the replication (block) column, or NULL for a completely randomized layout.

posthoc

Post-hoc method for the letters (see perform_posthoc). Default "lsd".

alpha

Significance level for CD and letters. Default 0.05.

verbose

Logical. If TRUE (default), prints the report.

Value

An object of class aridagri_factorial with anova_table, model, grand_mean, cv, ms_error, df_error, comparisons (SEm, SEd and CD for A, B and A x B), se_a, cd_a, se_b, cd_b, se_ab, cd_ab, mean_a, mean_b (with letters), interaction_means (all combinations with letters), mean_ab (two-way table) and posthoc.

Author

Lalit Kumar Rolaniya, ICAR-IIPR, Bikaner

Examples

data <- expand.grid(rep = 1:4, nitrogen = c("N0", "N40", "N80"),
                    phosphorus = c("P0", "P30"))
set.seed(1)
data$yield <- 900 + 3 * as.numeric(sub("N", "", data$nitrogen)) +
  2 * as.numeric(sub("P", "", data$phosphorus)) + rnorm(nrow(data), 0, 40)
res <- anova_factorial(data, response = "yield", factor1 = "nitrogen",
                       factor2 = "phosphorus", replication = "rep")
#> 
#> ======================================================================
#>  TWO-FACTOR FACTORIAL (RCBD)
#> ======================================================================
#>  Response     : yield
#>  Factor A     : nitrogen
#>  Factor B     : phosphorus
#>  Observations : 24
#> 
#>  Analysis of variance
#>               Source Df    Sum Sq   Mean Sq F value Pr(>F)    
#>  rep                  3   2910.24    970.08   0.545 0.6588  NS
#>  nitrogen             2 265228.51 132614.26  74.540 0.0000 ***
#>  phosphorus           1  15300.49  15300.49   8.600 0.0103   *
#>  nitrogen:phosphorus  2   1973.02    986.51   0.554 0.5857  NS
#>  Error               15  26686.66   1779.11                   
#>  Total               23 312098.91                             
#>  Signif. codes: *** p < 0.001, ** p < 0.01, * p < 0.05, NS not significant
#> 
#>  Grand mean = 1055.995   CV = 3.99%
#> 
#>  SE and CD (alpha = 0.05)
#>                 Effect Obs_per_mean    SEm    SEd     CD
#>               nitrogen            8 14.913 21.090 44.952
#>             phosphorus           12 12.176 17.220 36.703
#>  nitrogen x phosphorus            4 21.090 29.825 63.571
#> 
#>  Means of nitrogen (Fisher's LSD)
#>  Level    Mean     SE Obs Group
#>     N0  922.80 14.913   8     c
#>    N40 1065.39 14.913   8     b
#>    N80 1179.79 14.913   8     a
#> 
#>  Means of phosphorus (Fisher's LSD)
#>  Level    Mean     SE Obs Group
#>     P0 1030.75 12.176  12     b
#>    P30 1081.24 12.176  12     a
#> 
#>  Treatment combinations (Fisher's LSD)
#>  nitrogen phosphorus    Mean     SE Obs Group
#>        N0         P0  903.17 21.090   4     d
#>       N40         P0 1027.35 21.090   4     c
#>       N80         P0 1161.72 21.090   4    ab
#>        N0        P30  942.44 21.090   4     d
#>       N40        P30 1103.43 21.090   4     b
#>       N80        P30 1197.86 21.090   4     a
res$interaction_means
#>   nitrogen phosphorus      Mean       SE Obs Group
#> 1       N0         P0  903.1684 21.08975   4     d
#> 2      N40         P0 1027.3479 21.08975   4     c
#> 3      N80         P0 1161.7202 21.08975   4    ab
#> 4       N0        P30  942.4406 21.08975   4     d
#> 5      N40        P30 1103.4277 21.08975   4     b
#> 6      N80        P30 1197.8633 21.08975   4     a