mrfDepth (version 1.0.12)

cmltest: Test for linearity of the conditional median in simple regression

Description

A test based on regression depth for linearity of the conditional median z given the simple regression dataset x. The calculation 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.

Usage

cmltest(x, z)

Arguments

x

An \(n\) by 2 regression data matrix. The first column is the explanatory variable, the second column corresponds to the response variable.

z

A parameter vector (intercept and slope).

Value

pval

The \(p\)-value of the hypothesis test.

Details

The following hypothesis test is performed: \(H0\): 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.

References

Van Aelst, Stefan, 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<U+00E4>user Boston, 401--412.

See Also

rdepth, rdepthmedian

Examples

Run this code
# NOT RUN {
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, z = z)
pvalue1

# Lets now test the deepest regression line. 
result <- rdepthmedian(x = stars)
pvalue2 <- cmltest(x = 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