How to continue working with "RegressionResultsWrapper"?

618 views
Skip to first unread message

c.b...@posteo.jp

unread,
Dec 20, 2022, 5:46:16 AM12/20/22
to pystat...@googlegroups.com
Hello,

from a linear regression using (os().fit()) I get back an object of type
"<class
'statsmodels.regression.linear_model.RegressionResultsWrapper'>".

I want to work further with it create a pandas dataframe of that results
for later use in a report (e.g. to_excel(), to_markdown(), ...).

I see the wrapper do offer me a "Summery" object which itself has a
"tables" list attribute offering me "SimpleTable". I found methods
"as_text()", "as_csv()", "as_html()" or the attribute "data". The latter
can be used to initialize a pandas.DataFrame.

OK, this works but feels like a hacky workaround. My question is if
there is a more elegant way with methods/attributes I haven't found yet?

The background of my question is that my reporting-pipeline is based on
pandas.DataFrame. I do build docx, xlsx, md including figures out of it.
But maybe there is a better solution then transforming the results into
a pandas.DataFrame?

Kind
Christian

Kevin Sheppard

unread,
Dec 21, 2022, 3:54:11 AM12/21/22
to pystatsmodels
If you want a DataFrame you should probably populate it yourself.  You can get all of the statistics using properties on the results object, e.g., res.params or res.tvalues.



Kevin


Reply all
Reply to author
Forward
0 new messages