**Econometrics Beat: Dave Giles' Blog**, and kindly contributed to R-bloggers)

**recent post**I discussed some aspects of the distributions of some common test statistics when the null hypothesis that’s being tested is actually

*false*. One of the things that we saw there was that in many cases these distributions are “non-central”, with a non-centrality parameter that increases as we move further and further away from the null hypothesis being true.

_{0}: Rβ = q

*vs*. H

_{1}: Rβ ≠ q

_{0}is based on the statistic,

^{-1}R’]

^{-1 }(Rb – q) / [J (e’e) / (n – k)] .

*restricted*least squares.

^{-1}R’]

^{-1 }(Rβ – q) / (2σ

^{2}).

**Warning!**The literature is split on what convention should be followed in defining λ. Many authors define it

*without the “2” in the denominator.*This can be very confusing, so be aware of this.)

*In the special case where H _{0} is true*, Rβ = q, and λ = 0. In this case the non-central F distribution collapses to the usual (central) F distribution that we’re familiar with. We use this fact to obtain the critical value associated with a chosen significance level; and then we reject H

_{0}if the computed value of F exceeds this critical value,

_{0}, when in fact H

_{0}is false. As noted already, a rejection of H

_{0}will arise when (for a chosen significance level, α) the computed value of the F statistic exceeds the critical value, c

_{(α)}. The power is a

*conditional*probability:

_{0}| H

_{0}False] = Pr.[F > c

_{(α)}| λ ≥ 0].

In this plot, the critical value associated with a 5% significance level is shown with the green marker. (The R code that I used to create this plot is on the **code page** for this blog.)

So, by computing the probability that defines the power – for various increasing values of λ – we can plot out the power function for the F test. Such probabilities are the areas to the right of “crit”, under the coloured densities in the plot shown above.The corresponding area under the black density is the significance level – namely, 5%.

^{2}

_{(v1,λ)}/ v

_{1}] / [χ

^{2}

_{(v2)}/ v

_{2}] ,

^{2}random variables are statistically independent. The numerator χ

^{2}variable is

*non-central*, while the denominator one is

*central*(

*i.e*., its non-centrality parameter is zero). Recall that in our particular example of testing linear restrictions on a regression coefficient vector, v

_{1}= J, and v

_{2}= (n – k).

_{(α)}| λ ≥ 0]

^{2}

_{(J,λ)}/ J] / [χ

^{2}

_{(n-k)}/ (n – k)] > c

_{(α)}| λ} .

*ratio*of weighted χ

^{2}variables as a

*difference*of such variables:

^{2}

_{(J,λ)}– (c

_{(α) }/ (n – k)) χ

^{2}

_{(n-k)}< 0 | lambda} .

^{2 }variable.

^{2}variables is not of any standard form. However, all is not lost. Some years ago the New Zealand statistician, Robert Davies, devised a method (Davies 1973, 1980), and wrote the code for computing the cumulative distribution function of a weighted sum of several (possibly non-central) χ

^{2}random variables, with weights that can be either positive or negative.

^{2}random variables are

*central*.)

**website**.

For this post, I’ve written a small FORTRAN program, FPower, that incorporates his “qf.for” code. I used the Lahey-Fujitsu 7.6 FORTRAN compiler for 64-bit Windows. The source code and the executable file are available on the **code page** for this blog. My program prompts you to key in some information, and the results are written to a file titled FPowerOut.txt that will be located in the same folder (directory) as the executable file.

_{1}and v

_{2}respectively). Recall that in the context of testing the validity of exact linear restrictions on a regression coefficient vector, v

_{1}would be the number of restrictions, and v

_{2}would be the regression degrees of freedom before the restrictions are taken into account. That is, v

_{2}= (n – k), where n is the sample size and k is the number of regressors in the model

For a fixed number of regressors, increasing v_{2} from 10 to 100 is equivalent to increasing the sample size. As the F-test is a “consistent” test, this increase in n leads to an increase in the power of the test for all non-zero values of the non-centrality parameter (for a fixed value of v_{1}). Intuitively, the additional information in the sample enables the test to “perform” better when it comes to identifying false null hypotheses, however false they are.

As I noted above, I’ve used Robert Davies’ code quite a lot in my research over the years. Situations where you need to determine the distribution of a ratio of quadratic forms in normal random vectors arise a lot in econometrics.

One simple example is if you want to compute the *exact* critical value for the Durbin-Watson statistic, for *your particular* X matrix. In this case, the trick of converting the ratio to a weighted difference can be used; there is no non-centrality parameter to worry about; so Imohf’s code can be used in place of Davies’ code if you wish. This was first discussed by Koerts and Abrahamse (1971). On the other hand, if you want to compute exact power functions for the DW test, a non-centrality parameter enters the picture once again, so Robert’s code can be used.

Other examples of where I (and my co-authors) have used Robert Davies code can be found in Giles and Clarke (1989), Giles and Small (1991), Carrodus and Giles (1992), Giles and Scott (1992), Small *et al*. (1994), and Giles and Giles (1996).

**References**

**, 1992. The exact distribution of R2 when the regression disturbances are autocorrelated.**

Carrodus, M. L. and D. E. A. Giles

Carrodus, M. L. and D. E. A. Giles

*Economics Letters*, 38, 375-380.

**Davies, R. B.**, 1973. Numerical inversion of a characteristic function. *Biometrika*, 60, 415-417.

**Davies, R. B.**, 1980. Algorithm AS155: The distribution of a linear combination of χ^{2} random variables. *Applied Statistics*, 29, 323-333.

**Giles, D. E. A. and J. A. Clarke**, 1989. Preliminary-test estimation of the scale parameter in a mis-specified regression model. *Economics Letters*, 30, 201-205.

**Giles, D. E. A. and M. Scott**, 1992. Some consequences of using the Chow test in the context of autocorrelated disturbances. *Economics Letters*, 38, 145-150.

**Giles, D. E. A. and J. P. Small**, 1991. The power of the Durbin-Watson test when the errors are heteroskedastic. *Economics Letters*, 36, 37-41.

**Giles, J. A. and D. E. A. Giles**, 1996. Risk of a homoscedasticity pre-test estimator of the regression scale under LINEX loss. *Journal of Statistical Planning and Inference*, 50, 21-35.

**Imhof, J. P.**, 1961. Computing the the distribution of quadratic forms in normal variables. *Biometrika*, 48, 419-426.

**Koerts, J. and A. P. J. Abrahamse**, 1971. *On the Theory and Application of the General Linear Model*. Rotterdam University Press, Rotterdam.

Small, J. P., D. E. A. Giles, and K. J. White, 1994. The exact powers of some autocorrelation tests when relevant regressors are omitted. *Journal of Statistical Computation and Simulation*, 50, 45-57.

**leave a comment**for the author, please follow the link and comment on their blog:

**Econometrics Beat: Dave Giles' Blog**.

R-bloggers.com offers

**daily e-mail updates**about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...