This vignette surveys the functions available for planning studies, then derives power calculations for t-tests and tests of a linear trend. The overview includes sample-size and precision tools for confidence, prediction, and tolerance intervals.

Related vignettes:

For monitoring-specific power calculations, see normal prediction interval power and nonparametric prediction interval power.

FcnsByCatPower

Help topic: FcnsByCatPower.

Confidence Intervals

Function Name Description
ciTableProp Confidence intervals for binomial proportion, or
  difference between two proportions, following Bacchetti (2010)
ciBinomHalfWidth Compute the half-width of a confidence interval for a
  Binomial proportion or the difference between two proportions.
ciBinomN Compute the sample size necessary to achieve a specified
  half-width of a confidence interval for a Binomial proportion or
  the difference between two proportions.
plotCiBinomDesign Create plots for a sampling design based on a confidence interval
  for a Binomial proportion or the difference between two proportions.
ciTableMean Confidence intervals for mean of normal distribution, or
  difference between two means, following Bacchetti (2010)
ciNormHalfWidth Compute the half-width of a confidence interval for the mean of a
  Normal distribution or the difference between two means.
ciNormN Compute the sample size necessary to achieve a specified half-width
  of a confidence interval for the mean of a Normal distribution or
  the difference between two means.
plotCiNormDesign Create plots for a sampling design based on a confidence interval
  for the mean of a Normal distribution or the difference between
  two means.
ciNparConfLevel Compute the confidence level associated with a nonparametric
  confidence interval for a percentile.
ciNparN Compute the sample size necessary to achieve a specified
  confidence level for a nonparametric confidence interval for
  a percentile.
plotCiNparDesign Create plots for a sampling design based on a nonparametric
  confidence interval for a percentile.

Hypothesis Tests

Function Name Description
aovN Compute the sample sizes necessary to achieve a
  specified power for a one-way fixed-effects analysis
  of variance test.
aovPower Compute the power of a one-way fixed-effects analysis of
  variance test.
plotAovDesign Create plots for a sampling design based on a one-way
  analysis of variance.
propTestN Compute the sample size necessary to achieve a specified
  power for a one- or two-sample proportion test.
propTestPower Compute the power of a one- or two-sample proportion test.
propTestMdd Compute the minimal detectable difference associated with
  a one- or two-sample proportion test.
plotPropTestDesign Create plots involving sample size, power, difference, and
  significance level for a one- or two-sample proportion test.
tTestAlpha Compute the Type I Error associated with specified values for
  for power, sample size(s), and scaled MDD for a one- or
  two-sample t-test.
tTestN Compute the sample size necessary to achieve a specified
  power for a one- or two-sample t-test.
tTestPower Compute the power of a one- or two-sample t-test.
tTestScaledMdd Compute the scaled minimal detectable difference
  associated with a one- or two-sample t-test.
plotTTestDesign Create plots for a sampling design based on a one- or
  two-sample t-test.
tTestLnormAltN Compute the sample size necessary to achieve a specified
  power for a one- or two-sample t-test, assuming lognormal
  data.
tTestLnormAltPower Compute the power of a one- or two-sample t-test, assuming
  lognormal data.
tTestLnormAltRatioOfMeans Compute the minimal or maximal detectable ratio of means
  associated with a one- or two-sample t-test, assuming
  lognormal data.
plotTTestLnormAltDesign Create plots for a sampling design based on a one- or
  two-sample t-test, assuming lognormal data.
linearTrendTestN Compute the sample size necessary to achieve a specified
  power for a t-test for linear trend.
linearTrendTestPower Compute the power of a t-test for linear trend.
linearTrendTestScaledMds Compute the scaled minimal detectable slope for a t-test
  for linear trend.
plotLinearTrendTestDesign Create plots for a sampling design based on a t-test for
  linear trend.

Prediction Intervals

Normal Distribution Prediction Intervals

Function Name Description
predIntNormHalfWidth Compute the half-width of a prediction
  interval for a normal distribution.
predIntNormK Compute the required value of KK for
  a prediction interval for a Normal
  distribution.
predIntNormN Compute the sample size necessary to
  achieve a specified half-width for a
  prediction interval for a Normal
  distribution.
plotPredIntNormDesign Create plots for a sampling design
  based on the width of a prediction
  interval for a Normal distribution.
predIntNormTestPower Compute the probability that at least
  one future observation (or mean)
  falls outside a prediction interval
  for a Normal distribution.
plotPredIntNormTestPowerCurve Create plots for a sampling
  design based on a prediction interval
  for a Normal distribution.
predIntNormSimultaneousTestPower Compute the probability that at
  least one set of future observations
  (or means) violates the given rule
  based on a simultaneous prediction
  interval for a Normal distribution.
plotPredIntNormSimultaneousTestPowerCurve Create plots for a sampling design
  based on a simultaneous prediction
  interval for a Normal distribution.

Lognormal Distribution Prediction Intervals

Function Name Description
predIntLnormAltTestPower Compute the probability that at least
  one future observation (or geometric
  mean) falls outside a prediction
  interval for a lognormal distribution.
