1
2
3
4
5
#

R: t Distribution


I. Calculating P(t < x)
If X~t(df), where df is the degrees of freedom, use the pt(x, df) function to calculate P(X < x).
 
Example 1:
If X~t(4), use the following R code to calculate P(X < 1.2).
> pt(1.2, 4)
[1] 0.8518243
 

II. Calculating P(X > x)

If X~t(df), where df is the degrees of freedom, use the pt(x, v, lower.tail=FALSE) function to calculate P(X > x). A second method would be to subtract pt(x, df) from 1.

Example 1: 

If X~t(4), use the following R code to calculate P(X > 1.2).
# Method 1 - Use "lower.tail = FALSE"
> pt(1.2, 4, lower.tail = FALSE)
[1] 0.1481757

# Method 2 - Subtract pt(x, v) from 1
> 1 - pt(1.2, 4)
[1] 0.1481757

III. Given percentile, find corresponding t-value
If X~t(df), use the qt(percentile, df) function to find the x-value that corresponds with a given percentile. 
 
Example:
IX~t(12), what x-value corresponds with the 75th percentile?
> qt(0.90, 12)
[1] 1.356217

IV. Determing t*
For confidence interval calculations, under certain conditions, one may need to find t*. To calculate t* using R, use the following table on the bottom right.

 

Example:
Find t* for a 95% confidence interval with 8 degrees of freedom.

> qt(0.975, 8)
[1] 2.306004

 

 
Confidence Level R Code
99.9% qt(0.9995, df)
99.8% qt(0.999, df)
99.5% qt(0.9975, df)
99% qt(0.995, df)
98% qt(0.99, df)
96% qt(0.98, df)
95% qt(0.975, df)
90% qt(0.95, df)
80% qt(0.90, df)
70% qt(0.85, df)
60% qt(0.80, df)
50% qt(0.75, df)

 

 

Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.