Session Ready
Exercise

Comparing two means (4)

Now that we have the t score, we can easily calculate the p value. We can do so using the pt() function. One last thing we need to calculate this p value is the degrees of freedom df. You can calculate the degrees of freedom of a two-samples independent t test with the following formula: \(df = n_1 + n_2 - 2\)

Instructions
100 XP
  • Assume in this exercise that we are doing two-sided hypothesis testing. Firstly calculate the degrees of freedom and store it in variable called df. Remember that the sample size for the first group is 100 and for the second group is 150.
  • Using the pt() function, calculate the p value. You can use the the pt() function the following way: pt(t_value, df). Make sure to multiply this p value by two as we are doing two-sided hypotheses testing.
  • Calculate the 99% confidence interval and report it the following way: c(lower_value, upper_value). Round both values to two decimals. Be aware that you can use the qt() function with the 99.5 percentile and the degrees of freedom, like so: qt(0.995, df). You would then need to multiply this value by the standard error. You can subsequently add and subtract this calculated value from your variable mean_difference.