EVOLUTION-MANAGER
Edit File: TDist.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: The Student t Distribution</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for TDist {stats}"><tr><td>TDist {stats}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>The Student t Distribution</h2> <h3>Description</h3> <p>Density, distribution function, quantile function and random generation for the t distribution with <code>df</code> degrees of freedom (and optional non-centrality parameter <code>ncp</code>). </p> <h3>Usage</h3> <pre> dt(x, df, ncp, log = FALSE) pt(q, df, ncp, lower.tail = TRUE, log.p = FALSE) qt(p, df, ncp, lower.tail = TRUE, log.p = FALSE) rt(n, df, ncp) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x, q</code></td> <td> <p>vector of quantiles.</p> </td></tr> <tr valign="top"><td><code>p</code></td> <td> <p>vector of probabilities.</p> </td></tr> <tr valign="top"><td><code>n</code></td> <td> <p>number of observations. If <code>length(n) > 1</code>, the length is taken to be the number required.</p> </td></tr> <tr valign="top"><td><code>df</code></td> <td> <p>degrees of freedom (<i>> 0</i>, maybe non-integer). <code>df = Inf</code> is allowed.</p> </td></tr> <tr valign="top"><td><code>ncp</code></td> <td> <p>non-centrality parameter <i>delta</i>; currently except for <code>rt()</code>, only for <code>abs(ncp) <= 37.62</code>. If omitted, use the central t distribution.</p> </td></tr> <tr valign="top"><td><code>log, log.p</code></td> <td> <p>logical; if TRUE, probabilities p are given as log(p).</p> </td></tr> <tr valign="top"><td><code>lower.tail</code></td> <td> <p>logical; if TRUE (default), probabilities are <i>P[X ≤ x]</i>, otherwise, <i>P[X > x]</i>.</p> </td></tr> </table> <h3>Details</h3> <p>The <i>t</i> distribution with <code>df</code> <i>= n</i> degrees of freedom has density </p> <p style="text-align: center;"><i>f(x) = Γ((n+1)/2) / (√(n π) Γ(n/2)) (1 + x^2/n)^-((n+1)/2)</i></p> <p>for all real <i>x</i>. It has mean <i>0</i> (for <i>n > 1</i>) and variance <i>n/(n-2)</i> (for <i>n > 2</i>). </p> <p>The general <em>non-central</em> <i>t</i> with parameters <i>(df, Del)</i> <code>= (df, ncp)</code> is defined as the distribution of <i>T(df, Del) := (U + Del) / √(V/df) </i> where <i>U</i> and <i>V</i> are independent random variables, <i>U ~ N(0,1)</i> and <i>V ~ χ^2(df)</i> (see <a href="Chisquare.html">Chisquare</a>). </p> <p>The most used applications are power calculations for <i>t</i>-tests:<br /> Let <i>T= (mX - m0) / (S/sqrt(n))</i> where <i>mX</i> is the <code><a href="../../base/html/mean.html">mean</a></code> and <i>S</i> the sample standard deviation (<code><a href="sd.html">sd</a></code>) of <i>X_1, X_2, …, X_n</i> which are i.i.d. <i>N(μ, σ^2)</i> Then <i>T</i> is distributed as non-central <i>t</i> with <code>df</code><i>= n - 1</i> degrees of freedom and <b>n</b>on-<b>c</b>entrality <b>p</b>arameter <code>ncp</code><i> = (μ - m0) * sqrt(n)/σ</i>. </p> <h3>Value</h3> <p><code>dt</code> gives the density, <code>pt</code> gives the distribution function, <code>qt</code> gives the quantile function, and <code>rt</code> generates random deviates. </p> <p>Invalid arguments will result in return value <code>NaN</code>, with a warning. </p> <p>The length of the result is determined by <code>n</code> for <code>rt</code>, and is the maximum of the lengths of the numerical arguments for the other functions. </p> <p>The numerical arguments other than <code>n</code> are recycled to the length of the result. Only the first elements of the logical arguments are used. </p> <h3>Note</h3> <p>Supplying <code>ncp = 0</code> uses the algorithm for the non-central distribution, which is not the same algorithm used if <code>ncp</code> is omitted. This is to give consistent behaviour in extreme cases with values of <code>ncp</code> very near zero. </p> <p>The code for non-zero <code>ncp</code> is principally intended to be used for moderate values of <code>ncp</code>: it will not be highly accurate, especially in the tails, for large values. </p> <h3>Source</h3> <p>The central <code>dt</code> is computed via an accurate formula provided by Catherine Loader (see the reference in <code><a href="Binomial.html">dbinom</a></code>). </p> <p>For the non-central case of <code>dt</code>, C code contributed by Claus Ekstrøm based on the relationship (for <i>x != 0</i>) to the cumulative distribution. </p> <p>For the central case of <code>pt</code>, a normal approximation in the tails, otherwise via <code><a href="Beta.html">pbeta</a></code>. </p> <p>For the non-central case of <code>pt</code> based on a C translation of </p> <p>Lenth, R. V. (1989). <em>Algorithm AS 243</em> — Cumulative distribution function of the non-central <i>t</i> distribution, <em>Applied Statistics</em> <b>38</b>, 185–189. </p> <p>This computes the lower tail only, so the upper tail suffers from cancellation and a warning will be given when this is likely to be significant. </p> <p>For central <code>qt</code>, a C translation of </p> <p>Hill, G. W. (1970) Algorithm 396: Student's t-quantiles. <em>Communications of the ACM</em>, <b>13(10)</b>, 619–620. </p> <p>altered to take account of </p> <p>Hill, G. W. (1981) Remark on Algorithm 396, <em>ACM Transactions on Mathematical Software</em>, <b>7</b>, 250–1. </p> <p>The non-central case is done by inversion. </p> <h3>References</h3> <p>Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) <em>The New S Language</em>. Wadsworth & Brooks/Cole. (Except non-central versions.) </p> <p>Johnson, N. L., Kotz, S. and Balakrishnan, N. (1995) <em>Continuous Univariate Distributions</em>, volume 2, chapters 28 and 31. Wiley, New York. </p> <h3>See Also</h3> <p><a href="Distributions.html">Distributions</a> for other standard distributions, including <code><a href="Fdist.html">df</a></code> for the F distribution. </p> <h3>Examples</h3> <pre> require(graphics) 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)) t.tit <- "Non-central t - Probabilities" image(tt, ncp, ptn, zlim = c(0,1), main = t.tit) persp(tt, ncp, ptn, zlim = 0:1, r = 2, phi = 20, theta = 200, main = t.tit, xlab = "t", ylab = "non-centrality parameter", zlab = "Pr(T <= t)") plot(function(x) dt(x, df = 3, ncp = 2), -3, 11, ylim = c(0, 0.32), main = "Non-central t - Density", yaxs = "i") </pre> <hr /><div style="text-align: center;">[Package <em>stats</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>