Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

Practical 10

Prisha Vaswani

11/8/2022
library(readxl)
data <- read_excel("D:/3rd semester/R/prac10data.xlsx")

The Premodule and post module scores of 20 students is given.


Assumptions of paired t test 1. 2 Samples are dependent on the same set of units. The same
20 samples dataset.
2. The difference of the 2 samples follows a normal distribution.
First the normal quantile plot is used for checking normality.
qqnorm(data$`Premodule score`-data$`Post module score`)

The normal
quantile plot shows that all the points fall amost in a straight line , hence we can say that
the distribution of data is not significantly different from the normal distribution.
This can be confirmed using shapiro-wilk’s test.
H0: Distribution is normally distributed. H1: Distribution is not normally distributed.
shapiro.test(data$`Premodule score`-data$`Post module score`)

##
## Shapiro-Wilk normality test
##
## data: data$`Premodule score` - data$`Post module score`
## W = 0.96205, p-value = 0.5856

Since , p value is greater than 0.05. Therefore, The data is not significantly different from a
normal distribution.
Since , both the assumptions are satisfied we can conduct a paired t test.
H0: There is no significant difference in the mean marks pre and post module. H1: There is
a significant difference in the mean marks pre and post module.
t.test(data$`Premodule score`,data$`Post module
score`,paired=TRUE,alternative="two.sided")

##
## Paired t-test
##
## data: data$`Premodule score` and data$`Post module score`
## t = -3.2796, df = 19, p-value = 0.003942
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -3.4401893 -0.7598107
## sample estimates:
## mean of the differences
## -2.1

Since , the p value is less than 0.05 , we reject the null hypothesis. Therefore , there is
strong evidence that on average the module leads to improvements.
t.test(data$`Premodule score`,data$`Post module
score`,paired=TRUE,alternative="two.sided",conf.level = 0.95)

##
## Paired t-test
##
## data: data$`Premodule score` and data$`Post module score`
## t = -3.2796, df = 19, p-value = 0.003942
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -3.4401893 -0.7598107
## sample estimates:
## mean of the differences
## -2.1

The 95% confidence interval is -3.4401893 and -0.7598107.


t.test(data$`Premodule score`,data$`Post module
score`,paired=TRUE,alternative="two.sided",conf.level = 0.99)

##
## Paired t-test
##
## data: data$`Premodule score` and data$`Post module score`
## t = -3.2796, df = 19, p-value = 0.003942
## alternative hypothesis: true difference in means is not equal to 0
## 99 percent confidence interval:
## -3.931892 -0.268108
## sample estimates:
## mean of the differences
## -2.1

The 99% confidence interval is -3.931892 and -0.268108.


plot(data$`Premodule score`,data$`Post module score`,main="Scatter
diagram",xlab="Premodule scores",ylab="Post module scores")

Interpretation:
Premodule and post module scores are positively correlated.
Significance of Correlation coefficient Our hypothesis will be
H0 ∶ ρ = 0 H1 ∶ ρ ≠ 0
cor.test(data$`Premodule score`,data$`Post module score`)
##
## Pearson's product-moment correlation
##
## data: data$`Premodule score` and data$`Post module score`
## t = 4.412, df = 18, p-value = 0.0003364
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## 0.4086231 0.8819948
## sample estimates:
## cor
## 0.7208049

Conclusion value 0.0003364 is less than the chosen level of significance (0.05). We reject
the hypothesis, correlation is significant.
The 95% confidence interval is 0.4086231 and 0.8819948.
cor.test(data$`Premodule score`,data$`Post module score`,conf.level = 0.99)

##
## Pearson's product-moment correlation
##
## data: data$`Premodule score` and data$`Post module score`
## t = 4.412, df = 18, p-value = 0.0003364
## alternative hypothesis: true correlation is not equal to 0
## 99 percent confidence interval:
## 0.2771460 0.9111149
## sample estimates:
## cor
## 0.7208049

The 99% confidence interval is 0.2771460 and 0.9111149.


Therefore , cor.test and paired t test have been conducted on the dataset in this given
assignment.

You might also like