Hi there,
I am new to R and I'm having an assignment that requires the application of t-test (both independent and dependent ones). I just want to ask if the codes I used are correct or not, because the results I found were both of the hypotheses were NOT supported.
Synopsis: Suppose you have a student list with the following variables: gender (male/female), study_per_week (study hours per week), love_of_stat (love of statistics, rating 1-10), heart_rate_before (heart rate before exam), and heart_rate_after (heart rate after exam).
- You want to know if male students study significantly less hours per week than female students.
I use independent t-test with the following code:
t.test(study_per_week ~ gender, data = filtered_exams)
Here is the results for your reference:
#>
#> Welch Two Sample t-test
#>
#> data: study_per_week by gender
#> t = 1.6676, df = 55, p-value = 0.1011
#> alternative hypothesis: true difference in means between group female and group male is not equal to 0
#> 95 percent confidence interval:
#> -0.1178838 1.2866183
#> sample estimates:
#> mean in group female mean in group male
#> 3.423077 2.838710
- You want to know if students in general have significantly higher heart rate after exam compared to before exam.
I use dependent t-test with the following code:
t.test(
x = filtered_exams$heart_rate_before,
y = filtered_exams$heart_rate_after,
pair = TRUE )
here is the results for your reference:
#>
#> Paired t-test
#>
#> data: filtered_exams$heart_rate_before and filtered_exams$heart_rate_after
#> t = 16.706, df = 56, p-value < 2.2e-16
#> alternative hypothesis: true difference in means is not equal to 0
#> 95 percent confidence interval:
#> 6.531164 8.310941
#> sample estimates:
#> mean of the differences
#> 7.421053
- You want to know if the mean of the students' love of statistics is significantly lower than 5.17.
I use single sample t-test with the following code:
t.test(filtered_exams$love_of_stats, mu = 5.17)
here is the results for your reference:
#>
#> One Sample t-test
#>
#> data: filtered_exams$love_of_stats
#> t = -1.3787, df = 56, p-value = 0.1735
#> alternative hypothesis: true mean is not equal to 5.17
#> 95 percent confidence interval:
#> 3.978344 5.390077
#> sample estimates:
#> mean of x
#> 4.684211
**Note: "filtered_exams" is my new data set after removing Outliners.
So, am I using the tests correctly, or am I misunderstanding any of their characteristics?
I'm sorry if my question is a bit too long, and thank you very much for your help!
Cheers,
Esther