Description Usage Arguments Details Value References Examples
Compute Theil Sen Regression and Repeated Medians Regression (Siegel)
1 2 3 |
formula |
object of type formula, must be linear |
data |
optional data frame with the data used in formula in columns |
theil_sen_regression
compute linear regression using the Theil–Sen estimator base on the median of the slopes.
siegel_regression
compute linear regression using the repeated median estimator for the slope, propose by Siegel (1982).
The main difference is that siegel_regression
is less sensitive to outliers in the data.
Returns an object of type "lm"
- Theil, H., 1992. A rank-invariant method of linear and polynomial regression analysis. In: Henri Theil’s contributions to economics and econometrics. Springer, pp. 345–381. URL https://doi.org/10.1007/978-94-011-2546-8_20
- Sen, P. K., 1968. Estimates of the regression coefficient based on kendall’s tau. Journal of the American statistical association 63 (324), 1379–1389.
1 2 3 4 5 6 7 8 9 10 11 12 | # create x axis (t)
t <- 1:100
# create values that follow a linear relation with the x axis
x <- rnorm(100,35,4)*t/100
# add some outliers
x[c(10,12,76,34,21)] <- x[c(10,12,76,34,21)] + 40
model <- theil_sen_regression(x~t)
lm_model <- lm(x~t)
# compare linear regression with theil_sen_regression
plot(x~t)
abline(model,col='blue')
abline(lm_model,col='red')
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.