Specifying which category to treat as the base with 'statsmodels'

Ok, maybe someone will find this one helpfull. I needed to set a new baseline category for the dependent variable, I had no idea how to do it. I searched and found nothing, so i simply added a "_" for the other categories. If you have 3 categories A, B, C, and you want your baseline to be C you just change the labeles from A and B to _A and _B. It works. I appears that the baseline category is defined by sorted()

Maybe someone knows a proper way to do it, this is not very phytonic, ja.


You can pass a reference arg to the Treatment contrast, using syntax like

"y ~ C(Location, Treatment(reference='China'))"

http://patsy.readthedocs.org/en/latest/API-reference.html#patsy.Treatment

If you have a better suggestion for naming conventions please file an issue with patsy.