-
-
Save avidale/6668635c318aceebe0142de013a4cf77 to your computer and use it in GitHub Desktop.
@jfrasco yes, exactly, L-BFGS-B is a more sophisticated alternative to my method.
@davendw49 please look at the examples above
@davendw49 please look at the examples above
oops, i miss that part.
Hello,
I have used your code for my dataset and it works. Thanks for sharing this. I still needed a bit of help/guidance though. The sklearn linear regression also allows you to use weights (sample_weights). I wanted to know, how can I add sample weights to this code. If you could give me help with that. Use both specific constraints on each coefficient and also use specific weights for each sample. Thank you.
Hi, how to put both constraints together, min beta value should be 1 and sum of all the betas should be equal or less than a particular no
Hi, how to put both constraints together, min beta value should be 1 and sum of all the betas should be equal or less than a particular no
See my example above. -np.identity provides a single 1 for each beta under A, and you will then include the corresponding minimum value in B.
Its not working.
I am putting 2 conditions together:
- min beta value - 1
- sum of all beta <= a no
Please paste your code.
Can I also make intercept positive. if yes, please let me know how? I am using the same code, just making min_coef = 1
@avidale how is the coordinate descent computing the constraints? For example, if I used an interior point solver, it creates a barrier function for inequalities and then a newton line search is used.
EDIT: And what do you mean by "recalculating constraints for every coefficient on each step"?
Thank you very much for sharing. This is what I'm looking for. Is there a way to just constrain specific subset of features and leave everything else as is?
Brilliant solution and well explained. I'm late to the party here but how would one modify this to use weighted-least-squares with constraints?
@avidale Thanks for the quick response. I will try out on other data I have to see how it works, but this should have been a simple case, because my y (The South African All Bond Index), is actually made up of the Xs (the individual components of the ALBI representing the different duration buckets).
I will investigate your suggestion above, but is this an alternative to what your method solves, as this is exactly what I am looking for?