powered by
weighted_line fits a robust line and allows weights.
weighted_line
weighted_line(x, y = NULL, w, na.rm = FALSE, iter = 1)
a numeric vector (explanatory variable)
a numeric vector (response variable)
a numeric vector of weights
a logical value indicating whether rows with NA values should be stripped before the computation proceeds
NA
number of iterations for enhancing the slope
intercept and slope of the fitted line
Uses different quantiles for splitting the sample than line(). Is based on weighted_median().
line()
weighted_median()
line
# 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