Skip to content

Commit

Permalink
Mainly typos
Browse files Browse the repository at this point in the history
  • Loading branch information
bhindle committed Sep 8, 2018
1 parent 49fd46a commit e7631b8
Show file tree
Hide file tree
Showing 14 changed files with 74 additions and 68 deletions.
4 changes: 2 additions & 2 deletions 3_02_t-tests_one_sample.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ $$\text{t} = \frac{\text{Sample Mean}}{\text{Standard Error of the Mean}}$$

Why is this useful? If our normality assumption is reasonable this test-statistic follows a *t*-distribution. This is guaranteed by the normality assumption. So this particular test statistic is also a *t*-statistic. That's why we label it *t*. This knowledge leads to the final step...

**Step 4.** Compare the*t*-statistic to the theoretical predictions of the *t*-distribution to assess the statistical significance of the difference between observed and expected value. We calculate the probability that we would have observed a difference with a magnitude as large as, or larger than, the observed difference, if the null hypothesis were true. That's the *p*-value for the test.
**Step 4.** Compare the *t*-statistic to the theoretical predictions of the *t*-distribution to assess the statistical significance of the difference between observed and expected value. We calculate the probability that we would have observed a difference with a magnitude as large as, or larger than, the observed difference, if the null hypothesis were true. That's the *p*-value for the test.

We could step through the actual calculations involved in these steps in detail, using R to help us, but there's no need to do this. We can let R handle everything for us. But first, we should review the assumptions of the one-sample *t*-test.

Expand All @@ -62,7 +62,7 @@ There are a number of assumptions that need to be met in order for a one-sample

2. **Measurement scale.** The variable being analysed should be measured on an interval or ratio scale, i.e. it should be a numeric variable. It doesn't make much sense to apply a one-sample *t*-test to a variable that isn't measured on one of these scales.

3. **Normality.** The one-sample *t*-test will only produce completely reliable *p*-values if the variable is normally distributed in the population. This assumptions is less important than many people think. The *t*-test is fairly robust to mild departures from normality when the sample size is small, and when the sample size is large the normality assumption matters even less.
3. **Normality.** The one-sample *t*-test will only produce completely reliable *p*-values if the variable is normally distributed in the population. This assumption is less important than many people think. The *t*-test is fairly robust to mild departures from normality when the sample size is small, and when the sample size is large the normality assumption matters even less.

We don't have the time to properly explain why the normality assumption is not too important for large samples, but we will at least state the reason: it is a consequence of something called the ['central limit theorem'](https://www.khanacademy.org/math/statistics-probability/sampling-distributions-library/sample-means/v/central-limit-theorem).

Expand Down
2 changes: 1 addition & 1 deletion 4_01_regression_intro.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ Writing 'simple linear regression' all the time becomes tedious, so we'll often
```{block, type='advanced-box'}
**'response vs. predictor' or 'dependent vs. independent'?**
Another way to describe linear regression is that finds the straight-line relationship which best describes the dependence of one variable (the **dependent variable**) on the other (the **independent variable**). The dependent vs. independent and response vs. predictor conventions for variables in a regression are essentially equivalent. They only differ in the nomenclature they use to describe the variables involved. To avoid confusion, we will stick with response vs. predictor naming convention in this course.
Another way to describe linear regression is that it finds the straight-line relationship which best describes the dependence of one variable (the **dependent variable**) on the other (the **independent variable**). The dependent vs. independent and response vs. predictor conventions for variables in a regression are essentially equivalent. They only differ in the nomenclature they use to describe the variables involved. To avoid confusion, we will stick with response vs. predictor naming convention in this course.
```

How do we decide how to select which is to be used as the response variable and which as the predictor variable? The decision is fairly straightforward in an experimental setting: the manipulated variable is the predictor variable, and the measured outcome is the response variable. Consider the thermal tolerance example from earlier. Temperature was manipulated in this experiment, so it must be designated the predictor variable. Moreover, *a priori* (before conducting the experiment), we can reasonably suppose that changes in temperature may cause changes in enzyme activity, but the reverse seems pretty unlikely.
Expand Down
12 changes: 6 additions & 6 deletions 4_03_one_way_anova_intro.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ ANOVA models underpin the analysis of many different kinds of experimental data;

```{r, echo=FALSE}
means <- c(1.5, 2.0, 1.8, 1.4, 1.9);
plans <- c("None", "Growfast", "Linseed", "Allvit", "Earlybird")
plans <- c("None", "Sizefast", "Linseed", "Allvit", "Earlybird")
sim.wl <- function(variables) {
#
wloss.data <-
Expand All @@ -34,9 +34,9 @@ sim.wl <- function(variables) {
}
```

The corncrake, *Crex crex*, underwent severe declines in the UK. Captive breeding and reintroduction programmes were introduced to try to help supplement the wild population. The scientists in charge of the breeding programme wanted to determine the success of 4 different supplementss (the predictor variable) for increasing initial growth (the response variable) in the captively bred hatchlings. They conducted an experiment in which groups of 8 hatchlings were fed with different supplements. A fifth group of 8 hatchlings served as the control group—they were given the base diet with no supplements. At the end of the experiment they measured how much weight each hatchling had gained over the week.
The corncrake, *Crex crex*, underwent severe declines in the UK thought to be due to changes in farming practices. Captive breeding and reintroduction programmes were introduced to try to help supplement the wild population. The scientists in charge of the breeding programme wanted to determine the success of 4 different supplements (the predictor variable) for increasing initial growth (the response variable) in the captively bred hatchlings. They conducted an experiment in which groups of 8 hatchlings were fed with different supplements. A fifth group of 8 hatchlings served as the control group—they were given the base diet with no supplements. At the end of the experiment they measured how much weight each hatchling had gained over the week.

