Learn R Programming

distributional (version 0.6.0)

dist_student_t: The (non-central) location-scale Student t Distribution

Description

[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.

Usage

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

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

dist
mean(dist)
variance(dist)

generate(dist, 10)

density(dist, 2)
density(dist, 2, log = TRUE)

cdf(dist, 4)

quantile(dist, 0.7)

Run the code above in your browser using DataLab