Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Repalce Galton with Gosset #44

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions manuscript/08_tcis.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ groups rather than paired.

## The data

{title="Loading Galton's data.", line-numbers=off,lang=r}
{title="Loading Gosset's data.", line-numbers=off,lang=r}
~~~
> data(sleep)
> head(sleep)
Expand All @@ -121,12 +121,12 @@ groups rather than paired.

Here's a plot of the data. In this plot paired observations are connected with a line.

![A plot of the pairs of observations from Galton's sleep data.](images/galtonSleep.png)
![A plot of the pairs of observations from Gosset's sleep data.](images/galtonSleep.png)

Now let's calculate the *t* interval for the differences from baseline to follow up.
Below we give four different ways for calculating the interval.

{title="Loading Galton's data.", line-numbers=off,lang=r}
{title="Calculating the *t* interval for the differences in Gosset's data.", line-numbers=off,lang=r}
~~~
g1 <- sleep$extra[1 : 10]; g2 <- sleep$extra[11 : 20]
difference <- g2 - g1
Expand Down Expand Up @@ -159,7 +159,7 @@ those who received the treatment to those who received a placebo. The randomizat
attempting to balance unobserved covariates that might contaminate our results. Because of the randomization, it
would be reasonable to compare the two groups without considering further variables.

We cannot use the paired *t* interval that we just used for Galton's data,
We cannot use the paired *t* interval that we just used for Gosset's data,
because the groups are independent. Person 1 from the treated group has no relationship with person 1
from the control group. Moreover, the groups may have different sample sizes, so taking paired differences
may not even be possible even if it isn't advisable in this setting.
Expand Down Expand Up @@ -193,10 +193,10 @@ If there is some doubt about the constant variance assumption, assume a differen
## Mistakenly treating the sleep data as grouped

Let's first go through an example where we treat paired data as if it were independent.
Consider Galton's sleep data from before. In the code below, we do the R code
Consider Gosset's sleep data from before. In the code below, we do the R code
for grouped data directly, and using the `r t.test` function.

{title="Galton's data treated as grouped and independent.", line-numbers=off,lang=r}
{title="Gosset's data treated as grouped and independent.", line-numbers=off,lang=r}
~~~
n1 <- length(g1); n2 <- length(g2)
sp <- sqrt( ((n1 - 1) * sd(x1)^2 + (n2-1) * sd(x2)^2) / (n1 + n2-2))
Expand Down