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 ?
brms
, and frankly installing Stan to solve this problem sounds like using a cannon to kill a fly. 2. Bayes gives me a posterior distribution. I only need point estimates for the coefficients (the model goal is prediction, not inference). Of course I can summarise $p (\theta|y)$ by mean, mode, etc. but again, I was thinking of a simple solution. Anyway, I'd accept a Bayesian answer, if there is no simpler way. $\endgroup$