plotPredIntLnormAltTestPowerCurve Create plots for a sampling design
  based on a prediction interval for a
  lognormal distribution.
predIntLnormAltSimultaneousTestPower Compute the probability that at least
  one set of future observations (or
  geometric means) violates the given
  rule based on a simultaneous
  prediction interval for a lognormal
  distribution.
plotPredIntLnormAltSimultaneousTestPowerCurve Create plots for a sampling design
  based on a simultaneous prediction
  interval for a lognormal distribution.

Nonparametric Prediction Intervals

Function Name Description
predIntNparConfLevel Compute the confidence level associated with
  a nonparametric prediction interval.
predIntNparN Compute the required sample size to achieve
  a specified confidence level for a
  nonparametric prediction interval.
plotPredIntNparDesign Create plots for a sampling design based on
  the confidence level and sample size of a
  nonparametric prediction interval.
predIntNparSimultaneousConfLevel Compute the confidence level associated with
  a simultaneous nonparametric prediction
  interval.
predIntNparSimultaneousN Compute the required sample size for a
  simultaneous nonparametric prediction
  interval.
plotPredIntNparSimultaneousDesign Create plots for a sampling design based on
  a simultaneous nonparametric prediction
  interval.
predIntNparSimultaneousTestPower Compute the probability that at least one
  set of future observations violates the
  given rule based on a nonparametric
  simultaneous prediction interval.
plotPredIntNparSimultaneousTestPowerCurve Create plots for a sampling design based on
  a simultaneous nonparametric prediction
  interval.

Tolerance Intervals

Function Name Description
tolIntNormHalfWidth Compute the half-width of a tolerance
  interval for a normal distribution.
tolIntNormK Compute the required value of KK for a
  tolerance interval for a Normal distribution.
tolIntNormN Compute the sample size necessary to achieve a
  specified half-width for a tolerance interval
  for a Normal distribution.
plotTolIntNormDesign Create plots for a sampling design based on a
  tolerance interval for a Normal distribution.
tolIntNparConfLevel Compute the confidence level associated with a
  nonparametric tolerance interval for a specified
  sample size and coverage.
tolIntNparCoverage Compute the coverage associated with a
  nonparametric tolerance interval for a specified
  sample size and confidence level.
tolIntNparN Compute the sample size required for a nonparametric
  tolerance interval with a specified coverage and
  confidence level.
plotTolIntNparDesign Create plots for a sampling design based on a
  nonparametric tolerance interval.

tTestPower

Help topic: tTestPower.

If the arguments n.or.n1, n2, delta.over.sigma, and alpha are not all the same length, they are replicated to be the same length as the length of the longest argument.

One-Sample Case (sample.type="one.sample")
Let x_=x1,x2,…,xn\underline{x} = x_1, x_2, \ldots, x_n denote a vector of nn observations from a normal distribution with mean μ\mu and standard deviation σ\sigma, and consider the null hypothesis:

H0:μ=μ0(1) H_0: \mu = \mu_0 \;\;\;\;\;\; (1)

The three possible alternative hypotheses are the upper one-sided alternative (alternative="greater"):

Ha:μ>μ0(2) H_a: \mu > \mu_0 \;\;\;\;\;\; (2)

the lower one-sided alternative (alternative="less")

Ha:μ<μ0(3) H_a: \mu < \mu_0 \;\;\;\;\;\; (3)

and the two-sided alternative (alternative="two.sided")

Ha:μ≠μ0(4) H_a: \mu \ne \mu_0 \;\;\;\;\;\; (4)

The test of the null hypothesis (1) versus any of the three alternatives (2)-(4) is based on the Student t-statistic:

t=x‾−μ0s/n(5) t = \frac{\bar{x} - \mu_0}{s/\sqrt{n}} \;\;\;\;\;\; (5)

where

x‾=1n∑i=1nxi(6) \bar{x} = \frac{1}{n} \sum_{i=1}^n x_i \;\;\;\;\;\; (6)

s2=1n−1∑i=1n(xi−x‾)2(7) s^2 = \frac{1}{n-1} \sum_{i=1}^n (x_i - \bar{x})^2 \;\;\;\;\;\; (7)

Under the null hypothesis (1), the t-statistic in (5) follows a Student’s t-distribution with n−1n-1 degrees of freedom (Zar, 2010, Chapter 7; Johnson et al., 1995, pp.362-363).

The formula for the power of the test depends on which alternative is being tested. The two subsections below describe exact and approximate formulas for the power of the one-sample t-test. Note that none of the equations for the power of the t-test requires knowledge of the values δ\delta (Equation (12) below) or σ\sigma (the population standard deviation), only the ratio δ/σ\delta/\sigma. The argument delta.over.sigma is this ratio, and it is referred to as the “scaled difference”.

Exact Power Calculations (approx=FALSE)
This subsection describes the exact formulas for the power of the one-sample t-test.

Upper one-sided alternative (alternative="greater")
The standard Student’s t-test rejects the null hypothesis (1) in favor of the upper alternative hypothesis (2) at level-α\alpha if

