trendTest: Test for Trend in Relationship Between Two Variables

View source: R/trendTest.R

trendTestR Documentation

Test for Trend in Relationship Between Two Variables

Description

Conducts a test for trends between a numeric independent variable x and a numeric dependent variable y using specified statistical tests.

Usage

trendTest(x, y, data, test = c("william", "shirley", "tukey"), level = 0.05)

Arguments

x

A numeric vector or the name of the independent variable (if data is provided).

y

A numeric vector or the name of the dependent variable (if data is provided).

data

An optional data frame containing the variables x and y. If provided, x and y should be column names in data.

test

A character string specifying the test to use. Must be one of "william", "shirley", or "tukey" (default).

level

Significance level for the test. Defaults to 0.05.

Details

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).

Value

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 "accept" or "reject" based on the test results.

acceptTrend

A logical value indicating whether a trend is accepted (TRUE) or rejected (FALSE) based on the specified significance level.

Author(s)

Jens Riis Baalkilde

References

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.

See Also

.williamsTest, .shirleyTest, .tukeytrendfit

Examples

# 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)

DoseResponse/bmd documentation built on March 29, 2025, 4:36 p.m.