Repository navigation
Conversation
|
general comment: I think plot functions like this |
|
Examples of the output produced by this code are here: |
|
Moving the backend plotting code to graphics makes sense, but would we I already have some plotting code in MixedLM and GEE which are very On Thu, Oct 2, 2014 at 4:06 PM, Josef Perktold [email protected]
|
We have an ancient open issue for adding the regression plots to the results instance, IIRC. There is also some model specific code for VAR models in tsa. I think it's fine for model specific plots to keep them next to the models. (But a lot of model specific code covers an increasing number of models over time, so "model specific" might not always be the same.) |
|
I am tempted to remove the code that computes summaries and only accept an actual exog matrix or dataframe. The summary calculations would probably be better placed in an expanded predict method. For example, stata's predict lets you fix values for certain variables, with the others defaulting to the mean, max, etc. of the data used to do the fit. |
|
Related: I thought about this or similar recently, #2015 Related to #2015, Stata changed from I'm not clear yet about the details, I went through ATE like calculations once for Poisson, i.e. for log-link. All this here is only relevant for for models where predict is not a linear function of exog, is it? |
|
Maybe the axes should be slightly higher than the histogram so it doesn't hit at the top. |
|
Major refactoring after reconsidering the wisdom of performing the summarizing calculations here. Those calculations instead belong in a future extension of predict, or a new method with another name. So now I require the exog values for which mean curves are generated to be explicitly passed. Some other changes:
The updated test script results are here (the relevant plots for this PR start on page 9): |
|
It would also be nice to auto-detect if focus_var is categorical and adjust the plot accordingly. Also, once our predict methods consistently return confidence intervals we could have an option to add those to the plot. |
|
Just a comment to clarify what this is useful for: It is a plot for visualizing the fitted regression surface. It is not really a diagnostic plot, because it doesn't intend to identify any particular problem with the fit. It is especially useful in nonlinear models (like logistic or Poisson regression), where the effect of one covariate on the scale of the outcome variable depends on the levels of the other covariates. It is seems to be somewhat similar to the existing function 'plot_regress_exog', but that one only works with OLS linear models. |
There was a problem hiding this comment.
Convention for methods that plot is to put plot_ first, so they're easily discoverable.
|
My thinking now is that we don't really need this. Instead, what we need is an enhanced "predict" method that allows a sequence of values for one predictor to be specified, and the other covariates are held fixed at default values (e.g. mean or a percentile). Then it would be easy enough to plot the results without needing a convenience function. I will put that together as a separate PR unless people have other thoughts. I would like to keep the "add_hist" from this PR. |
|
I'm closing this. Will come back later with something analogous to Stata's 'margins'. |
This PR adds a plotting method to the base results class. It should be useful for any regression model that has endog and exog and that implements the predict method. The plot displays the fitted mean response against the value of one "focus" covariate, holding the other "control" covariates fixed at given values. There are two different ways to specify how the "control" covariates are fixed.