The t distribution (2)
In the last exercise we calculated the critical value using the qt()
function. However, we still do not know our t test statistics and whether this statistics is larger than the cut-off value. Let's calculate the t value in this exercise and see which p value is associated with it. The formula for the standard error is the following:
$$\sigma / \sqrt(n)$$
The formula for the t value is the same as the formula for the Z value: $$t = \frac{\bar{x} - \mu}{se}$$
This exercise is part of the course
Basic Statistics
Exercise instructions
- Using our example where we had a sample of 50 males with a mean height of 186.5 and a population standard deviation of 5 and population mean of 185, calculate the associated standard error, round this value to two digits and store it in the variable
se
. - Calculate the associated t value, round it to two digits and store it in the variable
t_value
. Remember to use the same formula as when calculating a z score. - Using the
pt()
function withlower.tail = FALSE
, calculate the associated p value, round it to two digits and store it in a variable calledp_value
. Remember that we are doing a one-sided test. - print the variable
p_value
to the console.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# calculate the standard error and store it in the variable se
# calculate the t value and store it in a variable called t_value
# calculate the p value and store it in a variable called p_value
# print p_value to the console