Practice 8 Working with Student’s t Distribution in R

8.1 Directions


In this practice exercise, you will work with the Student’s t distribution R.

8.2 A closer look at the code


In this practice, you will learn about the pt() and qt() commands.

8.2.1 Let’s learn to use the pt() command

The pt() command has three arguments that we need to be concerned about.

  • q which holds the value to find the probability of being less than or greater than
  • df which holds the number of degrees of freedom
  • lower.tail which is set to true for a less than calculation or false for a greater than calculation.

Student’s t-distribution has a mean of zero and a standard deviation of one. Here are a few examples.

# P(X <=  0.25) where X ~ t(20)
pt(q=0.25, df=20, lower.tail=T)
## [1] 0.5974313
# P(X >=  -0.1) where X ~ t(100)
pt(q=-0.1, df=100, lower.tail=F)
## [1] 0.5397277

8.2.2 Let’s learn to use the qt() command

The qt() command has three arguments that we need to be concerned about.

  • p which holds the value for which you wish to find a probability.
  • df which holds the number of degrees of freedom
  • lower.tail which is set to true for a less than calculation or false for a greater than calculation.

Here is an example from the voice thread.

# Find the value of Z such that P(X <=  Z) = 25% where X ~ t(25)
qt(p=0.25, df=25, lower.tail=T)
## [1] -0.68443

8.3 R code used in the VoiceThread


# P(X <= 2.3) where X ~ t(5)
pt(q=2.3, df=5, lower.tail=T)

# Find the value of X such that the area to the left of X is 0.05 where X ~ t(46)
qt(p=0.05, df=46, lower.tail=T)

8.4 Now you try


Use R to complete the following activities (this is just for practice you do not need to turn anything in).

  1. Find the value of Z P(Z >= 1) where Z ~ N(0,1)
  2. Find the value of X such that P(X <= 70) = 25% where X ~ N(0,1)