T-test and Types of T-test
Sai Rahul Rachamalla
T-test
 One of the most popular ways to test a hypothesis is a concept called the t-test. There are
different types of t-tests, as we’ll soon see, and each one has its own unique application.
When should we
Perform a t-test?
Consider a telecom company that has two
service centers in the city. The company
wants to find whether the average time
required to service a customer is the same in
both stores.
Example
 The company measures the average time taken by 50 random customers in each store. Store A
takes 22 minutes while Store B averages 25 minutes. Can we say that Store A is more efficient
than Store B in terms of customer service?
 It does seem that way, doesn’t it? However, we have only looked at 50 random customers out of
the many people who visit the stores. Simply looking at the average sample time might not be
representative of all the customers who visit both the stores.
This is where the t-test comes into play. It helps us understand if the difference between two sample
means is actually real or simply due to chance.
Assumptions for Performing a t-test
 The data should follow a continuous or ordinal scale (the IQ test scores of students, for example)
 The observations in the data should be randomly selected
 The data should resemble a bell-shaped curve when we plot it, i.e., it should be normally
distributed. You can refer to this article to get a better understanding of the normal distribution
 Large sample size should be taken for the data to approach a normal distribution (although t-test
is essential for small samples as their distributions are non-normal)
 Variances among the groups should be equal (for independent two-sample t-test)
Types of t-tests (with Solved Examples in R)
There are three types of t-tests we can perform based on the data at hand:
 One sample t-test
 Independent two-sample t-test
 Paired sample t-test
One-Sample t-test
In a one-sample t-test, we compare the average (or mean) of one group against the set average (or
mean). This set average can be any theoretical value (or it can be the population mean).
Consider the following example – A research scholar wants to determine if the average eating time
for a (standard size) burger differs from a set value. Let’s say this value is 10 minutes. How do you
think the research scholar can go about determining this?
He/she can broadly follow the below steps:
SELECT A GROUP OF PEOPLE RECORD THE INDIVIDUAL
EATING TIME OF A STANDARD
SIZE BURGER
CALCULATE THE AVERAGE
EATING TIME FOR THE GROUP
FINALLY, COMPARE THAT
AVERAGE VALUE WITH THE SET
VALUE OF 10
Formulae for one sample t-test
where,
•t = t-statistic
•m = mean of the group
•µ = theoretical value or population mean
•s = standard deviation of the group
•n = group size or sample size
Once we have calculated
the t-statistic value, the
next task is to compare it
with the critical value of
the t-test. We can find this
in the below t-test table
against the degree of
freedom (n-1) and the level
of significance
Implementing the One-
Sample t-test in R
 Step 1: First, import the data.
 Step 2: Validate it for correctness
in R:
Output
Step 3: Remember the assumptions we discussed earlier? We need to
check them:
Almost all the
values lie on the
red line. We can
confidently say
that the data
follows a normal
distribution.
Conduct a one-sample t-test:
Output

T test and types of t-test

  • 1.
    T-test and Typesof T-test Sai Rahul Rachamalla
  • 2.
    T-test  One ofthe most popular ways to test a hypothesis is a concept called the t-test. There are different types of t-tests, as we’ll soon see, and each one has its own unique application.
  • 3.
    When should we Performa t-test? Consider a telecom company that has two service centers in the city. The company wants to find whether the average time required to service a customer is the same in both stores.
  • 4.
    Example  The companymeasures the average time taken by 50 random customers in each store. Store A takes 22 minutes while Store B averages 25 minutes. Can we say that Store A is more efficient than Store B in terms of customer service?  It does seem that way, doesn’t it? However, we have only looked at 50 random customers out of the many people who visit the stores. Simply looking at the average sample time might not be representative of all the customers who visit both the stores. This is where the t-test comes into play. It helps us understand if the difference between two sample means is actually real or simply due to chance.
  • 5.
    Assumptions for Performinga t-test  The data should follow a continuous or ordinal scale (the IQ test scores of students, for example)  The observations in the data should be randomly selected  The data should resemble a bell-shaped curve when we plot it, i.e., it should be normally distributed. You can refer to this article to get a better understanding of the normal distribution  Large sample size should be taken for the data to approach a normal distribution (although t-test is essential for small samples as their distributions are non-normal)  Variances among the groups should be equal (for independent two-sample t-test)
  • 6.
    Types of t-tests(with Solved Examples in R) There are three types of t-tests we can perform based on the data at hand:  One sample t-test  Independent two-sample t-test  Paired sample t-test
  • 7.
    One-Sample t-test In aone-sample t-test, we compare the average (or mean) of one group against the set average (or mean). This set average can be any theoretical value (or it can be the population mean). Consider the following example – A research scholar wants to determine if the average eating time for a (standard size) burger differs from a set value. Let’s say this value is 10 minutes. How do you think the research scholar can go about determining this?
  • 8.
    He/she can broadlyfollow the below steps: SELECT A GROUP OF PEOPLE RECORD THE INDIVIDUAL EATING TIME OF A STANDARD SIZE BURGER CALCULATE THE AVERAGE EATING TIME FOR THE GROUP FINALLY, COMPARE THAT AVERAGE VALUE WITH THE SET VALUE OF 10
  • 9.
    Formulae for onesample t-test where, •t = t-statistic •m = mean of the group •µ = theoretical value or population mean •s = standard deviation of the group •n = group size or sample size
  • 10.
    Once we havecalculated the t-statistic value, the next task is to compare it with the critical value of the t-test. We can find this in the below t-test table against the degree of freedom (n-1) and the level of significance
  • 11.
    Implementing the One- Samplet-test in R  Step 1: First, import the data.  Step 2: Validate it for correctness in R:
  • 12.
  • 13.
    Step 3: Rememberthe assumptions we discussed earlier? We need to check them:
  • 14.
    Almost all the valueslie on the red line. We can confidently say that the data follows a normal distribution.
  • 15.
  • 16.