0% found this document useful (0 votes)
7 views

Paried T Test

The document describes performing a two-sample t-test to compare the mean reaction times of subjects in a treatment and control group. The t-test results show a p-value of 0.006, allowing the researcher to reject the null hypothesis of no difference between the groups and conclude there is a significant difference in reaction times between the treatment and control groups.

Uploaded by

delvishjohn0
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Paried T Test

The document describes performing a two-sample t-test to compare the mean reaction times of subjects in a treatment and control group. The t-test results show a p-value of 0.006, allowing the researcher to reject the null hypothesis of no difference between the groups and conclude there is a significant difference in reaction times between the treatment and control groups.

Uploaded by

delvishjohn0
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

EX: 06

Paired Samples T-test


Consider the paired data below that presents cholesterol levels on 10 men before and after a
certain medicine.

S.No 1 2 3 4 5 6 7 8 9 10
Before 200.1 190.9 192.7 213 241.4 196.9 172.2 185.5 205.2 193.7
After 392.9 393.2 345.1 393 434 427.9 422 383.9 392.3 352.2

AIM:
To find the paired t-test for the given data by using R-coding.
Hypothesis:

H0: There is no significant difference between cholesterol levels on


before and after medicine.

H1: There is significant difference between cholesterol levels on before


and after medicine.

R function to compute paired-sample t-test

 t.test(x, y, paired = TRUE, alternative = "two.sided")


 x,y: numeric vectors
 paired: a logical value specifying that we want to compute a paired t-test
 alternative: the alternative hypothesis. Allowed value is one of “two.sided” (default),
“greater” or “less”.
Algorithm:
 Enter the values in the given data.
 Define the suitable R-coding for the given data.
 Interpretation of results.
INPUT:
# Data in two numeric vectors
# cholesterol level of the men before medicine
before <-c(200.1, 190.9, 192.7, 213.0, 241.4, 196.9, 172.2, 185.5, 205.2, 193.7)
# cholesterol level of the men after medicine
after <-c(392.9, 393.2, 345.1, 393.0, 434.0, 427.9, 422.0, 383.9, 392.3, 352.2)
# Compute t-test
pairedresult <- t.test(before, after, alternative = "two.sided", paired = TRUE)
pairedresult
OUTPUT:

Paired t-test
data: before and after
t = -20.883, df = 9, p-value = 6.2e-09
alternative hypothesis: true mean difference is not equal to 0
95 percent confidence interval:
-215.5581 -173.4219
sample estimates: mean difference
-194.49

Interpretation of results
 The p-value of the test is 6.2e-09, which is less than the significance level
alpha = 0.05.

 We can then reject null hypothesis and there is significant difference


between cholesterol levels on before and after medicine.
EX: 07
one-sample t-test
Problem:
Based on the field observation, the potato yield from 10 different farms. We know
that the standard potato yield for the given variety is 25. X=(17.6, 20.6, 22.2, 15.3,
20.9, 21.0, 18.9, 18.9, 18.9, 18.2). Test if the potato yield from these farms is
significantly better than the standard yield.
Aim:
To find the One sample t-test for the given data by using R-coding.
Hypothesis:
 H0 = There is no significant difference between potato yield and standard
yield.
 H1 = There is significant difference between potato yield and standard yield.
R function to compute one-sample t-test
To perform one-sample t-test, the R function t.test() can be used as follow:

t.test(x, mu = 0, alternative = "two.sided")


 x: a numeric vector containing your data values
 mu: the theoretical mean. Default is 0 but you can change it.
 alternative: the alternative hypothesis. Allowed value is one of “two.sided”
(default), “greater” or “less”.
Algorithm:
 Enter the values in the given data.
 Define the suitable R-coding for the given data.
 Interpretation of results.
INPUT
 # Data
 X= c( 17.6,20.6,22.2,15.3,20.9,21.0,18.9,18.9,18.9,18.2)
 # check the normality
 shapiro.test(X)
 # One-sample t-test
 t.testresults <- t.test(X, mu = 25)
 # Printing the results
 t.testresults
OUTPUT:
Shapiro-Wilk normality test
data: X
W = 0.9526, p-value = 0.6993
> # Printing the results
One Sample t-test
data: X
t = -9.0783, df = 9, p-value = 7.953e-06
alternative hypothesis: true mean is not equal to 25
95 percent confidence interval:
17.8172 20.6828
sample estimates:
mean of x
19.25

Interpretation of results
 The p-value of the test is 7.953e-06, which is less than the significance level
alpha = 0.05. We can then reject null hypothesis.
 There is significant difference between potato yield and standard yield.
EX:08
Two sample t-test
Problem:

Six subjects were given a drug (trearment group) and an additional 6 subjects a placebo
(control group).Their reaction time to stimulus was measured (in ms).We want to perform a two
sample t-test for comparing the means of the treatment and control groups.

Control 91 87 99 77 88 91

Treatment 101 110 103 93 99 104

Aim:

To find the two-sample t-test for the given data by using R-coding.
Hypothesis:

H0: There is no significant difference between treatment and control groups.

H1: There is significant difference between treatment and control groups.

R function to compute two-sample t-test


To perform two-samples t-test comparing the means of two independent samples (x & y),
the R function t.test() can be used as follow:

t.test(x, y, alternative = "two.sided", var.equal = TRUE)


❖ x,y: numeric vectors

❖ alternative: the alternative hypothesis. Allowed value is one of “two.sided” (default), “greater”
or “less”.

❖ var.equal: a logical variable indicating whether to treat the two variances as being equal. If
TRUE then the pooled variance is used to estimate the variance otherwise the Welch test is used.
Algorithm:

❖ Enter the values in the given data.

❖ Define the suitable R-coding for the given data.

❖ Interpretation of results.
INPUT:
# Data in two numeric vectors
control= c(91,87,99,77,88,91)
treatment = c(101,110,103,93,99,104)
# Shapiro-Wilk normality test for treatment and control groups
shapiro.test(control)
shapiro.test(treatment)
# Compute Two-sample t-test
tworesult <- t.test(control, treatment, var.equal = TRUE)
# Printing the results
tworesult
OUTPUT:
Shapiro-Wilk normality test
Shapiro-Wilk normality test
data: control
W = 0.93942, p-value = 0.6545
data: treatment
W = 0.98231, p-value = 0.9624
# Printing the results
Two Sample t-test
data: control and treatment
t = -3.4456, df = 10, p-value = 0.006272
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-21.132133 -4.534534
sample estimates:
mean of x mean of y
88.83333 101.66667
Interpretation of results
 The p-value of the test is 0.006, which is less than the significance level
alpha = 0.05. We can then reject null hypothesis.

 There is significant difference between treatment and control groups.

You might also like