```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

## 1. Using your own words, describe a randomized complete block design (RCBD) in 3-5 sentences. Then write out a statistical model (using mathematical notation) that could be fitted to data generated by an RCBD.   

An RCBD is a type of experiment design where there were groups of similar experimental units (i.e., the blocks) and all treatments fit the same number of times in the same block.
The capacity to run an experiment in an RCBD is independent of the treatment structure. 
To design an RCBD, we would randomize all treatments within each block. 
The "block effect" is typically considered a nuisance parameter, but they account for known variability in the data and may reduce the residual variance $\sigma^2_\varepsilon$. 
We normally assume that there is no block $\times$ treatment interaction. 

A statistical model that could correspond to an RCBD is 

$$y_{ijk} = \mu + T_j + b_k + \varepsilon_{ijk}, \varepsilon_{ijk}\sim N(0, \sigma^2),\ $$

where:

- $\mu$ is the overall mean, 
- $T_j$ is the effect of the $j$th treatment, 
- $b_k$ is the effect of the $k$th block, 
- $\varepsilon_{ijk}$ is the residual of the $i$th observation, $j$th treatment, and $k$th block, 
- $\sigma^2$ is the residual variance. 

## 2. Edit the R code below:  

- Silence the `messages` and `warnings`: your submitted pdf or html should include the code, but not the warnings/messages seen below. 
- Print a summary of `model1`. 
- Find and print the value for $\hat\sigma^2$ estimated in `model1`. 

```{r message=FALSE, warning=FALSE}
library(tidyverse)
library(agridat)
data("omer.sorghum")
df <- omer.sorghum %>% filter(env == "E3")
model1 <- lm(yield ~ 1 + gen + rep, data = df)
```

```{r}
summary(model1)
```

```{r}
# you only need to do one of these. this is just to show 3 possible responses:
sigma(model1)^2
sum(model1$residuals^2) / model1$df.residual
summary(model1)$sigma^2
```

