MATLAB code for Convex Nonparametric Least Square

The first version of this code was created by Bodhisattva Sen at Columbia University. What is presented here is a slightly adapted version to aid in the estimation of CNLS.

Adaptations done by Andrew L. Johnson

Function to compute the CONVEX Regression of the response y on the data matrix x
Function NEEDS the PACKAGE cvx (see to be installed in the computer

y: the response variable — a column vector of length n
x: the data matrix of the predictors (of size n*p);
Note that the vector of ones is NOT required in the data matrix

th: the value of the fitted response

The function also gives estimates of the sub-gradients at each data point and is stored in the ‘beta1’ matrix

Note that for sample sizes of 200 or more, the function can be very slow!
It involves n(n-1) many constraints





Posted in Code.