weighted_line function

Weighted Robust Line Fitting

Weighted Robust Line Fitting

weighted_line fits a robust line and allows weights.

weighted_line(x, y = NULL, w, na.rm = FALSE, iter = 1) ## S3 method for class 'medline' print(x, ...) ## S3 method for class 'medline' coef(object, ...) ## S3 method for class 'medline' residuals(object, ...) ## S3 method for class 'medline' fitted(object, ...)

Arguments

  • x: [numeric vector] explanatory variable.
  • y: [numeric vector] response variable (default: NULL).
  • w: [numeric vector] weights (same length as x).
  • na.rm: [logical] indicating whether NA values should be removed before the computation proceeds (default: FALSE).
  • iter: [integer] number of iterations to use (default: 1).
  • object: object of class medline.
  • ...: additional arguments passed to the method.

Details

weighted_line uses different quantiles for splitting the sample than stats::line().

Returns

intercept and slope of the fitted line

See Also

Overview (of all implemented functions)

line

Examples

head(cars) # compute weighted line weighted_line(cars$speed, cars$dist, w = rep(1, length(cars$speed))) m <- weighted_line(cars$speed, cars$dist, w = rep(1:10, each = 5)) m coef(m) residuals(m) fitted(m)
  • Maintainer: Tobias Schoch
  • License: GPL (>= 2)
  • Last published: 2024-08-22