t≥tν(1−α)(8) t \ge t_{\nu}(1 - \alpha) \;\;\;\;\;\; (8)

where

ν=n−1(9) \nu = n - 1 \;\;\;\;\;\; (9)

and tν(p)t_{\nu}(p) denotes the pp’th quantile of Student’s t-distribution with ν\nu degrees of freedom (Zar, 2010; Berthouex and Brown, 2002). The power of this test, denoted by 1−β1-\beta, where β\beta denotes the probability of a Type II error, is given by:

1−β=Pr[tν,Δ≥tν(1−α)]=1−G[tν(1−α),ν,Δ](10) 1 - \beta = Pr[t_{\nu, \Delta} \ge t_{\nu}(1 - \alpha)] = 1 - G[t_{\nu}(1 - \alpha), \nu, \Delta] \;\;\;\;\;\; (10)

where

Δ=n(δσ)(11) \Delta = \sqrt{n} (\frac{\delta}{\sigma}) \;\;\;\;\;\; (11)

δ=μ−μ0(12) \delta = \mu - \mu_0 \;\;\;\;\;\ (12)

and tν,Δt_{\nu, \Delta} denotes a non-central Student’s t-random variable with ν\nu degrees of freedom and non-centrality parameter Δ\Delta, and G(x,ν,Δ)G(x, \nu, \Delta) denotes the cumulative distribution function of this random variable evaluated at xx (Johnson et al., 1995, pp.508-510).

Lower one-sided alternative (alternative="less")
The standard Student’s t-test rejects the null hypothesis (1) in favor of the lower alternative hypothesis (3) at level-α\alpha if

t≤tν(α)(13) t \le t_{\nu}(\alpha) \;\;\;\;\;\; (13)

and the power of this test is given by:

1−β=Pr[tν,Δ≤tν(α)]=G[tν(α),ν,Δ](14) 1 - \beta = Pr[t_{\nu, \Delta} \le t_{\nu}(\alpha)] = G[t_{\nu}(\alpha), \nu, \Delta] \;\;\;\;\;\; (14)

Two-sided alternative (alternative="two.sided")
The standard Student’s t-test rejects the null hypothesis (1) in favor of the two-sided alternative hypothesis (4) at level-α\alpha if

|t|≥tν(1−α/2)(15) |t| \ge t_{\nu}(1 - \alpha/2) \;\;\;\;\;\; (15)

and the power of this test is given by:

1−β=Pr[tν,Δ≤tν(α/2)]+Pr[tν,Δ≥tν(1−α/2)] 1 - \beta = Pr[t_{\nu, \Delta} \le t_{\nu}(\alpha/2)] + Pr[t_{\nu, \Delta} \ge t_{\nu}(1 - \alpha/2)]

=G[tν(α/2),ν,Δ]+1−G[tν(1−α/2),ν,Δ](16) = G[t_{\nu}(\alpha/2), \nu, \Delta] + 1 - G[t_{\nu}(1 - \alpha/2), \nu, \Delta] \;\;\;\;\;\; (16)

The power of the t-test given in Equation (16) can also be expressed in terms of the cumulative distribution function of the non-central F-distribution as follows. Let Fν1,ν2,ΔF_{\nu_1, \nu_2, \Delta} denote a non-central F random variable with ν1\nu_1 and ν2\nu_2 degrees of freedom and non-centrality parameter Δ\Delta, and let H(x,ν1,ν2,Δ)H(x, \nu_1, \nu_2, \Delta) denote the cumulative distribution function of this random variable evaluated at xx. Also, let Fν1,ν2(p)F_{\nu_1, \nu_2}(p) denote the pp’th quantile of the central F-distribution with ν1\nu_1 and ν2\nu_2 degrees of freedom. It can be shown that

(tν,Δ)2≅F1,ν,Δ2(17) (t_{\nu, \Delta})^2 \cong F_{1, \nu, \Delta^2} \;\;\;\;\;\; (17)

where ≅\cong denotes “equal in distribution”. Thus, it follows that

[tν(1−α/2)]2=F1,ν(1−α)(18) [t_{\nu}(1 - \alpha/2)]^2 = F_{1, \nu}(1 - \alpha) \;\;\;\;\;\; (18)

so the formula for the power of the t-test given in Equation (16) can also be written as:

1−β=Pr{(tν,Δ)2≥[tν(1−α/2)]2} 1 - \beta = Pr\{(t_{\nu, \Delta})^2 \ge [t_{\nu}(1 - \alpha/2)]^2\}

=Pr[F1,ν,Δ2≥F1,ν(1−α)]=1−H[F1,ν(1−α),1,ν,Δ2](19) = Pr[F_{1, \nu, \Delta^2} \ge F_{1, \nu}(1 - \alpha)] = 1 - H[F_{1, \nu}(1-\alpha), 1, \nu, \Delta^2] \;\;\;\;\;\; (19)

Approximate Power Calculations (approx=TRUE)
Zar (2010, pp.115–118) presents an approximation to the power for the t-test given in Equations (10), (14), and (16) above. His approximation to the power can be derived by using the approximation

