monotonicityTest: Test for Monotonicity of Relationship Between Two Variables

View source: R/monotonicityTest.R

monotonicityTestR Documentation

Test for Monotonicity of Relationship Between Two Variables

Description

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

Usage

monotonicityTest(x, y, data, test = c("jonckheere", "bartholomew"), 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 "jonckheere" (default) or "bartholomew".

level

Significance level for the test. Defaults to 0.05.

...

Additional arguments passed to the underlying test functions.

Details

The function tests the monotonicity of the relationship between x and y based on the specified test:

  • "jonckheere": Uses the Jonckheere-Terpstra test to assess monotonic trends.

  • "bartholomew": Uses Bartholomew's test to assess monotonicity.

The direction of the monotonicity (increasing or decreasing) is determined by the sign of the coefficient from a simple linear model lm(y ~ x).

Value

A list with the following components:

p.value

The p-value of the test.

acceptMonotonicity

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

Author(s)

Jens Riis Baalkilde

References

A. R. Jonckheere (1954). "A Distribution-Free k-Sample Test Against Ordered Alternatives." D. J. Bartholomew (1961). "Ordered tests in the analysis of variance." OECD (2006). Rapport No. 54, Annexes.

See Also

.jonckheereTest, .bartholomewTest

Examples

# Example with custom data
x <- c(1, 2, 3, 4, 5)
y <- c(2, 4, 6, 8, 10)
result <- monotonicityTest(x, y, test = "jonckheere")
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 <- monotonicityTest("x", "y", data = data, test = "bartholomew")
print(result)

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