When do you use paired t test and how to apply the same in practical situation?
In this article we will talk about paired t test analysis calculation based on mathematical formula and using R software.
Mathematical Approach
Let us consider two variable x1 and x2 which are normally distributed. In practical situation observations are taken from same item considered for paired t test analysis. ie item have pre and post values. x1-x2 is the difference denoted as d with mean u and variance sigma1+sigma2-2sigma1sigma2.
Null Hypothesis
In this case the null hypothesis is Ho µd=0 and H1 is µd≠0
paired t test statistic
t statistic should be t=mean(d)/(Sd/sqrt(n))
Let consider x1 values are 2.265, 2.267, 2.264, 2.267, 2.268, 2.263, 2.264, 2.258 and x2 values are 2.270, 2.268, 2.269, 2.273, 2.270, 2.270, 2.268, 2.268
Test pre and post values are significantly different or not.
mean of difference=0.005, sd=0.0028 and t=5.05. According tabled value n-1=7 and confidence level =0.95, Given tabled value t=2.2365.
The calculated value greater than the tabled value, that means rejecting Ho and accepting H1. In other words, significant difference was observed between Pre and Post values at 95% significance level.
R Script
Let see how to calculate paired t test analysis in R software.
The advantage here is with single line of R script we can execute the analysis.
Let store values of x1 in
X1<-c( 2.265, 2.267, 2.264, 2.267, 2.268, 2.263, 2.264, 2.258)
and values of x2 in
X2<-c(2.270, 2.268, 2.269, 2.273, 2.270, 2.270, 2.268, 2.268)
Null Hypothesis
Ho=No difference was observed between Pre and post values
H1=Difference was observed between Pre and Post values
R Function
The R function is mentioned as below
t.test(X1, X2, paired = TRUE, alternative = “two.sided”)
Result:-
data: X1 and X2
t = -5, df = 7, p-value = 0.001565
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-0.007364624 -0.002635376
sample estimates:
mean of the differences -0.005
Conclusion: –
p-value is less than 0.05 that means significant difference was observed between pre and post values. Using R with single line of script can easily execute the analysis.
What is proportion analysis?
How to do t test in R?