Theil_sen: Theil Sen Regression

Description Usage Arguments Details Value References Examples

Description

Compute Theil Sen Regression and Repeated Medians Regression (Siegel)

Usage

1
2
3

Arguments

formula

object of type formula, must be linear

data

optional data frame with the data used in formula in columns

Details

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.

Value

Returns an object of type "lm"

References

- 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.

Examples

 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')

RobustLinearReg documentation built on July 1, 2020, 10:31 p.m.