Skip to content

Commit

Permalink
Changed fig 3. image to the correct F distribution and cited the source
Browse files Browse the repository at this point in the history
  • Loading branch information
dkpalmers committed Sep 30, 2024
1 parent 10077ec commit 167655d
Show file tree
Hide file tree
Showing 17 changed files with 3,356 additions and 339 deletions.
17 changes: 8 additions & 9 deletions ancova.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@
title: "ANCOVA"
---

```{=html}
<script type="text/javascript">
function showhide(id) {
var e = document.getElementById(id);
e.style.display = (e.style.display == 'block') ? 'none' : 'block';
}
</script>
```

```{r}
#| label: setup
#| include: false
Expand Down Expand Up @@ -227,13 +226,13 @@ Though the formula may seem a little different, the good news is that R will do

The assumptions for the ANCOVA model are essentially the same as for [CB\[1\]](cb1.qmd), with the addition that the response and the covariate need to have a linear relationship:

| Requirements | Method for Checking | What You Hope to See |
|--------------------|--------------------------|--------------------------|
| Linear relationship between covariate and response | Residual vs. Fitted Plot | No trend or pattern |
| Constant variance across factor levels | Residual vs. Fitted Plot | No wedge or megaphone shape |
| Normally Distributed Residuals | Normal Q-Q plot | Straight line, majority of points in boundaries |
| Independent residuals | Order plot (only if applicable) | No pattern/trend |
| | Familiarity with/critical thinking about the experiment | No potential source for bias |
| Requirements | Method for Checking | What You Hope to See |
|----|----|----|
| Linear relationship between covariate and response | Residual vs. Fitted Plot | No trend or pattern |
| Constant variance across factor levels | Residual vs. Fitted Plot | No wedge or megaphone shape |
| Normally Distributed Residuals | Normal Q-Q plot | Straight line, majority of points in boundaries |
| Independent residuals | Order plot (only if applicable) | No pattern/trend |
| | Familiarity with/critical thinking about the experiment | No potential source for bias |

The following example illustrates how to conduct an ANOVA in R.

Expand Down
383 changes: 83 additions & 300 deletions docs/Anova_F-test.html

Large diffs are not rendered by default.

42 changes: 22 additions & 20 deletions docs/Anova_F-test.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,9 @@ F = \frac{\text{Variation between factor level means}}{\text{Variation of indivi
$$
:::

The F distribution is defined by 2 values for degrees of freedom. One degrees of freedom value for the variance estimate in the numerator, and another for the variance estimate in the denominator. The p-value for the ANOVA F-test is calculated as the area under the F distribution curve to the right of the F statistic, as shown in @fig-pvalue .
The F distribution is defined by 2 values for degrees of freedom. One degrees of freedom value for the variance estimate in the numerator, and another for the variance estimate in the denominator. The p-value for the ANOVA F-test is calculated as the area under the F distribution curve to the right of the F statistic, as shown in @fig-pvalue [^4].

[^4]: From the F distribution applet (https://homepage.divms.uiowa.edu/~mbognar/applets/f.html) copyright 2021 by Matt Bogner, Department of Statistics and Actuarial Science, University of Iowa

![Example P-value calculation based on a F-statistic of 2.23 and an F distribution with 3 and 16 degrees of freedom](images/p-value_example.jpg){#fig-pvalue}

Expand Down Expand Up @@ -159,12 +161,12 @@ $$

With this is mind, we can fill in the F column of the ANOVA table for Treatment Factor.

| Source | df | SS | MS | F | p-value |
|:-----------------|:---:|:---:|:---:|:-------------------------------------------------------------:|:-------:|
| Grand Mean | | | | | |
| Treatment Factor | | | | $\frac{MS_\text{Treatment Factor}}{MS_\text{Residual Error}}$ | |
| Residual Error | | | | | |
| Total | | | | | |
| Source | df | SS | MS | F | p-value |
|:--------|:-------:|:-------:|:-------:|:-----------------------------:|:-------:|
| Grand Mean | | | | | |
| Treatment Factor | | | | $\frac{MS_\text{Treatment Factor}}{MS_\text{Residual Error}}$ | |
| Residual Error | | | | | |
| Total | | | | | |

: Blank ANOVA summary table for an experiment with 1 treatment factor {#tbl-blank-1}

Expand Down Expand Up @@ -281,12 +283,12 @@ Recall that an effect is defined as a deviation from the mean.
Therefore, in a mean square calculation, the numerator is the sum of squares and the denominator is the degrees of freedom.
| Source | df | SS | MS | F | p-value |
|:-----------------|:---:|:---:|:---------------------------------------------------------------:|:-------------------------------------------------------------:|:-------:|
| Grand Mean | | | | | |
| Treatment Factor | | | $\frac{SS_\text{Treatment Factor}}{df_\text{Treatment Factor}}$ | $\frac{MS_\text{Treatment Factor}}{MS_\text{Residual Error}}$ | |
| Residual Error | | | $\frac{SS_\text{Residual Error}}{df_\text{Residual Error}}$ | | |
| Total | | | | | |
| Source | df | SS | MS | F | p-value |
|:--------|:-------:|:-------:|:-----------------:|:----------------:|:-------:|
| Grand Mean | | | | | |
| Treatment Factor | | | $\frac{SS_\text{Treatment Factor}}{df_\text{Treatment Factor}}$ | $\frac{MS_\text{Treatment Factor}}{MS_\text{Residual Error}}$ | |
| Residual Error | | | $\frac{SS_\text{Residual Error}}{df_\text{Residual Error}}$ | | |
| Total | | | | | |
## Sum of Squares (SS)
Expand All @@ -296,12 +298,12 @@ To avoid this problem, statisticians square the distances before summing them. T
In the table below an equation for each factor's SS is listed using terms from the factor effects model. We'll walk through the meaning of each of those equations.
| Source | df | SS | MS | F | p-value |
|:-----------------|:---:|:-------------------------------------:|:---------------------------------------------------------------:|:-------------------------------------------------------------:|:-------:|
| Grand Mean | | $n*\bar{y}_\text{..}^2$ | | | |
| Treatment Factor | | $$ \sum (\hat{\alpha}_i^2*n_i)$$ | $\frac{SS_\text{Treatment Factor}}{df_\text{Treatment Factor}}$ | $\frac{MS_\text{Treatment Factor}}{MS_\text{Residual Error}}$ | |
| Residual Error | | $$ \sum \hat{\epsilon}_\text{ij}^2 $$ | $\frac{SS_\text{Residual Error}}{df_\text{Residual Error}}$ | | |
| Total | | $\sum y_\text{ij}^2$ | | | |
| Source | df | SS | MS | F | p-value |
|:----------|:---------:|:---------:|:--------------:|:-------------:|:---------:|
| Grand Mean | | $n*\bar{y}_\text{..}^2$ | | | |
| Treatment Factor | | $$ \sum (\hat{\alpha}_i^2*n_i)$$ | $\frac{SS_\text{Treatment Factor}}{df_\text{Treatment Factor}}$ | $\frac{MS_\text{Treatment Factor}}{MS_\text{Residual Error}}$ | |
| Residual Error | | $$ \sum \hat{\epsilon}_\text{ij}^2 $$ | $\frac{SS_\text{Residual Error}}{df_\text{Residual Error}}$ | | |
| Total | | $\sum y_\text{ij}^2$ | | | |
::: column-margin
A deviation from the mean can be thought of as an effect. That is why the symbols for factor effects are used in the SS column in the ANOVA summary table.
Expand Down Expand Up @@ -337,7 +339,7 @@ For additional explanation, consider this simple example. There are three data p
The example described above is summarized in @tbl-df-example. The first number is represented as an $a$ and the second number if represented with a $b$.
| value 1 | value 2 | value 3 | | Mean of 3 Values |
|:------------:|:------------:|:---------------------------:|:---:|:----------------:|
|:-----------:|:-----------:|:-------------------:|:-----------:|:-----------:|
| a | b | $3*10 - (a+b)$ | -\> | 10 |
| free to vary | free to vary | depends on other two values | | |
Expand Down
Loading

0 comments on commit 167655d

Please sign in to comment.