
Last chance! 50% off unlimited learning
Sale ends in
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)
The
An
The first column is the explanatory variable, the second column corresponds to the response variable.
A matrix with one row containing an intercept and slope.
P. Segaert
The following hypothesis test is performed:
The test statistic being used is the regression depth of z
with respect to x
.
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")
Run the code above in your browser using DataLab