Learn R Programming

robsurvey (version 0.1.0)

weighted_line: 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)

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

Value

intercept and slope of the fitted line

Details

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

See Also

line

Examples

Run this code
# NOT RUN {
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))
# }

Run the code above in your browser using DataLab