This help topic is for R version 1.5.0. For the current version of R, try https://stat.ethz.ch/R-manual/R-patched/library/base/html/TDist.html
TDist {base}R Documentation

The Student t Distribution

Description

Density, distribution function, quantile function and random generation for the t distribution with df degrees of freedom (and optional noncentrality parameter ncp).

Usage

dt(x, df, log = FALSE)
pt(q, df, ncp=0, lower.tail = TRUE, log.p = FALSE)
qt(p, df,        lower.tail = TRUE, log.p = FALSE)
rt(n, df)

Arguments

x, q

vector of quantiles.

p

vector of probabilities.

n

number of observations. If length(n) > 1, the length is taken to be the number required.

df

degrees of freedom (> 0, maybe non-integer).

ncp

non-centrality parameter \delta; currently ncp <= 37.62.

log, log.p

logical; if TRUE, probabilities p are given as log(p).

lower.tail

logical; if TRUE (default), probabilities are P[X \le x], otherwise, P[X > x].

Details

The t distribution with df = \nu degrees of freedom has density

f(x) = \frac{\Gamma ((\nu+1)/2)}{\sqrt{\pi \nu} \Gamma (\nu/2)} (1 + x^2/\nu)^{-(\nu+1)/2}%

for all real x. It has mean 0 (for \nu > 1) and variance \frac{\nu}{\nu-2} (for \nu > 2).

The general non-central t with parameters (\nu,\delta) = (df, ncp) is defined as a the distribution of T_{\nu}(\delta) := \frac{U + \delta}{\chi_{\nu}/\sqrt{\nu}} where U and \chi_{\nu} are independent random variables, U \sim {\cal N}(0,1), and \chi^2_\nu is chi-squared, see pchisq.

The most used applications are power calculations for t-tests:
Let T= \frac{\bar{X} - \mu_0}{S/\sqrt{n}} where \bar{X} is the mean and S the sample standard deviation (sd) of X_1,X_2,\dots,X_n which are i.i.d. N(\mu,\sigma^2). Then T is distributed as non-centrally t with df= n-1 degrees of freedom and non-centrality parameter ncp= (\mu - \mu_0) \sqrt{n}/\sigma.

Value

dt gives the density, pt gives the distribution function, qt gives the quantile function, and rt generates random deviates.

References

Lenth, R. V. (1989). Algorithm AS 243 — Cumulative distribution function of the non-central t distribution, Appl.\ Statist. 38, 185–189.

See Also

df for the F distribution.

Examples

1 - pt(1:5, df = 1)
qt(.975, df = c(1:10,20,50,100,1000))

tt <- seq(0,10, len=21)
ncp <- seq(0,6, len=31)
ptn <- outer(tt,ncp, function(t,d) pt(t, df = 3, ncp=d))
image(tt,ncp,ptn, zlim=c(0,1),main=t.tit <- "Non-central t - Probabilities")
persp(tt,ncp,ptn, zlim=0:1, r=2, phi=20, theta=200, main=t.tit,
      xlab = "t", ylab = "noncentrality parameter", zlab = "Pr(T <= t)")

[Package base version 1.5.0 ]