2

I am willing to write a program for calculating the critical t values,preferably in R. I am aware of the functions used for the same. But, I am interested in getting aware of the mathematical procedure involved in its calculation.

Using that procedure, I want to make a program of my own, without using any of the in built functions.

Tim
  • 108,699
  • 20
  • 212
  • 390
  • This question seems to be more suited to CrossValidated, and even then it would be more prudent to at least obtain some rudimentary knowledge about the Student's t distribution: https://en.wikipedia.org/wiki/Student%27s_t-distribution – Maxim.K Aug 30 '15 at 06:50
  • 1
    The t-distribution can be computed using the Gamma function, see https://en.wikipedia.org/wiki/Student%27s_t-distribution –  Aug 30 '15 at 08:01
  • @fcoppens The distribution function is a regularized incomplete *beta.* Its inverse is computed in various ways depending on the values of the argument, typically switching between series expansions and continued fraction expansions. See, for instance, http://www.alglib.net/specialfunctions/incompletebeta.php. For working code the best places to start looking are [Numerical Recipes](http://www.nr.com) and [Applied Statistics](http://ece.ut.ac.ir/classpages/F83/IPS/stat/text/briefbook/statalg/StatLib---Applied%20Statistics%20algorithms.htm), algorithms published by the (British) Royal Society. – whuber Aug 30 '15 at 15:29
  • @whuber: thanks for the info, but wasn't that also on the link that I sent ? under 'Cumulative distribution function' , just below the graphs ? (see the link I pasted in my comment) –  Aug 30 '15 at 16:23
  • @fcoppens I had looked at that link, but I did not see anything there that described how to compute the Student t quantiles using Gamma functions. Its *only* references to Gamma concern (1) computing the normalization constant and (2) a discussion of prior distributions. – whuber Aug 30 '15 at 16:54

1 Answers1

7

Critical values are quantiles of the distribution. There are numerous ways to approximate quantiles (inverse cdf) of the t-distribution.

Since you have R already, one way is readily found by looking at how R does it; this is referenced in the help (?qt)), under "Source":

For central qt, a C translation of

Hill, G. W. (1970) Algorithm 396: Student's t-quantiles. Communications of the ACM, 13(10), 619–620.

altered to take account of

Hill, G. W. (1981) Remark on Algorithm 396, ACM Transactions on Mathematical Software, 7, 250–1.

To my understanding Hill uses a modified version of a Cornish-Fisher expansion.

Other approximations are in Abramowitz and Stegun, and if I recall correctly, the tables by Pearson and Hartley as well as a number of more recent ones (both those references are even older than Hill).

If you already have an inverse beta cdf (via inverse incomplete beta function, which is available in some libraries), you can do that way -- the relationship between the t cdf and the regularized incomplete beta function is given at the Wikipedia page for the t-distribution.

Glen_b
  • 257,508
  • 32
  • 553
  • 939