trendTest | R Documentation |
Conducts a test for trends between a numeric independent variable x
and a numeric dependent variable y
using specified statistical tests.
trendTest(x, y, data, test = c("william", "shirley", "tukey"), level = 0.05)
x |
A numeric vector or the name of the independent variable (if |
y |
A numeric vector or the name of the dependent variable (if |
data |
An optional data frame containing the variables |
test |
A character string specifying the test to use. Must be one of |
level |
Significance level for the test. Defaults to 0.05. |
The function tests for a trend in the relationship between x
and y
based on the specified test:
"william"
: Applies Williams' test to assess trend significance.
"shirley"
: Uses Shirley's test for trend analysis with ordered alternatives.
"tukey"
: Implements the Tukey trend test using multiple marginal models.
The direction of the trend (increasing or decreasing) is determined by the slope of the linear model lm(y ~ x)
.
A list with the following components:
p.values |
A numeric vector of p-values for the tests (if applicable). |
decisions |
A character vector indicating whether the trend is |
acceptTrend |
A logical value indicating whether a trend is accepted ( |
Jens Riis Baalkilde
Williams, D. A. (1971). "A test for differences between treatment means when several dose levels are compared with a zero dose control." Biometrics, 27(1), 103-117. Shirley, E. (1977). "A non-parametric equivalent of Williams' test for contrasting increasing dose levels of a treatment." Biometrics, 33(2), 386-389. Schaarschmidt, F. et al. (2021). "The Tukey trend test: Multiplicity adjustment using multiple marginal models" Biometrics, 78(2), 789-797.
.williamsTest
, .shirleyTest
, .tukeytrendfit
# Example with custom data
x <- c(1, 2, 3, 4, 5)
y <- c(2, 4, 6, 8, 10)
result <- trendTest(x, y, test = "tukey")
print(result)
# Example with a data frame
data <- data.frame(x = c(1, 2, 3, 4, 5), y = c(10, 9, 8, 7, 6))
result <- trendTest("x", "y", data = data, test = "shirley")
print(result)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.