[Stable]

The Student's T distribution is closely related to the Normal() distribution, but has heavier tails. As \(\nu\) increases to \(\infty\), the Student's T converges to a Normal. The T distribution appears repeatedly throughout classic frequentist hypothesis testing when comparing group means.

dist_student_t(df, mu = 0, sigma = 1, ncp = NULL)

Arguments

df

degrees of freedom (\(> 0\), maybe non-integer). df = Inf is allowed.

mu

The location parameter of the distribution. If ncp == 0 (or NULL), this is the median.

sigma

The scale parameter of the distribution.

ncp

non-centrality parameter \(\delta\); currently except for rt(), accurate only for abs(ncp) <= 37.62. If omitted, use the central t distribution.

Details

We recommend reading this documentation on pkgdown which renders math nicely. https://pkg.mitchelloharawild.com/distributional/reference/dist_student_t.html

In the following, let \(X\) be a location-scale Student's T random variable with df = \(\nu\), mu = \(\mu\), sigma = \(\sigma\), and ncp = \(\delta\) (non-centrality parameter).

If \(Z\) follows a standard Student's T distribution (with df = \(\nu\) and ncp = \(\delta\)), then \(X = \mu + \sigma Z\).

Support: \(R\), the set of all real numbers

Mean:

For the central distribution (ncp = 0 or NULL):

$$ E(X) = \mu $$

for \(\nu > 1\), and undefined otherwise.

For the non-central distribution (ncp \(\neq\) 0):

$$ E(X) = \mu + \delta \sqrt{\frac{\nu}{2}} \frac{\Gamma((\nu-1)/2)}{\Gamma(\nu/2)} \sigma $$

for \(\nu > 1\), and undefined otherwise.

Variance:

For the central distribution (ncp = 0 or NULL):

$$ \mathrm{Var}(X) = \frac{\nu}{\nu - 2} \sigma^2 $$

for \(\nu > 2\). Undefined if \(\nu \le 1\), infinite when \(1 < \nu \le 2\).

For the non-central distribution (ncp \(\neq\) 0):

$$ \mathrm{Var}(X) = \left[\frac{\nu(1+\delta^2)}{\nu-2} - \left(\delta \sqrt{\frac{\nu}{2}} \frac{\Gamma((\nu-1)/2)}{\Gamma(\nu/2)}\right)^2\right] \sigma^2 $$

for \(\nu > 2\). Undefined if \(\nu \le 1\), infinite when \(1 < \nu \le 2\).

Probability density function (p.d.f):

For the central distribution (ncp = 0 or NULL), the standard t distribution with df = \(\nu\) has density:

$$ f_Z(z) = \frac{\Gamma((\nu + 1)/2)}{\sqrt{\pi \nu} \Gamma(\nu/2)} \left(1 + \frac{z^2}{\nu} \right)^{- (\nu + 1)/2} $$

The location-scale version with mu = \(\mu\) and sigma = \(\sigma\) has density:

$$ f(x) = \frac{1}{\sigma} f_Z\left(\frac{x - \mu}{\sigma}\right) $$

For the non-central distribution (ncp \(\neq\) 0), the density is computed numerically via stats::dt().

Cumulative distribution function (c.d.f):

For the central distribution (ncp = 0 or NULL), the cumulative distribution function is computed numerically via stats::pt(), which uses the relationship to the incomplete beta function:

$$ F_\nu(t) = \frac{1}{2} I_x\left(\frac{\nu}{2}, \frac{1}{2}\right) $$

for \(t \le 0\), where \(x = \nu/(\nu + t^2)\) and \(I_x(a,b)\) is the incomplete beta function (stats::pbeta()). For \(t \ge 0\):

$$ F_\nu(t) = 1 - \frac{1}{2} I_x\left(\frac{\nu}{2}, \frac{1}{2}\right) $$

The location-scale version is: \(F(x) = F_\nu((x - \mu)/\sigma)\).

For the non-central distribution (ncp \(\neq\) 0), the cumulative distribution function is computed numerically via stats::pt().

Moment generating function (m.g.f):

Does not exist in closed form. Moments are computed using the formulas for mean and variance above where available.

See also

Examples

dist <- dist_student_t(df = c(1,2,5), mu = c(0,1,2), sigma = c(1,2,3))

dist
#> <distribution[3]>
#> [1] t(1, 0, 1) t(2, 1, 2) t(5, 2, 3)
mean(dist)
#> [1] NA  1  2
variance(dist)
#> [1]  NA Inf  15

generate(dist, 10)
#> [[1]]
#>  [1]  0.05027518 -1.55556018 39.48683023  0.18818200 -0.95884586  0.23366422
#>  [7]  0.35943551 -0.89352261 -0.01417151 14.02979421
#> 
#> [[2]]
#>  [1] -0.6468812  1.6642693 -1.4564988  0.5251308  3.5918778 -2.4867035
#>  [7] -0.7360158 -1.3345168  3.2917138  1.5645391
#> 
#> [[3]]
#>  [1]  3.1942126 -0.5372396  6.2023451  7.0352406  1.6969657  9.0049139
#>  [7]  5.9884601  4.7603832  6.0149427  2.6508712
#> 

density(dist, 2)
#> [1] 0.06366198 0.14814815 0.12653556
density(dist, 2, log = TRUE)
#> [1] -2.754168 -1.909543 -2.067232

cdf(dist, 4)
#> [1] 0.9220209 0.8638034 0.7327454

quantile(dist, 0.7)
#> [1] 0.7265425 2.2344268 3.6782889