Learn R Programming

robsurvey (version 0.7)

weighted_median_ratio: Weighted Robust Ratio Estimator Based on Median

Description

A weighted median of the ratios y/x determines the slope of a regression through the origin.

Usage

weighted_median_ratio(x, y = NULL, w, na.rm = FALSE)

Value

A vector with two components: intercept and slope

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

See Also

Overview (of all implemented functions)

line, weighted_line and weighted_median_line

Examples

Run this code
x <- c(1,2,4,5)
y <- c(1,0,5,2)
m <- weighted_median_ratio(y ~ x, w = rep(1, length(y)))
m
coef(m)
fitted(m)
residuals(m)

Run the code above in your browser using DataLab