mregnn: Regression with Linear Inequality Restrictions on Predicted...

mregnnR Documentation

Regression with Linear Inequality Restrictions on Predicted Values

Description

The package contains three functions for fitting regressions with inequality restrictions: mregnn is the most general one, allowing basically for any partial orders, mregnnM poses a monotone restriction on the fitted values, mregnnP restricts the predicted values to be positive. Monre details can be found below.

Usage

mregnn(x, y, a)
mregnnM(x, y)
mregnnP(x, y)

Arguments

x

Can be a spline basis.

y

Response.

a

Matrix containing order restrictions.

Details

These functions solve the problem

f(b) = \frac{1}{2}(y - Xb)'(y - Xb)

over all b for which A'Xb ≥q 0. A can be used require the transformation to be non-negative, or increasing, or satisfying any partial order.

Value

xb

Predicted values.

lb

Solution of the dual problem.

f

Value of the target function

References

de Leeuw, J. (2015). Regression with Linear Inequality Restrictions on Predicted Values. http://rpubs.com/deleeuw/78897.

Examples

## Compute the best fitting quadratic polynomial (in black) 
## and monotone quadratic polynomial (in blue)
set.seed(12345)
x <- outer(1:10,1:3,"^")
x <- apply(x,2,function(x)
x - mean(x))
x <- apply (x,2,function(x)
x / sqrt (sum(x ^ 2)))
y <- rowSums(x) + rnorm(10)
plot(x[,1], y, lwd = 3, col = "RED", xlab = "x", ylab = "P(x)")
o <- mregnnM(x,y)
lines(x[,1], o$xb, col = "BLUE", lwd = 2)
xb <- drop(x %*% qr.solve(x,y))
lines(x[,1],xb,col="BLACK", lwd = 2)

## same monotone model through basic mregnn()
difmat <- function (n) {
  m1 <- ifelse(outer(1:(n - 1),1:n,"-") == -1, 1, 0)
  m2 <- ifelse(outer(1:(n - 1),1:n,"-") == 0,-1, 0)
  return (m1 + m2)
}
a <- difmat(nrow(x))      ## order restriction
o2 <- mregnn(x, y, a)

isotone documentation built on March 7, 2023, 6:58 p.m.