weighted_line: Weighted Robust Line Fitting

View source: R/robline.R

weighted_lineR Documentation

Weighted Robust Line Fitting

Description

weighted_line fits a robust line and allows weights.

Usage

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

Value

intercept and slope of the fitted line

See Also

Overview (of all implemented functions)

line

Examples

data(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)

robsurvey documentation built on Jan. 6, 2023, 5:09 p.m.