View source: R/monotonicityTest.R
monotonicityTest | R Documentation |
Conducts a test for monotonicity between a numeric independent variable x
and a numeric dependent variable y
using specified statistical tests.
monotonicityTest(x, y, data, test = c("jonckheere", "bartholomew"), 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. |
... |
Additional arguments passed to the underlying test functions. |
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)
.
A list with the following components:
p.value |
The p-value of the test. |
acceptMonotonicity |
A logical value indicating whether monotonicity is accepted ( |
Jens Riis Baalkilde
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.
.jonckheereTest
, .bartholomewTest
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.