Skip to content

Commit

Permalink
flexible level for CIs in summarize
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathan-taylor committed Jun 4, 2024
1 parent b89b21b commit 692f756
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions ISLP/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,14 @@
sklearn_selection_path)

def summarize(results,
conf_int=False):
conf_int=False,
level=None):
"""
Take a fit statsmodels and summarize it
by returning the usual coefficient estimates,
their standard errors, the usual test
statistics and P-values as well as
(optionally) 95% confidence intervals.
(optionally) confidence intervals.
Based on:
Expand All @@ -46,7 +47,11 @@ def summarize(results,
Include 95% confidence intervals?
"""
tab = results.summary().tables[1]
if level is not None:
conf_int = True
if level is None:
level = 0.95
tab = results.summary(alpha=1-level).tables[1]
results_table = pd.read_html(StringIO(tab.as_html()),
index_col=0,
header=0)[0]
Expand All @@ -58,12 +63,4 @@ def summarize(results,
return results_table[results_table.columns[:-2]]
return results_table

# def poly(X, degree):
# """
# Create columns of design matrix
# for orthogonal polynomial for a given series X
# """

# result = Poly(degree=degree).fit_transform(X)


0 comments on commit 692f756

Please sign in to comment.