R code for Shape-Restricted Regression

SHAPE-RESTRICTED LEAST-SQUARES REGRESSION

"Constraints-only" -- no smoothing.

PART I: Unsmoothed monotone (isotonic) regression

Given a data vector y in &realn, minimize ||y &minus &phi||2 , over &phi1 &le &phi2 &le ... &le &phin

The following code has argument y, and returns the least-squares nondecreasing solution.

R code for monotone regression


PART II: Unsmoothed convex regression

Given a scatterplot of data vector (x,y) where x,y in &realn, minimize ||y &minus &phi||2 , over A&phi&ge 0, where the non-zero elements of the (n-2) by n constraint matrix A are

Ai,i=xi+2 &minus xi+1; Ai,i+1=xi &minus xi+2; and Ai,i+2=xi+1 &minus xi, for i=1,...n-2.

The following code has arguments x and y and returns the solution.

R code for convex regression


PART III: Unsmoothed monotone increasing and convex regression

Given a scatterplot of data vector (x,y) where x,y in &realn, minimize ||y &minus &phi||2 , over A&phi&ge 0, where the non-zero elements of the (n-1) by n constraint matrix A are

Ai,i=xi+2 &minus xi+1; Ai,i+1=xi &minus xi+2; Ai,i+2=xi+1 &minus xi for i=1,...n-2, and An-1,1=-1; An-1,2=1.

The following code has arguments x and y and returns the solution.

R code for increasing monotone convex regression


PART IV: Unsmoothed monotone decreasing and convex regression

Given a scatterplot of data vector (x,y) where x,y in &realn, minimize ||y &minus &phi||2 , over A&phi&ge 0, where the non-zero elements of the (n-1) by n constraint matrix A are

Ai,i=xi+2 &minus xi+1; Ai,i+1=xi &minus xi+2; Ai,i+2=xi+1 &minus xi for i=1,...n-2, and An-1,n-1=1; An-1,n=-1.

The following code has arguments x and y and returns the solution.

R code for decreasing monotone convex regression



meyer@stat.colostate.edu