I have a question regarding the statmodels graphic
module.
Let's assume I have built a linear regression with an interaction term:
import statsmodels.formula.api as smf
reg = smf.ols(data=data,
formula= "y ~ age + C(group, Treatment('a')) + C(gender, Treatment('female')) + weight_del6_relative * pc1")
Now, my goal is to plot a partial regression based on this linear regression for the interaction term.
Is there a way to do so using statsmodels.graphics
?
So far, I have encountered two issues:
- Using plot_partregress does not allow for a regression fit (
reg.fit()
) as an input, and there is no option (or at least I didn't succeed) to specify interaction terms or reference levels for categorical variables. - Using plot_regress_exog or plot_partregress_grid give the desired output of a partial regression for the exog of interest, but returns a figure in which the desired plot is a subplot. so far, I haven't been able to access only the partial regression
Thanks!