n(δs)≈n(δσ)=Δ(20) \sqrt{n} (\frac{\delta}{s}) \approx \sqrt{n} (\frac{\delta}{\sigma}) = \Delta \;\;\;\;\;\; (20)

where ≈\approx denotes “approximately equal to”. Zar’s approximation can be summarized in terms of the cumulative distribution function of the non-central t-distribution as follows:

G(x,ν,Δ)≈G(x−Δ,ν,0)=G(x−Δ,ν)(21) G(x, \nu, \Delta) \approx G(x - \Delta, \nu, 0) = G(x - \Delta, \nu) \;\;\;\;\;\; (21)

where G(x,ν)G(x, \nu) denotes the cumulative distribution function of the central Student’s t-distribution with ν\nu degrees of freedom evaluated at xx.

The following three subsections explicitly derive the approximation to the power of the t-test for each of the three alternative hypotheses.

Upper one-sided alternative (alternative="greater")
The power for the upper one-sided alternative (2) given in Equation (10) can be approximated as:

1−β=Pr[t≥tν(1−α)] 1 - \beta = Pr[t \ge t_{\nu}(1 - \alpha)]

=Pr[x‾−μs/n≥tν(1−α)−nδs] = Pr[\frac{\bar{x} - \mu}{s/\sqrt{n}} \ge t_{\nu}(1 - \alpha) - \sqrt{n}\frac{\delta}{s}]

≈Pr[tν≥tν(1−α)−Δ] \approx Pr[t_{\nu} \ge t_{\nu}(1 - \alpha) - \Delta]

=1−Pr[tν≤tν(1−α)−Δ] = 1 - Pr[t_{\nu} \le t_{\nu}(1 - \alpha) - \Delta]

=1−G[tν(1−α)−Δ,ν](22) = 1 - G[t_{\nu}(1-\alpha) - \Delta, \nu] \;\;\;\;\;\; (22)

where tνt_{\nu} denotes a central Student’s t-random variable with ν\nu degrees of freedom.

Lower one-sided alternative (alternative="less")
The power for the lower one-sided alternative (3) given in Equation (14) can be approximated as:

1−β=Pr[t≤tν(α)] 1 - \beta = Pr[t \le t_{\nu}(\alpha)]

=Pr[x‾−μs/n≤tν(α)−nδs] = Pr[\frac{\bar{x} - \mu}{s/\sqrt{n}} \le t_{\nu}(\alpha) - \sqrt{n}\frac{\delta}{s}]

≈Pr[tν≤tν(α)−Δ] \approx Pr[t_{\nu} \le t_{\nu}(\alpha) - \Delta]

=G[tν(α)−Δ,ν](23) = G[t_{\nu}(\alpha) - \Delta, \nu] \;\;\;\;\;\; (23)

Two-sided alternative (alternative="two.sided")
The power for the two-sided alternative (4) given in Equation (16) can be approximated as:

1−β=Pr[t≤tν(α/2)]+Pr[t≥tν(1−α/2)] 1 - \beta = Pr[t \le t_{\nu}(\alpha/2)] + Pr[t \ge t_{\nu}(1 - \alpha/2)]

=Pr[x‾−μs/n≤tν(α/2)−nδs]+Pr[x‾−μs/n≥tν(1−α)−nδs] = Pr[\frac{\bar{x} - \mu}{s/\sqrt{n}} \le t_{\nu}(\alpha/2) - \sqrt{n}\frac{\delta}{s}] + Pr[\frac{\bar{x} - \mu}{s/\sqrt{n}} \ge t_{\nu}(1 - \alpha) - \sqrt{n}\frac{\delta}{s}]

≈Pr[tν≤tν(α/2)−Δ]+Pr[tν≥tν(1−α/2)−Δ] \approx Pr[t_{\nu} \le t_{\nu}(\alpha/2) - \Delta] + Pr[t_{\nu} \ge t_{\nu}(1 - \alpha/2) - \Delta]

=G[tν(α/2)−Δ,ν]+1−G[tν(1−α/2)−Δ,ν](24) = G[t_{\nu}(\alpha/2) - \Delta, \nu] + 1 - G[t_{\nu}(1-\alpha/2) - \Delta, \nu] \;\;\;\;\;\; (24)

Two-Sample Case (sample.type="two.sample")
Let x_1=x11,x12,…,x1n1\underline{x}_1 = x_{11}, x_{12}, \ldots, x_{1n_1} denote a vector of n1n_1 observations from a normal distribution with mean μ1\mu_1 and standard deviation σ\sigma, and let x_2=x21,x22,…,x2n2\underline{x}_2 = x_{21}, x_{22}, \ldots, x_{2n_2} denote a vector of n2n_2 observations from a normal distribution with mean μ2\mu_2 and standard deviation σ\sigma, and consider the null hypothesis:

H0:μ1=μ2(25) H_0: \mu_1 = \mu_2 \;\;\;\;\;\; (25)

The three possible alternative hypotheses are the upper one-sided alternative (alternative="greater"):

