Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Limits to df in invnchi2

From (Jeff Pitblado, Stata Corp.)
Subject   Re: st: Limits to df in invnchi2
Date   Mon, 15 Sep 2003 17:48:26 -0500

Jeffrey Simons( asks about a limit on the degrees of freedom
for the functions related to noncentral chi-square:

>  From Stata manual:
> invnchi2(n,L,p) returns the inverse cumulative noncentral chi-squared
> distribution.  If nchi2(n,L,x) = p, then invnchi2(n,L,p) = x (n must be 
> an integer,1<=n<=200, 0<=L<=1000).
> Why does n (the degrees of freedom) need to be <=200?
> I am trying to utilize MacCallum et al., (1996) formulas for determining
> sample size for covariance structural models. He provides equations and 
> SAS code at the end of the article and it involves the above chi2 
> distributions.
> I wrote a program to do this in Stata but naturally, the model I want to
> test has 246 degrees of freedom.  Why is there this limit?

This limit comes from the algorithm used to implement the -nchi2()- function;
from Haynam, Govindarajulu, and Leone (1970) [ref below].

The key issue here is that the algorithm involves progressive products
(factorials) and powers of values, both of which are taken directly from the
degrees of freedom.  Beyond a certain point, these calculations will break
down given that they are performed on finite precision machines, thus we chose
to cut things off at n=200.

There are several approximations to this distribution, most (if not all) of
which are discussed in Johnson, Kotz, and Balakrishnan (1995).  One
approximation is based on a Central Limit Argument.

	Assume X2 is distributed as a non-central chi-square random variable
	with n degrees of freedome and non-centrality parameter L, then

		Z = (X2 - (n+L))/sqrt(2*(n+2*L))

	will tend to follow the standard normal distribution for fixed n and
	large L, or for fixed L and large n.

I compared the results between -invnchi2()- and this approximation fixing
n=200, using alpha = 0.05, and L ranging between 5 and 99.  The relative
difference between the two ranged between 0.0040 and 0.0047.  The normal
approximation was consistently less than the result from -invnchi2()- (minimum
difference was 1.12, max was 1.38).

For n=246, the normal approximation will be better, but I cannot say by how


Haynam, G.E., Z. Govindarajulu, and F.C. Leone. 1970. Tables of the cumulative
	non-central chi-square distribution. In Selected Tables in
	Mathematical Statistics, vol. 1, eds. H.L Harter and D.B. Owen,
	Providence, RI: American Mathematical Society, pp. 1--78.

Johnson, N.L., S. Kotz, and N. Balarishnan. 1995. Continuous Univariate
	Distributions, vol 2. 2d ed. New York: Wiley.

*   For searches and help try:

© Copyright 1996–2022 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index