Description Usage Arguments Details Value Note Author(s) References See Also Examples
View source: R/linearTrendTestScaledMds.R
Compute the scaled minimal detectable slope associated with a ttest for liner trend, given the sample size or predictor variable values, power, and significance level.
1 2 3 
n 
numeric vector of sample sizes. All values of 
x 
numeric vector of predictor variable values, or a list in which each component is
a numeric vector of predictor variable values. Usually, the predictor variable is
time (e.g., days, months, quarters, etc.). 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 
two.sided.direction 
character string indicating the direction (positive or negative) for the
scaled minimal detectable slope when 
approx 
logical scalar indicating whether to compute the power based on an approximation to
the noncentral tdistribution. 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 argument x
is a vector, it is converted into a list with one
component. If the arguments n
, x
, 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 ttest 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
linearTrendTestScaledMds
uses the uniroot
search algorithm to
determine the minimal detectable scaled slope for specified values of the power,
sample size, and Type I error level.
numeric vector of computed scaled minimal detectable slopes. When
alternative="less"
, or alternative="two.sided"
and
two.sided.direction="less"
, the computed slopes are negative. Otherwise,
the slopes are positive.
See the help file for linearTrendTestPower
.
Steven P. Millard ([email protected])
See the help file for linearTrendTestPower
.
linearTrendTestPower
, linearTrendTestN
,
plotLinearTrendTestDesign
, lm
,
summary.lm
, kendallTrendTest
,
Power and Sample Size, Normal, t.test
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62  # Look at how the scaled minimal detectable slope for the ttest for linear
# trend increases with increasing required power:
seq(0.5, 0.9, by = 0.1)
#[1] 0.5 0.6 0.7 0.8 0.9
scaled.mds < linearTrendTestScaledMds(n = 10, power = seq(0.5, 0.9, by = 0.1))
round(scaled.mds, 2)
#[1] 0.25 0.28 0.31 0.35 0.41
#
# Repeat the last example, but compute the scaled minimal detectable slopes
# based on the approximate power instead of the exact:
scaled.mds < linearTrendTestScaledMds(n = 10, power = seq(0.5, 0.9, by = 0.1),
approx = TRUE)
round(scaled.mds, 2)
#[1] 0.25 0.28 0.31 0.35 0.41
#==========
# Look at how the scaled minimal detectable slope for the ttest for linear trend
# decreases with increasing sample size:
seq(10, 50, by = 10)
#[1] 10 20 30 40 50
scaled.mds < linearTrendTestScaledMds(seq(10, 50, by = 10), alternative = "greater")
round(scaled.mds, 2)
#[1] 0.40 0.13 0.07 0.05 0.03
#==========
# Look at how the scaled minimal detectable slope for the ttest for linear trend
# decreases with increasing values of Type I error:
scaled.mds < linearTrendTestScaledMds(10, alpha = c(0.001, 0.01, 0.05, 0.1),
alternative="greater")
round(scaled.mds, 2)
#[1] 0.76 0.53 0.40 0.34
#
# Repeat the last example, but compute the scaled minimal detectable slopes
# based on the approximate power instead of the exact:
scaled.mds < linearTrendTestScaledMds(10, alpha = c(0.001, 0.01, 0.05, 0.1),
alternative="greater", approx = TRUE)
round(scaled.mds, 2)
#[1] 0.70 0.52 0.41 0.36
#==========
# Clean up
#
rm(scaled.mds)

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.