Exercise

Comparing two means

From the course on basic statistics, you may recall the t statistic. We usually use this statistic when we compare the means from two independent samples.

However, before we calculate the t statistic to see whether the difference between two sample means is meaningful, we usually calculate 2 other things first

  1. The difference between two independent sample means
  2. The standard error of the difference between two independent sample means

Two formula for the difference between two independent sample means is relatively straightforward: You substract one mean from the other. See the following formula: $\bar{x}1 - \bar{x}2$. The formula for the standard error of the difference between two independent samples is slightly more complicated:

$$se = \sqrt{\frac{s_1^2}{n_1} + \frac{s_2^2}{n_2}}$$

Here $s1^2$ represents that variance of the first sample, $n1$ represents the sample size of the first sample, $s2$ represents the variance of the second sample and $n2$ represents the sample size of the second sample.

Instructions

100 XP
  • In this exercise we have a sample of 100 males that do sports on average 4.2 hours per week and a sample of 150 females that do sports on average 5.8 hours per week. Calculate the difference between the average of the male and the female sample and store it in the variable mean_difference
  • The male sample has a standard deviation of 2.3 hours and the female sample has a standard deviaton of 3.1 hours. Calculate the standard error of the difference and store it in a variable called se. To square a value, you can use the ^ sign in R. To take the square root of a value, you can use the sqrt() function in R.