Ha:μ1>μ2(26) H_a: \mu_1 > \mu_2 \;\;\;\;\;\; (26)

the lower one-sided alternative (alternative="less")

Ha:μ1<μ2(27) H_a: \mu_1 < \mu_2 \;\;\;\;\;\; (27)

and the two-sided alternative (alternative="two.sided")

Ha:μ1≠μ2(28) H_a: \mu_1 \ne \mu_2 \;\;\;\;\;\; (28)

The test of the null hypothesis (25) versus any of the three alternatives (26)-(28) is based on the Student t-statistic:

t=x‾1−x‾2sp1n1+1n2(29) t = \frac{\bar{x}_1 - \bar{x}_2}{s_p\sqrt{\frac{1}{n_1} + \frac{1}{n_2}}} \;\;\;\;\;\; (29)

where

x‾1=1n1∑i=1n1x1i(30) \bar{x}_1 = \frac{1}{n_1} \sum_{i=1}^{n_1} x_{1i} \;\;\;\;\;\; (30)

x‾2=1n2∑i=1n2x2i(31) \bar{x}_2 = \frac{1}{n_2} \sum_{i=1}^{n_2} x_{2i} \;\;\;\;\;\; (31)

sp2=(n1−1)s12+(n2−1)s22n1+n2−2(32) s_p^2 = \frac{(n_1 - 1) s_1^2 + (n_2 - 1) s_2^2}{n_1 + n_2 - 2} \;\;\;\;\;\; (32)

s12=1n1−1∑i=1n1(x1i−x‾1)2(33) s_1^2 = \frac{1}{n_1 - 1} \sum_{i=1}^{n_1} (x_{1i} - \bar{x}_1)^2 \;\;\;\;\;\; (33)

s22=1n2−1∑i=1n2(x2i−x‾2)2(34) s_2^2 = \frac{1}{n_2 - 1} \sum_{i=1}^{n_2} (x_{2i} - \bar{x}_2)^2 \;\;\;\;\;\; (34)

Under the null hypothesis (25), the t-statistic in (29) follows a Student’s t-distribution with n1+n2−2n_1 + n_2 - 2 degrees of freedom (Zar, 2010, Chapter 8; Johnson et al., 1995, pp.508–510, Helsel and Hirsch, 1992, pp.124–128).

The formulas for the power of the two-sample t-test are precisely the same as those for the one-sample case, with the following modifications:

ν=n1+n2−2(35) \nu = n_1 + n_2 - 2 \;\;\;\;\;\; (35)

Δ=n1n2n1+n2(δσ)(36) \Delta = \sqrt{\frac{n_1 n_2}{n_1 + n_2}} (\frac{\delta}{\sigma}) \;\;\;\;\;\; (36)

δ=μ1−μ2(37) \delta = \mu_1 - \mu_2 \;\;\;\;\;\; (37)

Note that none of the equations for the power of the t-test requires knowledge of the values δ\delta or σ\sigma (the population standard deviation for both populations), only the ratio δ/σ\delta/\sigma. The argument delta.over.sigma is this ratio, and it is referred to as the “scaled difference”.

linearTrendTestPower

Help topic: linearTrendTestPower.

If the argument x is a vector, it is converted into a list with one component. If the arguments n, x, slope.over.sigma, and alpha are not all the same length, they are replicated to be the same length as the length of the longest argument.

Basic Model
Consider the simple linear regression model

Y=β0+β1X+ϵ(1) Y = \beta_0 + \beta_1 X + \epsilon \;\;\;\;\;\; (1)

where XX denotes the predictor variable (observed without error), β0\beta_0 denotes the intercept, β1\beta_1 denotes the slope, and the error term ϵ\epsilon is assumed to be a random variable from a normal distribution with mean 0 and standard deviation σ\sigma. Let

(x_,y_)=(x1,y1),(x2,y2),…,(xn,yn)(2) (\underline{x}, \underline{y}) = (x_1, y_1), (x_2, y_2), \ldots, (x_n, y_n) \;\;\;\;\;\; (2)

denote nn independent observed (X,Y)(X,Y) pairs from the model (1).

Often in environmental data analysis, we are interested in determining whether there is a trend in some indicator variable over time. In this case, the predictor variable XX is time (e.g., day, month, quarter, year, etc.), and the nn values of the response variable YY represent measurements taken over time. The slope then represents the change in the average of the response variable per one unit of time.

When the argument x is a numeric vector, it represents the nn values of the predictor variable. When the argument x is a list, each component of x is a numeric vector that represents a set values of the predictor variable (and the number of elements may vary by component). By default, the argument x is a list for which the i’th component is simply the integers from 1 to the value of the i’th element of the argument n, representing, for example, Day 1, Day2, …, Day n[i].

In the discussion that follows, be sure not to confuse the intercept and slope coefficients β0\beta_0 and β1\beta_1 with the Type II error of the hypothesis test, which is denoted by β\beta.

Estimation of Coefficients and Confidence Interval for Slope
The standard least-squares estimators of the slope and intercept are given by:

