Learn R Programming

isodistrreg (version 0.6.0)

isotonic_regression: Isotonic mean regression

Description

Computes isotonic mean regression for numeric responses. When covariates are supplied they determine the ordering; when omitted the responses are assumed pre-sorted (regression on the index). When weights are omitted every observation receives weight 1.

Usage

isotonic_regression(y, X = NULL, weights = NULL, decreasing = FALSE)

Value

Numeric vector of isotonic fitted means, one per observation.

Arguments

y

numeric vector of response values.

X

numeric vector of covariate values, or NULL if responses are pre-sorted.

weights

numeric vector of finite, non-negative weights, at least one of which must be positive, or NULL for equal weights.

decreasing

whether the fit is decreasing in the covariate (default FALSE is increasing, TRUE is decreasing).

Examples

Run this code
isotonic_regression(c(2, 3, 1, 4, 5), X = 1:5)
isotonic_regression(c(3, 2, 4, 1), X = 1:4, weights = c(1, 2, 1, 1))
isotonic_regression(sort(c(3, 1, 2, 5)))
isotonic_regression(sort(c(2, 1, 3)), weights = c(1, 2, 1))

Run the code above in your browser using DataLab