Testing Claims Using Hypothesis

saubhagya verma
Analytics Vidhya
Published in
9 min readJul 6, 2021

--

Corn on a plate.

Have you ever wondered what is the total number of corn buds in corn? Probably not! This is because corns aren’t that important to us. They don’t form a major part of our expenses.

However, for Kellogg’s calculating the number of corn buds in corn is a big deal. The famous Corn Flakes of Kellogg’s are made by processing these corn buds. Since corn buds form a major part of their final product, it is important for them to know about the number of buds in corn so that they can predict the number of Corn Flakes.

Let us suppose that a corn bud contains around 70 buds on average and each corn is priced the same as 10 rupees. Also, the corn bud to cornflake ratio (input to output ratio) is 1:1 and the price of 70 units of cornflake is 40 rupees. So on average, the profit generated by the company will be approximately 30 rupees on each such corn assuming that the company has no other costs.

So here you can see how the number of buds in corn can impact the profitability of a multi-billion dollar company. We use Hypothesis testing to find the answers to these kinds of claims (a corn bud contains around 70 buds on average) by using statistics. This testing helps us to understand the likelihood that the claim will be true or not based upon a sample of inputs. Let us understand the basic concepts that are instrumental for doing hypothesis testing.

What is a Hypothesis?

In layman's terms, the hypothesis is an assumption or a proposed explanation about a phenomenon. We formulate hypotheses whenever we aren’t sure about the real value of a population parameter. So, we assume a particular value for the population parameter to test a claim against it. Some examples of hypotheses are shown below:-

  1. A person’s shoe preference is unrelated to its color.
  2. The number of candies in an M&M’s box is equal.
  3. The number of leaves taken by employees per month is equal to 5 days.
  4. The number of pets in a household is unrelated to the number of people living in it.

Basic Components Of Hypothesis Testing

  1. Statistic: A statistic is a central value that we use to summarize the sample data. So you can say that any representative value that is derived from the sample is called a statistic. For example, We find mean, variance, and proportion values from our sample which are used to find test statistics.
  2. Parameter: Just as a statistic is used to summarize the sample, a parameter is used to summarize the properties of the population. We also use parameters to represent the entire population. Similar to the case of statistic values, we calculate mean, variance, proportion values from our sample which are used in hypothesis analysis.
Symbols used to denote different statistical values of population and sample

3. Point Estimate: A point estimate involves the calculation of a single best value that is representative of the unknown population parameter. We use a point estimate to find a value that acts as a central tendency for the population parameter. There are two methods commonly used to calculate point estimates:-

  • Method of Moments: In this method, we basically equate population moments to the respective sample moments in order to get an estimate.
Calculation of Point estimate In case of different number of parameters
  • Method of Maximum Likelihood: In this method, we find the likelihood of a sample statistic by using a population density function or probability function [f(x,0)]of the population. We differentiate the Likelihood function with respect to the population parameters to get the maximum likelihood estimator for each particular parameter.
The likelihood Function derived from the population probability Function.

4. Confidence Interval: We use confidence intervals to find a range of estimate values that the population parameters can take based upon the sample analysis. Unlike Point estimate, we don’t want to find an exact value for the unknown population parameters, instead, we want to know the range that parameter can take at a certain level of probability. Thus, confidence intervals are designed to contain the parameter’s value based upon a stated probability.

The interpretation of a 95% confidence interval (Left side limit, Right side limit) means that there is a 95% chance that the population parameter will lie between the Left side limit and the Right side limit. The limit values of the confidence intervals are also called Critical Values.

The interval at 95% level of confidence.

5. Rare Event Rule: This rule is a quintessential property that allows us to make inferences about the population by using sample data. The rare event rule simply states that if we make an assumption about an event and find that the probability of that observed event is very small, then our assumption is false.

“If, under a given assumption, the probability of a particular observed event is exceptionally small, we conclude that the assumption is probably not correct.”

The basic idea here is that we test a Hypothesis claim by contrasting between two different things:

  • An event that easily occurs by chance. (Null Hypothesis)
  • An event that is highly unlikely to occur by chance. (Alternate Hypothesis)

So we use the knowledge from the Rule of Rare events to accept or reject the original assumption while doing the Hypothesis testing. This rule forms the basis for the Test of Significance.

6. Test of Significance: This is a formal procedure used to check whether the observed data aligns with our assumed value or claimed value. We use p- values to examine whether we can reject the Null Hypothesis or not by comparing it with the test statistic derived from the sample data. In this test, we take a certain level of significance at the start and test our claim with respect to that particular level of significance only.

