How it works...

A student's t-test is where the test statistic follows a normal distribution (the student's t distribution) if the null hypothesis is true. It can be used to determine whether there is a difference between two independent datasets. A student's t-test is best used with the problems associated with an inference based on small samples.

In this recipe, we discuss one sample student's t-test and two sample student's t-tests. In the one sample student's t-test, a research question often asked is, Is the mean of the population different from the null hypothesis? Thus, in order to test whether the average mpg of automobiles is lower than the overall average mpg, we first use a boxplot to view the differences between populations without making any assumptions. From the preceding figure, the mean of mpg of automobiles (the blue line) is lower than the average mpg (red line) of the overall population. Then, we apply the one sample t-test; the low p-value of 0.003595 (< 0.05) suggests that we should reject the null hypothesis that the mean mpg for automobiles is less than the average mpg of the overall population.

As a one sample t-test enables us to test whether two means are significantly different, a two-sample t-test allows us to test whether the means of two independent groups are different. Like in a one sample t-test, we first use a boxplot to see the differences between populations and then apply a two-sample t-test. The test results show the p-value = 0.01374 (p< 0.05). In other words, the test provides evidence that rejects the null hypothesis, which shows the mean mpg of cars with automatic transmission differs from the cars with manual transmission.

To elaborate on this, the next recipe creates the dummy student marks data and performs the same test.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset