In this article, we will see what is Error in Hypothesis Testing, different types of errors that occur in hypothesis testing, and how to calculate them. The hypothesis is the summation of the various assumptions we assume to be true during model formulation for data. It is very easy to calculate the type II error in the hypothesis with R programming.
What is Error in Hypothesis Testing?
In Hypothesis testing, Error is the estimate of the approval or rejection of a particular hypothesis. There are mainly two types of errors in hypothesis testing:
- Type I Error(also known as alpha error): Type I error occurs when we reject the Null hypothesis but the Null hypothesis is correct. This case is also known as a false positive.
- Type II Error(also known as beta error): Type II error occurs when we fail to remove the Null Hypothesis when the Null hypothesis is incorrect/the alternative hypothesis is correct. This case is also known as a false negative.
P(X) is the probability of the event X happening.
Ho = NULL Hypothesis
Ha = Alternative Hypothesis
- Mathematical Definition of Type I Error: P(Probability of Rejecting Ho/Probability of Ho being true ) = P(Rejecting Ho | Ho True)
- Mathematical Definition of Type II Error: P(Probability of failing to remove Ho/Probability of Ho being false ) = P(Accept Ho | Ho False)
In this example, we are considering the Jury/Court decision for a case. The two decisions that the jury can decide are the convict is guilty and not guilty. Hence the two hypotheses stated under hypothesis. For every decision the truth can be either, the convict is really guilty and the convict is not guilty in reality. Hence the two types of Errors.
- Ho = Not Guilty
- Ha = Guilty
In the above example,
- Type I Error will be: Innocent in Jail
- Type II Error will be: Guilty Set Free
How to Calculate the Type II Error in R Programming?
Type II Error can be calculated by using the following formula. But in this article, we are going to calculate Type II Error using R programming.
P(Probability of failing to remove Ho / Probability of Ho being false ) = P(Accept Ho | Ho False)
Code to Calculate Type II Error in R:
First, copy the function above and run it in the R studio. Then do this.
Putting different values on the dummy set: