weighted_line: Weighted robust line fitting

Description Usage Arguments Details Value See Also Examples

View source: R/robsurvey.R

Description

weighted_line fits a robust line and allows weights.

Usage

1
weighted_line(x, y = NULL, w, na.rm = FALSE, iter = 1)

Arguments

x

a numeric vector (explanatory variable)

y

a numeric vector (response variable)

w

a numeric vector of weights

na.rm

a logical value indicating whether rows with NA values should be stripped before the computation proceeds

iter

number of iterations for enhancing the slope

Details

Uses different quantiles for splitting the sample than line(). Is based on weighted_median().

Value

intercept and slope of the fitted line

See Also

line

Examples

1
2
3
data(cars)
weighted_line(cars$speed, cars$dist, w=rep(1, length(cars$speed)))
weighted_line(cars$speed, cars$dist, w=rep(1:10, each=5))

martinSter/robsurvey documentation built on Oct. 11, 2019, 4:45 p.m.