7. Test Statistic: A test statistic is a value that is derived from a sample statistic. We convert the sample statistic value into a distribution score such as Z score (Normal Distribution), t- score (T- distribution), or Chi-score (Chi-square distribution). If the score value lies in the confidence interval of the sample distribution then we fail to reject the null hypothesis, else we reject the null hypothesis.

Formulas for calculating Test Statistics

8. P-Value: The P in this value stands for Probability Value. The P-Value is the probability of getting a value of the test statistic that is considered to be as extreme as the one representing the sample data while assuming that the null hypothesis is true. If the P-Value is small enough then we say that the results are statistically significant. The method of calculating the p-value changes depending upon the distribution of the sample. However, you can quickly calculate all the p values using the link mentioned below.

Two Hypotheses used in testing

We all can agree that life is hard. Some people have to be truly extraordinary to be accepted by society whereas some just get it by sheer luck. Well, the same is the case when we talk about hypotheses. The Null Hypothesis always gets the benefit of the doubt and the Alternate Hypothesis has to showcase truly exceptional results in order to be accepted by statisticians. I can’t help but wonder if hypotheses were a real person how would the alternate Hypothesis look at the Null Hypothesis.

Null Hypothesis overshadowing all the four Alternate Hypotheses

Since we are familiar with the dynamics of the relationship between null and alternate Hypotheses, let’s formally understand both of them.

  1. Null Hypothesis: A null hypothesis is an initial claim or a generally accepted fact about the population. The null hypothesis is basically a statement which states that the value of the population parameter is equal to some assumed value. In Hypothesis testing, we directly test the claim of the null hypothesis. We can either fail to reject the null hypothesis or reject the null hypothesis. Let us understand the meaning of failing to reject a null hypothesis with an example shown in the video below.
Failing to Reject Null Hypothesis.

2. Alternate Hypothesis: An alternate hypothesis is an actual claim that we want to test against the general information available on population parameters. An alternate Hypothesis is a statement which states that the value of the parameter is different from the one specified in the Null Hypothesis. In the world of Statistics, Rejection of null Hypothesis invariably means acceptance of Alternate Hypothesis. Let us understand the meaning of rejection of the Null Hypothesis with an example shown in the video below.

Steps involved in Hypothesis testing:-

In order to do hypothesis testing, We will use the following steps:-

Step 1: Read the question and understand which parameters are used for analysis. It can be mean (μ), variance(σ), or proportion (p^).

Step 2: formulate the null Hypothesis based upon the target parameter to be studied in the problem.

Step 3: While forming the alternate hypothesis, figure out the type of tail which will be studied in the test.

Different types of Tails in Hypothesis testing

Step 4: Check from the table below to identify which test to use based upon the target parameter which is to be tested.

The different tests used for testing various population parameters

Step 5: Now after choosing the test you must also decide the level of significance(α) and the level of confidence(1- α) for your test.

Step 6: Now check out the formulas mentioned below to calculate the test statistic from the available values of the parameter.

Step 7: After Calculating the test statistic’s value you can use two methods to analyze your results.

  • P-value Analysis: In this form of analysis we compare the p-value of the test statistic with our alpha value and we reject the null hypothesis only when alpha is less than the p-value.
Conclusions based on P-value
  • Acceptance Interval Analysis: In this analysis, we compare the test statistic value with the confidence interval of the distribution. If the test statistic value lies within the confidence interval then the null hypothesis is accepted else we reject the null hypothesis.
Graphical representation of Acceptance and Rejection region

Types of Error

Just like any other human activity, hypothesis testing also involves a certain degree of errors that arise from the test of significance. Predominantly there are two kinds of errors that are most prevalent in hypothesis testing.

  1. Type I Error: A type 1 error occurs when the null hypothesis is true but we mistakenly reject the null hypothesis. The symbol α (Alpha) is used to represents Type 1 error.
  2. Type II Error: A type 2 error occurs when the null hypothesis is false but we mistakenly fail to reject the null hypothesis. The symbol β (Beta) is used to represents Type 1 error.
Table showcasing Type I and Type II Errors

This was all for today’s brief introduction to the theory of Hypothesis testing. We will conduct an example problem based upon Kellogg's corn hypothesis that we discussed at the start of our discussion in the next blog. Stay tuned for the next blog and Take care!

--

--

saubhagya verma
Analytics Vidhya

I am a budding Data Science enthusiast who is actively learning about the various facets of Data.