# Power of One Sided t-test

Let $$X_1, \ldots, X_n$$ be a sample from $$N(\mu, \sigma^2)$$ for unknown $$\mu \in \mathbb{R}$$ and unknown $$\sigma > 0$$. Fix $$\mu_0 \in \mathbb{R}$$. The one-sided hypothesis is $$H_0: \mu \leqslant \mu_0$$ versus $$H_1 : \mu > \mu_0$$. The t-test is given by:

$$\begin{equation*} t(X) = \frac{\sqrt{n} (\overline{X} - \mu_0)}{S} \end{equation*}$$

We are supposed to reject $$H_0$$ if $$t(X) > t_{1-\alpha, n-1}$$, for an $$\alpha \in (0,1)$$.

Is there a way to calculate the power of this test? We know that, if $$H_1$$ is true, then $$t(X)$$ is distributed as the non-central t-distribution:

$$\begin{equation*} t_{n-1} (\frac{\sqrt{n}(\mu-\mu_0)}{\sigma}) \end{equation*}$$

Let $$Y_{\mu,\sigma}$$ be a random variable following this distribution. The power is given by:

$$\begin{equation*} \inf_{\mu > \mu_0, \sigma > 0} P \{Y_{\mu,\sigma} > t_{1-\alpha, n-1}\} \end{equation*}$$

I would guess this does not have a closed form, for the cumulative distribution function of non-central t distribution is complicated. What are some of the ways to compute this quantity? In particular, I would like to know how g-power computes it so that I can reproduce the result.

It doesn't have a closed form. The wikipedia article gives the cdf in terms of infinite series and nonstandard ('not closed form') functions
https://en.wikipedia.org/wiki/Noncentral_t-distribution#Cumulative_distribution_function

Not having a closed form is typical. For example the standard normal is not closed form in the usual sense; it's a special function, too.

G-power would simply call a non-central t-distribution cdf or an equivalent function from some library of statistical and or mathematical functions, or implement one from a paper. If you want to have a look at some code, R should have its code available for its own one-sample t power function power.t.test. ... indeed it is written in R; I just looked; it simply calls pt, the cdf of a t (which allows a non-centrality parameter as an argument by sets it to 0 by default). now pt just calls a C function but you can go and read the code for that.

The R help gives a reference: "For the non-central case of ‘pt’ based on a C translation of Lenth, R. V. (1989). Algorithm AS 243 - Cumulative distribution function of the non-central t distribution, Applied Statistics 38, 185-189."

I don't have the paper but I believe the idea is (if the series gets small quickly enough) to evaluate enough terms in an infinite series that you can bound the error below some desired value.

The Gpower 3.1 manual doesn't mention a reference in the text on the power for a one sample t but has the following reference in the references at the end of the manual:
Benton, D., & Krishnamoorthy, K. (2003). "Computing discrete mixtures of continuous distributions: noncentral chisquare, noncentral t and the distribution of the square of the sample multiple correlation coefficient." Computational statistics & data analysis, 43, 249-267

I presume they use an implementation based off that.

A working paper version of this paper can be found online:

https://papers.ssrn.com/sol3/papers.cfm?abstract_id=3142698

(That paper says that Lenth made an error in the analysis of the error bound in his paper and that it's inaccurate for some specific arguments.)

• Haha. I meant to write "does not" in the question. Thank you for your answer. I shall look into these paper.
– 温泽海
Commented Jul 12 at 12:07
• Yes, I figured that you probably intended a "not" to be in the question but either way it was important to be clear in my answer that it was not closed form. Commented Jul 12 at 14:21