Repository navigation
Description
(I didn't find an issue directly for automatically creating exog)
We need automatically created exog for prediction as tools to illustrate the effect of explanatory variables.
I'm trying to do this currently for OrderedModel in #7035
-
discrete_margins code has
atcode, but it is mostly for aggregation over sample observations (no prediction on grid, AFAICS) -
sandbox.predict_functionalhas Kerby's code for prediction functions including confint -
GAM has plot_partial to plot only the effect of the spline or smoother
-
I wrote a simple helper function in ENH: Ordinal model rebased2 #7035 but only in notebook, endog is 2-d multi-column, mainly in support of plotting
-
single column focus variable - oneway
simplest case, all we need is a grid and fixed values of others, e.g. at mean. We can directly use model exog. -
single column focus variables - two or multi-way
would be nice for interactions, or splitting continuous prediction across a categorical variable (e.g. effect of age by gender)
needs double grid -
single column focus variables, but aggregated of other variables
This is what margins use, but only for average prediction at a point (or two for effect of dummy/count, ATE)
For functional prediction, i.e. ATE at many different points of a continuous predictor, would need either large memory or loop over grid points -
multi-column terms and predictors
- available in GAM for specific term not included in formula, we control the smooth part
- user provided transformation, we don't have enough info and the user can currently not provide that info
- using formulas, and going through it for prediction
This is used insandbox.predict_functionalbut I never went through the details to see how robust this is.
Main problem is that we need to automatically create something like the user's original exog. - categorical: we can get the relevant info from design_info.
I used it int_test_pairwiseto convert from different encodings, but it is currently not used for prediction. (e.g. in GLM. discrete)
asides:
- location might be statsmodels.base similar to get_predictions
- Results class hierarchy: This does not apply to TSA, at least not directly. We need something separate for non-tsa models. I'm not sure how it would work for proper panel data models, MixedLM and GEE (we only predict fixed effects? averaging over unobserved heterogeneity?).
- extensions to multivariate/multinomial endog: not really directly relevant because this is about creating exog_predict and processing the prediction can be treated separately.
Activity
josef-pkt commentedon Sep 30, 2020
My current version in a notebook for MNLogit and OrderedModel
grid=np.arange(...) works for discrete variables
e.g. predicted probabilities for 3 choices, The focus exog is int from 1 to 7
josef-pkt commentedon Mar 19, 2023
see also similar, newer issue #8439
ENH: Add predict methods to NominalGEE and OrdinalGEE
ENH: Add predict methods to NominalGEE and OrdinalGEE
ENH: Add predict methods to NominalGEE and OrdinalGEE