Package 'RobustLinearReg'

Title: Robust Linear Regressions
Description: Provides an easy way to compute the Theil Sehn Regression method and also the Siegel Regression Method which are both robust methods base on the median of slopes between all pairs of data. In contrast with the least squared linear regression, these methods are not sensitive to outliers. Theil, H. (1992) <doi:10.1007/978-94-011-2546-8_20>, Sen, P. K. (1968) <doi:10.1080/01621459.1968.10480934>.
Authors: Santiago I. Hurtado <[email protected]>
Maintainer: Santiago I. Hurtado <[email protected]>
License: GPL-3
Version: 1.2.0
Built: 2024-12-19 06:53:14 UTC
Source: CRAN

Help Index


Theil Sen Regression

Description

Compute Theil Sen Regression and Repeated Medians Regression (Siegel)

Usage

theil_sen_regression(formula, data = NULL)

  siegel_regression(formula, data = NULL)

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

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