# reg_2d: Isotonic Regression on 2D input. In UniIsoRegression: Unimodal and Isotonic L1, L2 and Linf Regression

## Description

Isotonic regression on weighted or unweighted 2D input with L1, L2 metric and other options.

## Usage

 `1` ``` reg_2d(y_vec, w_vec, metric) ```

## Arguments

 `y_vec` The 2D NumericMatrix of input data that we use to regression. It must be the same size as the w_vec argument. `w_vec` The 2D NumericMatrix of the weight of the input data. The default value is 1 for every entry. It must be the same size as y_vec. `metric` This is an integer input, metric = 1 stands for using L1 metric, metric = 2 stands for using L2 metric

## Details

See the paper about 2D regression in the reference.

## Value

A 2D NumericMatrix of the regression result which has the same size of y_vec.

## Error Messages

• The size of y_vec is 0: Empty data.

• The rows of w_vec doesn't match the rows of y_vec: Data and weight have different number of rows

• The columns of w_vec doesn't match the rows of y_vec: Data and weight have different number of columns

• The entry of w_vec has negative value: Negative weight detected

• Metric input is not in 1,2,3: Metric does not exist

## Author(s)

Zhipeng Xu, Chenkai Sun, Aman Karunakaran, Quentin Stout xzhipeng@umich.edu https://github.com/xzp1995/UniIsoRegression

## References

Q.F. Stout, Isotonic median regression via partitioning, Algorithmica 66 (2013), pp. 93-112 doi.org/10.1007/s00453-012-9628-4

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11 12``` ``` library(UniIsoRegression) #===2d monotonic=== y=matrix(c(2, 4, 3, 1, 5, 7,9,0), nrow=2, ncol=4, byrow = TRUE) weight=matrix(c(1, 10, 3, 9, 5, 7,9,10), nrow=2, ncol=4, byrow = TRUE) #l_1 metric temp=UniIsoRegression::reg_2d(y, weight, metric = 1) print(temp) #l_2 metric temp=UniIsoRegression::reg_2d(y, weight, metric = 2) print(temp) ```

### Example output

```     [,1] [,2] [,3] [,4]
[1,]    2    3    3    3
[2,]    5    7    7    7
[,1]     [,2]     [,3]     [,4]
[1,]    2 2.636364 2.636364 2.636364
[2,]    5 5.000000 5.000000 5.000000
```

UniIsoRegression documentation built on May 1, 2019, 7:05 p.m.