Performs a within-environment analysis of variance in randomized complete block or alpha-lattice designs and returns values such as Mean Squares, p-values, coefficient of variation, heritability, and accuracy of selection.

## Arguments

- .data
The dataset containing the columns related to Environments, Genotypes, replication/block and response variable(s).

- env
The name of the column that contains the levels of the environments. The analysis of variance is computed for each level of this factor.

- gen
The name of the column that contains the levels of the genotypes.

- rep
The name of the column that contains the levels of the replications/blocks.

- resp
The response variable(s). To analyze multiple variables in a single procedure a vector of variables may be used. For example

`resp = c(var1, var2, var3)`

.- block
Defaults to

`NULL`

. In this case, a randomized complete block design is considered. If block is informed, then a resolvable alpha-lattice design (Patterson and Williams, 1976) is employed.**All effects, except the error, are assumed to be fixed.**- verbose
Logical argument. If

`verbose = FALSE`

the code will run silently.

## Value

A list where each element is the result for one variable containing
(1) **individual**: A tidy tbl_df with the results of the individual
analysis of variance with the following column names, and (2) **MSRatio**:
The ratio between the higher and lower residual mean square. The following
columns are returned, depending on the experimental design

**For analysis in alpha-lattice designs**:`MEAN`

: The grand mean.`DFG, DFCR, and DFIB_R, and DFE`

: The degree of freedom for genotype, complete replicates, incomplete blocks within replicates, and error, respectively.`MSG, MSCR, MSIB_R`

: The mean squares for genotype, replicates, incomplete blocks within replicates, and error, respectively.`FCG, FCR, FCIB_R`

: The F-calculated for genotype, replicates and incomplete blocks within replicates, respectively.`PFG, PFCR, PFIB_R`

: The P-values for genotype, replicates and incomplete blocks within replicates, respectively.`CV`

: coefficient of variation.`h2`

: broad-sense heritability.`AS`

: accuracy of selection (square root of`h2`

)

**For analysis in randomized complete block design**:`MEAN`

: The grand mean.`DFG, DFB, and DFE`

: The degree of freedom for genotype blocks, and error, respectively.`MSG, MSB, and MSE`

: The mean squares for genotype blocks, and error, respectively.`FCG and FCB`

: The F-calculated for genotype and blocks, respectively.`PFG and PFB`

: The P-values for genotype and blocks, respectively.`CV`

: coefficient of variation.`h2`

: broad-sense heritability.`AS`

: accuracy of selection (square root of`h2`

)

## References

Patterson, H.D., and E.R. Williams. 1976. A new class of resolvable incomplete block designs. Biometrika 63:83-92.

## Author

Tiago Olivoto tiagoolivoto@gmail.com

## Examples

```
# \donttest{
library(metan)
# ANOVA for all variables in data
ind_an <- anova_ind(data_ge,
env = ENV,
gen = GEN,
rep = REP,
resp = everything())
#> Evaluating trait GY |====================== | 50% 00:00:00
Evaluating trait HM |============================================| 100% 00:00:00
# mean for each environment
get_model_data(ind_an)
#> Class of the model: anova_ind
#> Variable extracted: ALL
#> # A tibble: 28 × 16
#> trait ENV MEAN DFG MSG FCG PFG DFB MSB FCB PFB DFE
#> <chr> <chr> <dbl> <int> <dbl> <dbl> <dbl> <int> <dbl> <dbl> <dbl> <int>
#> 1 GY E1 2.52 9 0.337 2.34 5.94e-2 2 0.0652 0.453 6.43e-1 18
#> 2 GY E10 2.18 9 0.296 11.1 1.10e-5 2 0.654 24.5 7.28e-6 18
#> 3 GY E11 1.37 9 0.151 1.44 2.44e-1 2 0.377 3.59 4.86e-2 18
#> 4 GY E12 1.61 9 0.320 5.98 6.47e-4 2 0.0919 1.72 2.08e-1 18
#> 5 GY E13 2.91 9 0.713 7.18 2.10e-4 2 0.0767 0.772 4.77e-1 18
#> 6 GY E14 1.78 9 0.131 1.73 1.53e-1 2 0.104 1.37 2.78e-1 18
#> 7 GY E2 3.18 9 0.207 1.16 3.76e-1 2 0.698 3.91 3.88e-2 18
#> 8 GY E3 4.06 9 0.335 1.87 1.23e-1 2 0.489 2.73 9.21e-2 18
#> 9 GY E4 3.68 9 0.531 3.86 7.12e-3 2 0.116 0.846 4.46e-1 18
#> 10 GY E5 3.91 9 0.526 7.93 1.10e-4 2 0.219 3.30 6.02e-2 18
#> # … with 18 more rows, and 4 more variables: MSE <dbl>, CV <dbl>, h2 <dbl>,
#> # AS <dbl>
# P-value for genotype effect
get_model_data(ind_an, "PFG")
#> Class of the model: anova_ind
#> Variable extracted: PFG
#> # A tibble: 14 × 3
#> ENV GY HM
#> <chr> <dbl> <dbl>
#> 1 E1 0.0594 0.0293
#> 2 E10 0.0000110 0.00000302
#> 3 E11 0.244 0.107
#> 4 E12 0.000647 0.108
#> 5 E13 0.000210 0.0000180
#> 6 E14 0.153 0.00393
#> 7 E2 0.376 0.00402
#> 8 E3 0.123 0.0269
#> 9 E4 0.00712 0.000451
#> 10 E5 0.000110 0.126
#> 11 E6 0.0635 0.000163
#> 12 E7 0.00873 0.438
#> 13 E8 0.000131 0.00127
#> 14 E9 0.000562 0.00541
# }
```