cmltest | R Documentation |
A test based on regression depth for linearity of the
conditional median z
given the simple regression dataset x
. The computation of the regression depth of z
with respect to x
is done by the function rdepth
.
The test is only valid when x
contains no duplicates.
cmltest(x, z)
x |
An |
z |
A matrix with one row containing an intercept and slope. |
The following hypothesis test is performed:
H_0
: The data come from a model with: med(x_2|x_1) = z_1 + z_2 * x_1
The test statistic being used is the regression depth of z
with respect to x
.
pval |
The |
P. Segaert
Van Aelst S., Rousseeuw P.J., Hubert M., Struyf A. (2002). The deepest regression method. Journal of Multivariate Analysis, 81, 138–166.
Rousseeuw P.J., Struyf A. (2002). A depth test for symmetry. In: Goodness-of-Fit Tests and Model Validity, Birkhäuser Boston, pages 401–412.
rdepth
, rdepthmedian
data(stars)
# Compute the least squares fit. Due to outliers
# this fit will be bad and thus H0 should be rejected.
temp <- lsfit(x = stars[,1], y = stars[,2])$coefficients
intercept <- temp[1]
slope <- temp[2]
z <- matrix(c(intercept, slope), nrow = 1)
pvalue1 <- cmltest(x = stars[!duplicated(stars), ], z = z)
pvalue1
# Let's now test the deepest regression line.
result <- rdepthmedian(x = stars)
pvalue2 <- cmltest(x = stars[!duplicated(stars), ], z = matrix(result$deepest, nrow = 1))
pvalue2
plot(stars)
abline(a = intercept, b = slope)
abline(result$deepest, col = "red")
text(x = 3.8, y = 5.3, labels = paste("p-value", round(pvalue1, digits = 3)))
text(x = 4.45, y = 4.8, labels = paste("p-value", round(pvalue2, digits = 3)),
col = "red")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.