β̂1=SxySxx(3) \hat{\beta}_1 = \frac{S_{xy}}{S_{xx}} \;\;\;\;\;\; (3)

β̂0=y‾−β̂1x‾(4) \hat{\beta}_0 = \bar{y} - \hat{\beta}_1 \bar{x} \;\;\;\;\;\; (4)

where

Sxy=∑i=1n(xi−x‾)(yi−y‾)(5) S_{xy} = \sum_{i=1}^n (x_i - \bar{x})(y_i - \bar{y}) \;\;\;\;\;\; (5)

Sxx=∑i=1n(xi−x‾)2(6) S_{xx} = \sum_{i=1}^n (x_i - \bar{x})^2 \;\;\;\;\;\; (6)

x‾=1n∑i=1nxi(7) \bar{x} = \frac{1}{n} \sum_{i=1}^n x_i \;\;\;\;\;\; (7)

y‾=1n∑i=1nyi(8) \bar{y} = \frac{1}{n} \sum_{i=1}^n y_i \;\;\;\;\;\; (8)

(Draper and Smith, 1998, p.25; Zar, 2010, p.332-334; Berthoux and Brown, 2002, p.297; Helsel and Hirsch, p.226). The estimator of slope in Equation (3) has a normal distribution with mean equal to the true slope, and variance given by:

Var(β̂1)=σβ̂12=σ2Sxx(9) Var(\hat{\beta}_1) = \sigma_{\hat{\beta}_1}^2 = \frac{\sigma^2}{S_{xx}} \;\;\;\;\;\; (9)

(Draper and Smith, 1998, p.35; Zar, 2010, p.341; Berthoux and Brown, 2002, p.299; Helsel and Hirsch, 1992, p.227). Thus, a (1−α)100%(1-\alpha)100\% two-sided confidence interval for the slope is given by:

[β̂1−tn−2(1−α/2)σ̂β̂1,β̂1+tn−2(1−α/2)σ̂β̂1](10) [ \hat{\beta}_1 - t_{n-2}(1-\alpha/2) \hat{\sigma}_{\hat{\beta}_1}, \;\; \hat{\beta}_1 + t_{n-2}(1-\alpha/2) \hat{\sigma}_{\hat{\beta}_1} ] \;\;\;\;\;\; (10)

where

σ̂β̂1=σ̂Sxx(11) \hat{\sigma}_{\hat{\beta}_1} = \frac{\hat{\sigma}}{\sqrt{S_{xx}}} \;\;\;\;\;\; (11)

σ̂2=s2=1n−2∑i=1n(yi−ŷi)2(12) \hat{\sigma}^2 = s^2 = \frac{1}{n-2} \sum_{i=1}^n (y_i - \hat{y}_i)^2 \;\;\;\;\;\; (12)

ŷi=β̂0+β̂1xi(13) \hat{y}_i = \hat{\beta}_0 + \hat{\beta}_1 x_i \;\;\;\;\;\; (13)

and tν(p)t_{\nu}(p) denotes the pp’th quantile of Student’s t-distribution with ν\nu degrees of freedom (Draper and Smith, 1998, p.36; Zar, 2010, p.343; Berthoux and Brown, 2002, p.300; Helsel and Hirsch, 1992, p.240).

Testing for a Non-Zero Slope
Consider the null hypothesis of a zero slope coefficient:

H0:β1=0(14) H_0: \beta_1 = 0 \;\;\;\;\;\; (14)

The three possible alternative hypotheses are the upper one-sided alternative (alternative="greater"):

Ha:β1>0(15) H_a: \beta_1 > 0 \;\;\;\;\;\; (15)

the lower one-sided alternative (alternative="less")

Ha:β1<0(16) H_a: \beta_1 < 0 \;\;\;\;\;\; (16)

and the two-sided alternative (alternative="two.sided")

Ha:β1≠0(17) H_a: \beta_1 \ne 0 \;\;\;\;\;\; (17)

The test of the null hypothesis (14) versus any of the three alternatives (15)-(17) is based on the Student t-statistic:

t=β̂1σ̂β̂1=β̂1s/Sxx(18) t = \frac{\hat{\beta}_1}{\hat{\sigma}_{\hat{\beta}_1}} = \frac{\hat{\beta}_1}{s/\sqrt{S_{xx}}} \;\;\;\;\;\; (18)

Under the null hypothesis (14), the t-statistic in (18) follows a Student’s t-distribution with n−2n-2 degrees of freedom (Draper and Smith, 1998, p.36; Zar, 2010, p.341; Helsel and Hirsch, 1992, pp.238-239).

The formula for the power of the test of a zero slope depends on which alternative is being tested. The two subsections below describe exact and approximate formulas for the power of the test. Note that none of the equations for the power of the t-test requires knowledge of the values β1\beta_1 or σ\sigma (the population standard deviation of the error terms), only the ratio β1/σ\beta_1/\sigma. The argument slope.over.sigma is this ratio, and it is referred to as the “scaled slope”.

Exact Power Calculations (approx=FALSE)
This subsection describes the exact formulas for the power of the t-test for a zero slope.

