Generalized Nearly Isotonic Regression