Sample Size for a t-Test for Linear Trend
Compute the sample size necessary to achieve a specified power for a t-test for linear trend, given the scaled slope and significance level.
linearTrendTestN(slope.over.sigma, alpha = 0.05, power = 0.95, alternative = "two.sided", approx = FALSE, round.up = TRUE, n.max = 5000, tol = 1e-07, maxiter = 1000)
slope.over.sigma |
numeric vector specifying the ratio of the true slope to the standard deviation of
the error terms (σ). This is also called the "scaled slope". The
default value is |
alpha |
numeric vector of numbers between 0 and 1 indicating the Type I error level
associated with the hypothesis test. The default value is |
power |
numeric vector of numbers between 0 and 1 indicating the power
associated with the hypothesis test. The default value is |
alternative |
character string indicating the kind of alternative hypothesis. The possible values
are |
approx |
logical scalar indicating whether to compute the power based on an approximation to
the non-central t-distribution. The default value is |
round.up |
logical scalar indicating whether to round up the values of the computed
sample size(s) to the next smallest integer. The default value is
|
n.max |
positive integer greater than 2 indicating the maximum sample size.
The default value is |
tol |
numeric scalar indicating the toloerance to use in the
|
maxiter |
positive integer indicating the maximum number of iterations
argument to pass to the |
If the arguments slope.over.sigma
, alpha
, and power
are not
all the same length, they are replicated to be the same length as the length of
the longest argument.
Formulas for the power of the t-test of linear trend for specified values of
the sample size, scaled slope, and Type I error level are given in
the help file for linearTrendTestPower
. The function
linearTrendTestN
uses the uniroot
search algorithm to
determine the required sample size(s) for specified values of the power,
scaled slope, and Type I error level.
a numeric vector of sample sizes.
See the help file for linearTrendTestPower
.
Steven P. Millard (EnvStats@ProbStatInfo.com)
See the help file for linearTrendTestPower
.
# Look at how the required sample size for the t-test for zero slope # increases with increasing required power: seq(0.5, 0.9, by = 0.1) #[1] 0.5 0.6 0.7 0.8 0.9 linearTrendTestN(slope.over.sigma = 0.1, power = seq(0.5, 0.9, by = 0.1)) #[1] 18 19 21 22 25 #---------- # Repeat the last example, but compute the sample size based on the approximate # power instead of the exact: linearTrendTestN(slope.over.sigma = 0.1, power = seq(0.5, 0.9, by = 0.1), approx = TRUE) #[1] 18 19 21 22 25 #========== # Look at how the required sample size for the t-test for zero slope decreases # with increasing scaled slope: seq(0.05, 0.2, by = 0.05) #[1] 0.05 0.10 0.15 0.20 linearTrendTestN(slope.over.sigma = seq(0.05, 0.2, by = 0.05)) #[1] 41 26 20 17 #========== # Look at how the required sample size for the t-test for zero slope decreases # with increasing values of Type I error: linearTrendTestN(slope.over.sigma = 0.1, alpha = c(0.001, 0.01, 0.05, 0.1)) #[1] 33 29 26 25
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.