ThanksBlair
On Thu, Oct 31, 2013 at 7:49 AM, bsdz <bla...@gmail.com> wrote:
Is it possible to fit a model to a dataframe where the coefficients satisfy certain constraints?For example, say in the model:mod = sm.ols(formula='Lottery ~ Literacy + Wealth + Region', data=df)Is it possible to specify constraints on the coefficients of Literacy and Wealth to be greater than zero say whilst those of Region to be negative?
On Thu, Oct 31, 2013 at 7:49 AM, bsdz <bla...@gmail.com> wrote:
Is it possible to fit a model to a dataframe where the coefficients satisfy certain constraints?For example, say in the model:mod = sm.ols(formula='Lottery ~ Literacy + Wealth + Region', data=df)Is it possible to specify constraints on the coefficients of Literacy and Wealth to be greater than zero say whilst those of Region to be negative?No, inequality constraints are not supported at all.scipy has scipy.optimize.nnls that could be used to find the parameters.
Current linear models, OLS, ..., only use linear algebra and no iterative solvers.One of the main problem why we haven't started yet with inequality constraints that may be binding, is that the resulting statistics, the covariance/uncertainty of the parameter estimates, are not standard, and neither I nor anyone else has yet tried to figure out and implement the details.
On Thu, Oct 31, 2013 at 11:49 AM, bsdz <bla...@gmail.com> wrote:
Is it possible to fit a model to a dataframe where the coefficients satisfy certain constraints?For example, say in the model:mod = sm.ols(formula='Lottery ~ Literacy + Wealth + Region', data=df)Is it possible to specify constraints on the coefficients of Literacy and Wealth to be greater than zero say whilst those of Region to be negative?Not yet in an easy and general way (e.g., non-linear constraints, inequalities), though this is something we're currently working on improving and should be part of a PR soon.