This is (I think) a routine question, but I haven't seen an answer here. In the past I had to fit logistic regression models with linear constraints on the coefficients, in the case when some of the predictors were categorical. Until now I've been using
glmnet, which by the way only allows bound constraints ($a_i\leq\beta_i\leq b_i $). However, apart from the limitation on the type of constraints, I find it annoying to be forced to use
glmnet matrix/column specification for data, instead than a more expressive
formula as done in
glm. Also, most of the times I only needed to fit an unregularized logistic regression model ($\lambda=0$). However,
glmnet help warns against fitting the model for a single value of $\lambda$. Thus I had to fit a sequence of models, parameterized by a sequence of $\lambda$, and then extract the model corresponding to $\lambda=0$. It gets boring the $n-$th time you have to do it.
For all these reasons I'm looking into other solutions to fit unregularized logistic regression models, with linear constraints on the coefficients. One could of course derive the objective function for logistic regression (as done here) and then use an optimizer in R which supports convex optimization problems and linear constraints (any suggestions?). However, this is complicated and I'm not sure how I would setup the optimization to take into account the categorical predictors. Is there a simpler way to achieve my goal? If not, can you show me in detail how to do this with optimization ?