Repository navigation
Description
(I didn't find an issue, but I commented on this already)
We need some design_info when we are not directly using patsy's formulas.
current case: GAM creates multi-column terms that need special treatment. Currently this is handled directly in the model and results classes.
To make this more generic we need some additional information for terms that are created by statsmodels, or by the user, in which case the user needs to provide the information.
A generic idea was to allow for exog_extra in models that are user specified terms, similar to using terms like splines or categoricals in the formulas, but under the control of statsmodels without formula parsing.
Current example is polynomial trend in tsa models, and seasonal dummies in VECM.
Another usecase would be if we use patsy for individual terms but then want to combine this term into a full exog used in the models.
Related would be a drop methods for formula terms.
One problem with formula terms is that those are not independent of each other, e.g. dropping a reference category for categoricals depends on the presence of a constant, and it's more complicated with interaction terms.
This is mainly a convenience feature for users, e.g. we can provide additional post-estimation results without the user having to provide the extra information.
Similar to what we can do now with the additional information in patsy's design_info, for example wald_test_terms.
GAM will allow partial prediction, i.e. the contribution of a "term" to the linear predictor.
Another application is margins with respect to a non-linear function in an explanatory variable that is a linear combination of basis functions like polynomials or splines, which we don't have yet.
First part of design_info would be just named terms with index to the relevant columns of exog and of params, plus maybe a reference to the underlying instance that handles that term, e.g. a penalized spline instance.
Activity
josef-pkt commentedon Oct 25, 2018
some links found by chance to using patsy functions that I never looked at
https://stackoverflow.com/questions/38149482/using-ols-function-with-parameters-that-contain-numbers-spaces/38167185#38167185
https://patsy.readthedocs.io/en/latest/expert-model-specification.html
josef-pkt commentedon Oct 31, 2018
link to an old patsy PR for partial predict
pydata/patsy#98
josef-pkt commentedon Jan 16, 2019
a related ENH issue #5370 (comment)
If we have
exog_extra, then we need to combine the given exog with the exog_extra, which requires that we have the data handling (exog_names, and similar) and design_info for the full, concatenated exog.One problem in GAM is how to combine the given linear component exog with the created spline basis functions. It's not a problem with numpy arrays, but we don't have the extra info that we get from pandas, i.e. column names and index, and from patsy's design_info.
GAM is the first case for this, AFAIK, but there will be more if we follow the
exog_extraidea. Then we need a more generic and reusable solution to this.jbrockmendel commentedon May 8, 2019
Does this relate in any way to sandbox/formula.py?