Learn R Programming

orQA (version 0.2.1)

misoreg: Apply isotonic regression to each line of a matrix

Description

This function calculates the isotonic regression (assuming an upward trend) for each line of a given matrix with a given vector of weights. It does so by using the C implementation of the pool adjacent violators algorithm provided in the package , looping over the lines of the matrix in compiled C++ code. This implementation is approximately 2 orders of magnitude faster than using apply in R.

Usage

misoreg(data, weights)

Arguments

data
a numeric matrix, for the lines of which we want to calculate the isotonic regression
weights
a vector of same length as the columns of data defining the weights

Value

result
matrix with lines giving the isotonic regression fit for each line of the input matrix assuming an upward trend
weights
vector with original weights

Details

misoreg takes a matrix of values for the lines of which a weighted isotonic regression is to be computed. The weights are assumed to be equal for each line.

References

Barlow, R. E., Bartholomew, D. J., Bremner, J. M., and Brunk, H. D. (1972) "Statistical inference under order restrictions"; Wiley, London.

Robertson, T., Wright,F. T. and Dykstra, R. L. (1988) "Order Restricted Statistical Inference"; Wiley, New York.

Examples

Run this code
x <- matrix(rnorm(4000),nc=4)
w <- c(3,6,3,6)/18
out <- misoreg(x,w)

Run the code above in your browser using DataLab