Once the data have been collected we need to understand the results. The weight gain of 8 hatchlings on each of the supplements could be plotted (this is the raw data), along with the means of each supplement group, the standard error of the mean, and the sample mean of all the data:
We can plot the weight gain of 8 hatchlings on each of the supplements (this is the raw data), along with the means of each supplement group, the standard error of the mean, and the sample mean of all the data:

```{r, echo=FALSE, fig.align='center', fig.asp=1, fig.width=4}
set.seed(30081975)
Expand Down Expand Up @@ -66,7 +66,7 @@ The grey points are the raw data, the means and standard error of each group are

Perhaps all of this could be explained away as sampling variation---i.e. the supplements make no difference at all to weight gain. Obviously we need to apply a statistical test to decide whether these differences are 'real'.

It might be tempting to use *t*-tests to compare each mean value with every other. However, this would it would involve 10 *t*-tests. Remember, if there is no effect of supplement, each time we do a *t*-test there is a chance that we will get a false significant result. If we use the conventional *p* = 0.05 significance level, there is a 1 in 20 chance of getting such 'false positives'. Doing a large number of such tests increases the overall risk of finding a false positive. In fact doing ten *t*-tests on all possible comparisons of the 5 different supplements gives about 40% chance of at least one test giving a false significant difference, even though each individual test is conducted with *p* = 0.05.
It might be tempting to use *t*-tests to compare each mean value with every other. However, this would involve 10 *t*-tests. Remember, if there is no effect of supplement, each time we do a *t*-test there is a chance that we will get a false significant result. If we use the conventional *p* = 0.05 significance level, there is a 1 in 20 chance of getting such 'false positives'. Doing a large number of such tests increases the overall risk of finding a false positive. In fact doing ten *t*-tests on all possible comparisons of the 5 different supplements gives about 40% chance of at least one test giving a false significant difference, even though each individual test is conducted with *p* = 0.05.

That doesn't sound like a very good way to do science. We need a reliable way to determine whether there is a significance of differences between several means without increasing the chance of getting a spurious result. That's the job of Analysis of Variance (ANOVA). Just as a two sample *t*-test compares means between two groups, ANOVA compares means among two *or more* groups. The fundamental job of an ANOVA model is to compares means. So why is it called Analysis of *Variance*? Let's find out...

Expand All @@ -81,7 +81,7 @@ plt.data <-

The key to understanding ANOVA is to realise that it works by examining the magnitudes of different sources of variation in the data. We start with the total variation in the response variable---the variation among all the units in the study---and then partition this into two sources:

1. Variation due to the effect of experimental treatments or control groups. This is called the 'between-group' variation. This describes that variability that can be attributed to the different groups in the data (e.g. the supplement groups). This is the same as the 'explained variation' described in the [Relationships and regression] chapter. It quantifies the variation that is 'explained' by the different means.
1. Variation due to the effect of experimental treatments or control groups. This is called the 'between-group' variation. This describes the variability that can be attributed to the different groups in the data (e.g. the supplement groups). This is the same as the 'explained variation' described in the [Relationships and regression] chapter. It quantifies the variation that is 'explained' by the different means.

2. Variation due to other sources. This second source of variation is usually referred to as the 'within-group' variation because it applies to experimental units within each group. This quantifies the variation due to everything else that isn't accounted for by the treatments. Within-group variation is also called the 'error variation'. We'll mostly use this latter term because it is a bit more general.

Expand All @@ -105,7 +105,7 @@ ggplot(data = plt.data, aes(x = SuppNum)) +

The vertical lines show the distance between each observation and the grand mean---we have ordered the data within each group so that the plot is a little tidier. A positive deviation occurs when a point is above the line, and a negative deviation corresponds to a case where the point is below the line. We're not interested in the direction of these deviations. What we need to quantify is the variability of the deviations, which is a feature of their magnitude (the length of the lines).

What measure of variability should we use? We can't add up the deviations because they add to zero. Instead, we apply the same idea introduced in the regression chapter: the measure of variability we need is based on the 'sum of squares' (abbreviated SS) of the deviations. A sum of squares is calculated by taking each deviation in turn, squaring it, and adding up the squared values. Here are the numeric values of the deviations shown graphically above:
What measure of variability should we use? We can't add up the deviations because they add to zero. Instead, we apply the same idea introduced in the [Relationships and regression] chapter: the measure of variability we need is based on the 'sum of squares' (abbreviated SS) of the deviations. A sum of squares is calculated by taking each deviation in turn, squaring it, and adding up the squared values. Here are the numeric values of the deviations shown graphically above:
```{r, echo=FALSE}
(total.devs <- sim1$wloss.data$WeightGain-mean(sim1$wloss.data$WeightGain))
SS.Tot <- sum(total.devs^2)
Expand Down
Loading

0 comments on commit e7631b8

Please sign in to comment.