title: How to add "greater than 0 and sums to 1" constraint to a regression in Python?
body: <p>I am using statsmodels (open to other python options) to run some linear regression. My problem is that I need the regression to have no intercept and constraint the coefficients in the range (0,1) and also sum to 1.</p>
  
  <p>I tried something like this (for the sum of 1, at least):</p>
  
  <pre class="lang-py prettyprint-override"><code>from statsmodels.formula.api import glm
  import pandas as pd
  
  df = pd.DataFrame({'revised_guess':[0.6], "self":[0.55], "alter_1":[0.45], "alter_2":[0.2],"alter_3":[0.8]})
  mod = glm("revised_guess ~ self + alter_1 + alter_2 + alter_3 - 1", data=df)
  res = mod.fit_constrained(["self + alter_1 + alter_2 + alter_3  = 1"],
                            start_params=[0.25,0.25,0.25,0.25])
  res.summary()
  </code></pre>
  
  <p>but still struggling to enforce the 'non-negative' coefficients constraint.</p>