1
$\begingroup$

I want to build a logistic regression model on my data, which contains three continuous predictors and a logical response. I need to constrain the regression coefficients to be not less than 0 and sum up to a constant, i.e.,

$$y=\frac {1}{1+e^{-(\beta_1\times x_1+\beta_2 \times x_2+\beta_3 \times x_3)}}$$

$$s.t. \beta_j \geq 0(j=1,2,3)$$

$$ \beta_1+\beta_2+\beta_3=1$$

Is there anyone who knows how to add such constraint in theory? And how can this be done in MATLAB? The following is my test code using the function 'glmfit' which did not have an option to introduce a constraint:

load hospital.mat
dsa = hospital;

Age = dsa.Age;
Weight = dsa.Weight;
Blood = dsa.BloodPressure(:, 1);

Smoker = dsa.Smoker;

mdl = fitglm([Age, Weight, Blood], Smoker, 'Distribution', 'binomial', 'Intercept', false)
$\endgroup$
5
  • $\begingroup$ Sounds like nonlinear programming? In any event, we are all curious as to why you want to do this. $\endgroup$ Jan 25 at 11:57
  • $\begingroup$ I want to use the fitted weights to weighing multiple models in model averaging of classifiers, in which the weights I assume to be nonnegative and constrained in the simplex space. $\endgroup$ Jan 25 at 12:57
  • $\begingroup$ Ok, I guess you realize that classification will probably be worse when you constrain, but depending on sample size, perhaps not. $\endgroup$ Jan 25 at 13:57
  • $\begingroup$ Thank you. I also guess the performance will decline if constraint was considered. But what does you mean by "...but depending on sample size, perhaps not"? It is not clear to me. $\endgroup$ Jan 25 at 14:59
  • $\begingroup$ With small sample sizes, reasonable constraints often reduce variability and thus can provide more accurate estimates. $\endgroup$ Jan 25 at 15:35

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.