Upper one-sided alternative (alternative="greater")
The standard Student’s t-test rejects the null hypothesis (1) in favor of the upper alternative hypothesis (2) at level-α\alpha if

t≥tν(1−α)(19) t \ge t_{\nu}(1 - \alpha) \;\;\;\;\;\; (19)

where

ν=n−2(20) \nu = n - 2 \;\;\;\;\;\; (20)

and, as noted previously, tν(p)t_{\nu}(p) denotes the pp’th quantile of Student’s t-distribution with ν\nu degrees of freedom. The power of this test, denoted by 1−β1-\beta, where β\beta denotes the probability of a Type II error, is given by:

1−β=Pr[tν,Δ≥tν(1−α)]=1−G[tν(1−α),ν,Δ](21) 1 - \beta = Pr[t_{\nu, \Delta} \ge t_{\nu}(1 - \alpha)] = 1 - G[t_{\nu}(1 - \alpha), \nu, \Delta] \;\;\;\;\;\; (21)

where

Δ=Sxxβ1σ(22) \Delta = \sqrt{S_{xx}} \frac{\beta_1}{\sigma} \;\;\;\;\;\; (22)

and tν,Δt_{\nu, \Delta} denotes a non-central Student’s t-random variable with ν\nu degrees of freedom and non-centrality parameter Δ\Delta, and G(x,ν,Δ)G(x, \nu, \Delta) denotes the cumulative distribution function of this random variable evaluated at xx (Johnson et al., 1995, pp.508-510). Note that when the predictor variable XX represents equally-spaced measures of time (e.g., days, months, quarters, etc.) and

xi=i,i=1,2,…,n(23) x_i = i, \;\; i = 1, 2, \ldots, n \;\;\;\;\;\; (23)

then the non-centrality parameter in Equation (22) becomes:

Δ=(n−1)n(n+1)12β1σ(24) \Delta = \sqrt{\frac{(n-1)n(n+1)}{12}} \frac{\beta_1}{\sigma} \;\;\;\;\;\; (24)

Lower one-sided alternative (alternative="less")
The standard Student’s t-test rejects the null hypothesis (1) in favor of the lower alternative hypothesis (3) at level-α\alpha if

t≤tν(α)(25) t \le t_{\nu}(\alpha) \;\;\;\;\;\; (25)

and the power of this test is given by:

1−β=Pr[tν,Δ≤tν(α)]=G[tν(α),ν,Δ](26) 1 - \beta = Pr[t_{\nu, \Delta} \le t_{\nu}(\alpha)] = G[t_{\nu}(\alpha), \nu, \Delta] \;\;\;\;\;\; (26)

Two-sided alternative (alternative="two.sided")
The standard Student’s t-test rejects the null hypothesis (14) in favor of the two-sided alternative hypothesis (17) at level-α\alpha if

|t|≥tν(1−α/2)(27) |t| \ge t_{\nu}(1 - \alpha/2) \;\;\;\;\;\; (27)

and the power of this test is given by:

1−β=Pr[tν,Δ≤tν(α/2)]+Pr[tν,Δ≥tν(1−α/2)] 1 - \beta = Pr[t_{\nu, \Delta} \le t_{\nu}(\alpha/2)] + Pr[t_{\nu, \Delta} \ge t_{\nu}(1 - \alpha/2)]

=G[tν(α/2),ν,Δ]+1−G[tν(1−α/2),ν,Δ](28) = G[t_{\nu}(\alpha/2), \nu, \Delta] + 1 - G[t_{\nu}(1 - \alpha/2), \nu, \Delta] \;\;\;\;\;\; (28)

The power of the t-test given in Equation (28) can also be expressed in terms of the cumulative distribution function of the non-central F-distribution as follows. Let Fν1,ν2,ΔF_{\nu_1, \nu_2, \Delta} denote a non-central F random variable with ν1\nu_1 and ν2\nu_2 degrees of freedom and non-centrality parameter Δ\Delta, and let H(x,ν1,ν2,Δ)H(x, \nu_1, \nu_2, \Delta) denote the cumulative distribution function of this random variable evaluated at xx. Also, let Fν1,ν2(p)F_{\nu_1, \nu_2}(p) denote the pp’th quantile of the central F-distribution with ν1\nu_1 and ν2\nu_2 degrees of freedom. It can be shown that

(tν,Δ)2≅F1,ν,Δ2(29) (t_{\nu, \Delta})^2 \cong F_{1, \nu, \Delta^2} \;\;\;\;\;\; (29)

where ≅\cong denotes “equal in distribution”. Thus, it follows that

[tν(1−α/2)]2=F1,ν(1−α)(30) [t_{\nu}(1 - \alpha/2)]^2 = F_{1, \nu}(1 - \alpha) \;\;\;\;\;\; (30)

so the formula for the power of the t-test given in Equation (28) can also be written as:

1−β=Pr{(tν,Δ)2≥[tν(1−α/2)]2} 1 - \beta = Pr\{(t_{\nu, \Delta})^2 \ge [t_{\nu}(1 - \alpha/2)]^2\}

