Section One: What is Hypothesis Testing?
Hypothesis testing is a statistical procedure that involves making decisions based on data. It is used to determine whether a hypothesis about a population is supported by the data. A hypothesis is a statement about the population that is being studied. It can be a statement about the mean, proportion, or variance of the population. Hypothesis testing involves comparing the test statistic, which is a measure of the difference between the sample statistic and the hypothesized value, to a critical value from a probability distribution. If the test statistic falls in the rejection region, then the hypothesis is rejected.
Section Two: Intuitive Concept of Hypothesis Testing
Imagine you are a quality control engineer at a manufacturing plant that produces widgets. You suspect that the mean weight of the widgets has changed, and you want to determine whether this suspicion is supported by the data. You take a random sample of 100 widgets and measure their weights. The sample mean weight is 10.5 grams, and the standard deviation is 1.2 grams. The population mean weight, as stated in the production specifications, is 10 grams.
You can use hypothesis testing to determine whether the sample data support the hypothesis that the mean weight has changed. The null hypothesis is that the mean weight has not changed, and the alternative hypothesis is that the mean weight has changed. The test statistic is the difference between the sample mean and the hypothesized mean, divided by the standard error. The standard error is the standard deviation divided by the square root of the sample size.
Section Three: Types of Hypothesis Testing and Assumptions
There are two main types of hypothesis testing: parametric and nonparametric. Parametric tests make assumptions about the population distribution, such as normality and equal variances. Nonparametric tests do not make these assumptions and are used when the data are not normally distributed or when the variances are not equal.
Parametric tests include the t-test, ANOVA, and chi-square test. The t-test is used to compare the means of two groups, ANOVA is used to compare the means of three or more groups, and the chi-square test is used to compare proportions.
Nonparametric tests include the Mann-Whitney U test, the Wilcoxon signed-rank test, and the Kruskal-Wallis test. The Mann-Whitney U test is used to compare the medians of two groups, the Wilcoxon signed-rank test is used to compare the medians of one group at two different times, and the Kruskal-Wallis test is used to compare the medians of three or more groups.
Section Four: Role of Hypothesis Testing in Data Science
Hypothesis testing is an important tool in data science because it allows data scientists to make decisions based on data. For example, a data scientist may use hypothesis testing to determine whether a new marketing campaign is effective, whether a new manufacturing process is more efficient, or whether a new medical treatment is more effective than the current treatment.
Section Five: Deriving a Decision from Hypothesis Testing
To derive a decision from hypothesis testing, you need to compare the test statistic to a critical value from a probability distribution. The critical value is determined by the level of significance, which is the probability of rejecting the null hypothesis when it is true. The most common level of significance is 0.05, which means that there is a 5% chance of rejecting the null hypothesis when it is true.
For example, suppose you are a farmer and you want to determine whether a new fertilizer is more effective than the current fertilizer. You conduct an experiment and measure the yield of corn for each fertilizer. The sample mean yield for the new fertilizer is 120 bushels per acre, and the sample mean yield for the current fertilizer is 110 bushels per acre. The standard deviation of the yield for the new fertilizer is 10 bushels per acre, and the standard deviation of the yield for the current fertilizer is 12 bushels per acre.
You can use a t-test to determine whether the difference in mean yield is statistically significant. The null hypothesis is that the mean yield is the same for both fertilizers, and the alternative hypothesis is that the mean yield is different for the two fertilizers. The test statistic is (120-110)/sqrt((10^2)/10 + (12^2)/10) = 2.24.
The critical value for a two-tailed test with a level of significance of 0.05 and 18 degrees of freedom (18 = sample size - 1) is 2.101. Since the test statistic (2.24) is greater than the critical value (2.101), you reject the null hypothesis and conclude that the new fertilizer is more effective than the current fertilizer.