9. Hypothesis Testing

# 9.7 RStudio Lesson 5: Single Sample t-Test

Osama Bataineh

Let’s insert and attach the dataset “HeadCircum.sav” (from Data Sets). To get the descriptive statistics, first we need to install and load the package pastecs. I have already installed it before. So I just loaded this package using the library function. Then we utilize a function of this package round to get the descriptive statistics. Here we use our variable age as the argument and set digits equal to 2 to make it look nice.

library(haven)
library(pastecs)
descriptive_stat <- round(stat.desc(HeadCircum), digits = 2)
descriptive_stat Now we will be doing a T-test for mean equal to 33.8. To do it, we will take the help of the function t.test. Here we can see that in the argument, we have to mention the value of our null hypotheses (33.8 in the case), the type of T-test we are doing (one sided or two sided) and the confidence interval.

One Sample t-test

t = 2.258, df = 29, p-value = 0.03165
alternative hypothesis: true mean is not equal to 33.8
95 percent confidence interval:
33.82487 34.30313
sample estimates:
mean of x
34.064 One Sample t-test
t = 2.258, df = 29, p-value = 0.01582
alternative hypothesis: true mean is greater than 33.8
95 percent confidence interval:
33.86534      Inf
sample estimates:
mean of x
34.064  