=Pr[F1,ν,Δ2≥F1,ν(1−α)]=1−H[F1,ν(1−α),1,ν,Δ2](31) = Pr[F_{1, \nu, \Delta^2} \ge F_{1, \nu}(1 - \alpha)] = 1 - H[F_{1, \nu}(1-\alpha), 1, \nu, \Delta^2] \;\;\;\;\;\; (31)

Approximate Power Calculations (approx=TRUE)
Zar (2010, pp.115–118) presents an approximation to the power for the t-test given in Equations (21), (26), and (28) above. His approximation to the power can be derived by using the approximation

Sxxβ1s≈SSxxβ1σ=Δ(32) \sqrt{S_{xx}} \frac{\beta_1}{s} \approx \sqrt{SS_{xx}} \frac{\beta_1}{\sigma} = \Delta \;\;\;\;\;\; (32)

where ≈\approx denotes “approximately equal to”. Zar’s approximation can be summarized in terms of the cumulative distribution function of the non-central t-distribution as follows:

G(x,ν,Δ)≈G(x−Δ,ν,0)=G(x−Δ,ν)(33) G(x, \nu, \Delta) \approx G(x - \Delta, \nu, 0) = G(x - \Delta, \nu) \;\;\;\;\;\; (33)

where G(x,ν)G(x, \nu) denotes the cumulative distribution function of the central Student’s t-distribution with ν\nu degrees of freedom evaluated at xx.

The following three subsections explicitly derive the approximation to the power of the t-test for each of the three alternative hypotheses.

Upper one-sided alternative (alternative="greater")
The power for the upper one-sided alternative (15) given in Equation (21) can be approximated as:

1−β=Pr[t≥tν(1−α)] 1 - \beta = Pr[t \ge t_{\nu}(1 - \alpha)]

=Pr[β̂1s/Sxx≥tν(1−α)−Sxxβ1s] = Pr[\frac{\hat{\beta}_1}{s/\sqrt{S_{xx}}} \ge t_{\nu}(1 - \alpha) - \sqrt{S_{xx}}\frac{\beta_1}{s}]

≈Pr[tν≥tν(1−α)−Δ] \approx Pr[t_{\nu} \ge t_{\nu}(1 - \alpha) - \Delta]

=1−Pr[tν≤tν(1−α)−Δ] = 1 - Pr[t_{\nu} \le t_{\nu}(1 - \alpha) - \Delta]

=1−G[tν(1−α)−Δ,ν](34) = 1 - G[t_{\nu}(1-\alpha) - \Delta, \nu] \;\;\;\;\;\; (34)

where tνt_{\nu} denotes a central Student’s t-random variable with ν\nu degrees of freedom.

Lower one-sided alternative (alternative="less")
The power for the lower one-sided alternative (16) given in Equation (26) can be approximated as:

1−β=Pr[t≤tν(α)] 1 - \beta = Pr[t \le t_{\nu}(\alpha)]

=Pr[β̂1s/Sxx≤tν(α)−Sxxβ1s] = Pr[\frac{\hat{\beta}_1}{s/\sqrt{S_{xx}}} \le t_{\nu}(\alpha) - \sqrt{S_{xx}}\frac{\beta_1}{s}]

≈Pr[tν≤tν(α)−Δ] \approx Pr[t_{\nu} \le t_{\nu}(\alpha) - \Delta]

=G[tν(α)−Δ,ν](35) = G[t_{\nu}(\alpha) - \Delta, \nu] \;\;\;\;\;\; (35)

Two-sided alternative (alternative="two.sided")
The power for the two-sided alternative (17) given in Equation (28) can be approximated as:

1−β=Pr[t≤tν(α/2)]+Pr[t≥tν(1−α/2)] 1 - \beta = Pr[t \le t_{\nu}(\alpha/2)] + Pr[t \ge t_{\nu}(1 - \alpha/2)]

=Pr[β̂1s/Sxx≤tν(α/2)−SSxxβ1s]+Pr[β̂1s/Sxx≥tν(1−α)−SSxxβ1s] = Pr[\frac{\hat{\beta}_1}{s/\sqrt{S_{xx}}} \le t_{\nu}(\alpha/2) - \sqrt{SS_{xx}}\frac{\beta_1}{s}] + Pr[\frac{\hat{\beta}_1}{s/\sqrt{S_{xx}}} \ge t_{\nu}(1 - \alpha) - \sqrt{SS_{xx}}\frac{\beta_1}{s}]

≈Pr[tν≤tν(α/2)−Δ]+Pr[tν≥tν(1−α/2)−Δ] \approx Pr[t_{\nu} \le t_{\nu}(\alpha/2) - \Delta] + Pr[t_{\nu} \ge t_{\nu}(1 - \alpha/2) - \Delta]

=G[tν(α/2)−Δ,ν]+1−G[tν(1−α/2)−Δ,ν](36) = G[t_{\nu}(\alpha/2) - \Delta, \nu] + 1 - G[t_{\nu}(1-\alpha/2) - \Delta, \nu] \;\;\;\;\;\; (36)