本文整理汇总了Python中statsmodels.iolib.summary.Summary类的典型用法代码示例。如果您正苦于以下问题:Python Summary类的具体用法?Python Summary怎么用?Python Summary使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Summary类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: summary
def summary(self, yname=None, xname=None, title=0, alpha=.05,
return_fmt='text'):
"""
This is for testing the new summary setup
"""
from statsmodels.iolib.summary import (summary_top,
summary_params, summary_return)
## left = [(i, None) for i in (
## 'Dependent Variable:',
## 'Model type:',
## 'Method:',
## 'Date:',
## 'Time:',
## 'Number of Obs:',
## 'df resid',
## 'df model',
## )]
top_left = [('Dep. Variable:', None),
('Model:', None),
('Method:', ['IRLS']),
('Norm:', [self.fit_options['norm']]),
('Scale Est.:', [self.fit_options['scale_est']]),
('Cov Type:', [self.fit_options['cov']]),
('Date:', None),
('Time:', None),
('No. Iterations:', ["%d" % self.fit_history['iteration']])
]
top_right = [('No. Observations:', None),
('Df Residuals:', None),
('Df Model:', None)
]
if not title is None:
title = "Robust linear Model Regression Results"
#boiler plate
from statsmodels.iolib.summary import Summary
smry = Summary()
smry.add_table_2cols(self, gleft=top_left, gright=top_right, #[],
yname=yname, xname=xname, title=title)
smry.add_table_params(self, yname=yname, xname=xname, alpha=.05,
use_t=False)
#diagnostic table is not used yet
# smry.add_table_2cols(self, gleft=diagn_left, gright=diagn_right,
# yname=yname, xname=xname,
# title="")
#add warnings/notes, added to text format only
etext =[]
wstr = \
'''If the model instance has been used for another fit with different fit
parameters, then the fit options might not be the correct ones anymore .'''
etext.append(wstr)
if etext:
smry.add_extra_txt(etext)
return smry
开发者ID:CRP,项目名称:statsmodels,代码行数:60,代码来源:robust_linear_model.py
示例2: summary
def summary(self, yname=None, xname=None, title=0, alpha=0.05, return_fmt="text"):
"""
This is for testing the new summary setup
"""
from statsmodels.iolib.summary import summary_top, summary_params, summary_return
## left = [(i, None) for i in (
## 'Dependent Variable:',
## 'Model type:',
## 'Method:',
## 'Date:',
## 'Time:',
## 'Number of Obs:',
## 'df resid',
## 'df model',
## )]
top_left = [
("Dep. Variable:", None),
("Model:", None),
("Method:", ["IRLS"]),
("Norm:", [self.fit_options["norm"]]),
("Scale Est.:", [self.fit_options["scale_est"]]),
("Cov Type:", [self.fit_options["cov"]]),
("Date:", None),
("Time:", None),
("No. Iterations:", ["%d" % self.fit_history["iteration"]]),
]
top_right = [("No. Observations:", None), ("Df Residuals:", None), ("Df Model:", None)]
if not title is None:
title = "Robust linear Model Regression Results"
# boiler plate
from statsmodels.iolib.summary import Summary
smry = Summary()
smry.add_table_2cols(self, gleft=top_left, gright=top_right, yname=yname, xname=xname, title=title) # [],
smry.add_table_params(self, yname=yname, xname=xname, alpha=alpha, use_t=self.use_t)
# diagnostic table is not used yet
# smry.add_table_2cols(self, gleft=diagn_left, gright=diagn_right,
# yname=yname, xname=xname,
# title="")
# add warnings/notes, added to text format only
etext = []
wstr = """If the model instance has been used for another fit with different fit
parameters, then the fit options might not be the correct ones anymore ."""
etext.append(wstr)
if etext:
smry.add_extra_txt(etext)
return smry
开发者ID:Inoryy,项目名称:statsmodels,代码行数:54,代码来源:robust_linear_model.py
示例3: summary
def summary(self, yname=None, xname=None, title=None, alpha=.05,
yname_list=None):
top_left = [('Dep. Variable:', None),
('Model:', [self.model.__class__.__name__]),
('Method:', ['MLE']),
('Date:', None),
('Time:', None),
('Converged:', ["%s" % self.mle_retvals['converged']])]
top_right = [('No. Observations:', None),
('Log-Likelihood:', None),
]
if title is None:
title = self.model.__class__.__name__ + ' ' + "Regression Results"
#boiler plate
from statsmodels.iolib.summary import Summary
smry = Summary()
# for top of table
smry.add_table_2cols(self, gleft=top_left, gright=top_right, #[],
yname=yname, xname=xname, title=title)
# for parameters, etc
smry.add_table_params(self, yname=yname_list, xname=xname, alpha=alpha,
use_t=True)
return smry
开发者ID:statsmodels,项目名称:statsmodels,代码行数:23,代码来源:example_nbin.py
示例4: summary
def summary(self, yname=None, xname=None, title=0, alpha=0.05, return_fmt='text'):
from statsmodels.iolib.summary import (summary_top, summary_params, summary_return)
top_left = [('Dep. Variable:', None),
('Model:', None),
('Method:', ['Interior Point']),
('Date:', None),
('Time:', None)]
top_right = [('No. Observations:', None),
('Df Residuals:', None),
('Df Model:', None),
('Outer Iterations:', ["%d" % self.fit_history['outer_iterations']]),
('Avg. Inner Iterations:', ["%d" % self.fit_history['avg_inner_iterations']]) ]
if not title is None:
title = "Nonlinear Quantile Regression Results"
from statsmodels.iolib.summary import Summary
smry = Summary()
smry.add_table_2cols(self, gleft=top_left, gright=top_right, yname=yname, xname=xname, title=title)
smry.add_table_params(self, yname=yname, xname=xname, alpha=alpha, use_t=False)
return smry
开发者ID:StefanHubner,项目名称:etrics,代码行数:23,代码来源:NLRQ.py
示例5: summary
def summary(self):
"""Summary of test, containing statistic, p-value and critical values
"""
table_data = [('Test Statistic', '{0:0.3f}'.format(self.stat)),
('P-value', '{0:0.3f}'.format(self.pvalue)),
('Lags', '{0:d}'.format(self.lags))]
title = self._title
if not title:
title = self._test_name + " Results"
table = SimpleTable(table_data, stubs=None, title=title, colwidths=18,
datatypes=[0, 1], data_aligns=("l", "r"))
smry = Summary()
smry.tables.append(table)
cv_string = 'Critical Values: '
cv = self._critical_values.keys()
g = lambda x: float(x.split('%')[0])
cv_numeric = array(lmap(g, cv))
cv_numeric = sort(cv_numeric)
for val in cv_numeric:
p = str(int(val)) + '%'
cv_string += '{0:0.2f}'.format(self._critical_values[p])
cv_string += ' (' + p + ')'
if val != cv_numeric[-1]:
cv_string += ', '
extra_text = ['Trend: ' + TREND_DESCRIPTION[self._trend],
cv_string,
'Null Hypothesis: ' + self.null_hypothesis,
'Alternative Hypothesis: ' + self.alternative_hypothesis]
smry.add_extra_txt(extra_text)
if self._summary_text:
smry.add_extra_txt(self._summary_text)
return smry
开发者ID:VolosSoftware,项目名称:arch,代码行数:37,代码来源:unitroot.py
示例6: summary
def summary(self, yname=None, xname=None, title=0, alpha=.05,
return_fmt='text'):
"""
This is for testing the new summary setup
"""
top_left = [('Dep. Variable:', None),
('Model:', None),
('Method:', ['IRLS']),
('Norm:', [self.fit_options['norm']]),
('Scale Est.:', [self.fit_options['scale_est']]),
('Cov Type:', [self.fit_options['cov']]),
('Date:', None),
('Time:', None),
('No. Iterations:', ["%d" % self.fit_history['iteration']])
]
top_right = [('No. Observations:', None),
('Df Residuals:', None),
('Df Model:', None)
]
if title is not None:
title = "Robust linear Model Regression Results"
# boiler plate
from statsmodels.iolib.summary import Summary
smry = Summary()
smry.add_table_2cols(self, gleft=top_left, gright=top_right,
yname=yname, xname=xname, title=title)
smry.add_table_params(self, yname=yname, xname=xname, alpha=alpha,
use_t=self.use_t)
# add warnings/notes, added to text format only
etext = []
wstr = ("If the model instance has been used for another fit "
"with different fit\n"
"parameters, then the fit options might not be the correct "
"ones anymore .")
etext.append(wstr)
if etext:
smry.add_extra_txt(etext)
return smry
开发者ID:bashtage,项目名称:statsmodels,代码行数:43,代码来源:robust_linear_model.py
示例7: summary
def summary(self, alpha=.05):
"""
Returns a summary table for marginal effects
Parameters
----------
alpha : float
Number between 0 and 1. The confidence intervals have the
probability 1-alpha.
Returns
-------
Summary : SummaryTable
A SummaryTable instance
"""
_check_at_is_all(self.margeff_options)
results = self.results
model = results.model
title = model.__class__.__name__ + " Marginal Effects"
method = self.margeff_options['method']
top_left = [('Dep. Variable:', [model.endog_names]),
('Method:', [method]),
('At:', [self.margeff_options['at']]),]
from statsmodels.iolib.summary import (Summary, summary_params,
table_extend)
exog_names = model.exog_names[:] # copy
smry = Summary()
# sigh, we really need to hold on to this in _data...
_, const_idx = _get_const_index(model.exog)
if const_idx is not None:
exog_names.pop(const_idx)
J = int(getattr(model, "J", 1))
if J > 1:
yname, yname_list = results._get_endog_name(model.endog_names,
None, all=True)
else:
yname = model.endog_names
yname_list = [yname]
smry.add_table_2cols(self, gleft=top_left, gright=[],
yname=yname, xname=exog_names, title=title)
#NOTE: add_table_params is not general enough yet for margeff
# could use a refactor with getattr instead of hard-coded params
# tvalues etc.
table = []
conf_int = self.conf_int(alpha)
margeff = self.margeff
margeff_se = self.margeff_se
tvalues = self.tvalues
pvalues = self.pvalues
if J > 1:
for eq in range(J):
restup = (results, margeff[:,eq], margeff_se[:,eq],
tvalues[:,eq], pvalues[:,eq], conf_int[:,:,eq])
tble = summary_params(restup, yname=yname_list[eq],
xname=exog_names, alpha=alpha, use_t=False,
skip_header=True)
tble.title = yname_list[eq]
# overwrite coef with method name
header = ['', _transform_names[method], 'std err', 'z',
'P>|z|', '[%3.1f%% Conf. Int.]' % (100-alpha*100)]
tble.insert_header_row(0, header)
#from IPython.core.debugger import Pdb; Pdb().set_trace()
table.append(tble)
table = table_extend(table, keep_headers=True)
else:
restup = (results, margeff, margeff_se, tvalues, pvalues, conf_int)
table = summary_params(restup, yname=yname, xname=exog_names,
alpha=alpha, use_t=False, skip_header=True)
header = ['', _transform_names[method], 'std err', 'z',
'P>|z|', '[%3.1f%% Conf. Int.]' % (100-alpha*100)]
table.insert_header_row(0, header)
smry.tables.append(table)
return smry
开发者ID:QuocTran,项目名称:statsmodels,代码行数:80,代码来源:discrete_margins.py
示例8: summary
def summary(self, yname=None, xname=None, title=None, alpha=.05):
"""Summarize the Regression Results
Parameters
-----------
yname : string, optional
Default is `y`
xname : list of strings, optional
Default is `var_##` for ## in p the number of regressors
title : string, optional
Title for the top table. If not None, then this replaces the
default title
alpha : float
significance level for the confidence intervals
Returns
-------
smry : Summary instance
this holds the summary tables and text, which can be printed or
converted to various output formats.
See Also
--------
statsmodels.iolib.summary.Summary : class to hold summary
results
"""
top_left = [('Dep. Variable:', None),
('Model:', None),
('Model Family:', [self.family.__class__.__name__]),
('Link Function:', [self.family.link.__class__.__name__]),
('Method:', ['IRLS']),
('Date:', None),
('Time:', None),
('No. Iterations:', ["%d" % self.fit_history['iteration']]),
]
top_right = [('No. Observations:', None),
('Df Residuals:', None),
('Df Model:', None),
('Scale:', [self.scale]),
('Log-Likelihood:', None),
('Deviance:', ["%#8.5g" % self.deviance]),
('Pearson chi2:', ["%#6.3g" % self.pearson_chi2])
]
if title is None:
title = "Generalized Linear Model Regression Results"
#create summary tables
from statsmodels.iolib.summary import Summary
smry = Summary()
smry.add_table_2cols(self, gleft=top_left, gright=top_right, #[],
yname=yname, xname=xname, title=title)
smry.add_table_params(self, yname=yname, xname=xname, alpha=alpha,
use_t=True)
#diagnostic table is not used yet:
#smry.add_table_2cols(self, gleft=diagn_left, gright=diagn_right,
# yname=yname, xname=xname,
# title="")
return smry
开发者ID:gregcole,项目名称:statsmodels,代码行数:64,代码来源:generalized_linear_model.py
示例9: summary
def summary(self, title = None, alpha = .05):
"""Summarize the Clogit Results
Parameters
-----------
title : string, optional
Title for the top table. If not None, then this replaces the
default title
alpha : float
significance level for the confidence intervals
Returns
-------
smry : Summary instance
this holds the summary tables and text, which can be printed or
converted to various output formats.
See Also
--------
statsmodels.iolib.summary.Summary : class to hold summary
results
"""
top_left = [('Dep. Variable:', None),
('Model:', [self.model.__class__.__name__]),
('Method:', [self.mle_settings['optimizer']]),
('Date:', None),
('Time:', None),
('Converged:', ["%s" % self.mle_retvals['converged']]),
('Iterations:', ["%s" % self.mle_retvals['iterations']]),
('Elapsed time (seg.):',
["%10.4f" % self.model.elapsed_time]),
('Num. alternatives:', [self.model.J])
]
top_right = [
('No. Cases:', [self.nobs]),
('No. Observations:', [self.nobs_bychoice]),
('Df Residuals:', [self.model.df_resid]),
('Df Model:', [self.model.df_model]),
('Log-Likelihood:', None),
('LL-Null:', ["%#8.5g" % self.llnull]),
('Pseudo R-squ.:', ["%#6.4g" % self.prsquared]),
('LLR p-value:', ["%#6.4g" % self.llr_pvalue]),
('Likelihood ratio test:', ["%#8.5g" %self.llrt]),
('AIC:', ["%#8.5g" %self.aic])
]
if title is None:
title = self.model.__class__.__name__ + ' ' + \
"results"
#boiler plate
from statsmodels.iolib.summary import Summary, SimpleTable
smry = Summary()
# for top of table
smry.add_table_2cols(self, gleft=top_left, gright=top_right,
title=title)
# Frequencies of alternatives
mydata = [self.freq_alt, self.perc_alt]
myheaders = self.alt
mytitle = ("")
mystubs = ["Frequencies of alternatives: ", "Percentage:"]
tbl = SimpleTable(mydata, myheaders, mystubs, title = mytitle,
data_fmts = ["%5.2f"])
smry.tables.append(tbl)
# for parameters
smry.add_table_params(self, alpha=alpha, use_t=False)
return smry
开发者ID:max1mn,项目名称:statsmodels,代码行数:74,代码来源:dcm_clogit.py
示例10: summary
def summary(self, yname=None, xname=None, title=None, alpha=.05):
"""
Summarize the fitted model.
Parameters
----------
yname : string, optional
Default is `y`
xname : list of strings, optional
Default is `var_##` for ## in p the number of regressors
title : string, optional
Title for the top table. If not None, then this replaces the
default title
alpha : float
significance level for the confidence intervals
Returns
-------
smry : Summary instance
this holds the summary tables and text, which can be printed or
converted to various output formats.
See Also
--------
statsmodels.iolib.summary.Summary : class to hold summary
results
"""
top_left = [
('Dep. Variable:', None),
('Model:', None),
('Log-Likelihood:', None),
('Method:', [self.method]),
('Date:', None),
('Time:', None),
]
top_right = [
('No. Observations:', None),
('No. groups:', [self.n_groups]),
('Min group size:', [self._group_stats[0]]),
('Max group size:', [self._group_stats[1]]),
('Mean group size:', [self._group_stats[2]]),
]
if title is None:
title = "Conditional Logit Model Regression Results"
# create summary tables
from statsmodels.iolib.summary import Summary
smry = Summary()
smry.add_table_2cols(
self,
gleft=top_left,
gright=top_right, # [],
yname=yname,
xname=xname,
title=title)
smry.add_table_params(
self, yname=yname, xname=xname, alpha=alpha, use_t=self.use_t)
return smry
开发者ID:bashtage,项目名称:statsmodels,代码行数:63,代码来源:conditional_models.py
示例11: summary
def summary(self):
"""
Constructs a summary of the results from a fit model.
Returns
-------
summary : Summary instance
Object that contains tables and facilitated export to text, html or
latex
"""
# Summary layout
# 1. Overall information
# 2. Mean parameters
# 3. Volatility parameters
# 4. Distribution parameters
# 5. Notes
model = self.model
model_name = model.name + " - " + model.volatility.name
# Summary Header
top_left = [
("Dep. Variable:", self._dep_name),
("Mean Model:", model.name),
("Vol Model:", model.volatility.name),
("Distribution:", model.distribution.name),
("Method:", "User-specified Parameters"),
("", ""),
("Date:", self._datetime.strftime("%a, %b %d %Y")),
("Time:", self._datetime.strftime("%H:%M:%S")),
]
top_right = [
("R-squared:", "--"),
("Adj. R-squared:", "--"),
("Log-Likelihood:", "%#10.6g" % self.loglikelihood),
("AIC:", "%#10.6g" % self.aic),
("BIC:", "%#10.6g" % self.bic),
("No. Observations:", self._nobs),
("", ""),
("", ""),
]
title = model_name + " Model Results"
stubs = []
vals = []
for stub, val in top_left:
stubs.append(stub)
vals.append([val])
table = SimpleTable(vals, txt_fmt=fmt_2cols, title=title, stubs=stubs)
# create summary table instance
smry = Summary()
# Top Table
# Parameter table
fmt = fmt_2cols
fmt["data_fmts"][1] = "%18s"
top_right = [("%-21s" % (" " + k), v) for k, v in top_right]
stubs = []
vals = []
for stub, val in top_right:
stubs.append(stub)
vals.append([val])
table.extend_right(SimpleTable(vals, stubs=stubs))
smry.tables.append(table)
stubs = self._names
header = ["coef"]
vals = (self.params,)
formats = [(10, 4)]
pos = 0
param_table_data = []
for _ in range(len(vals[0])):
row = []
for i, val in enumerate(vals):
if isinstance(val[pos], np.float64):
converted = format_float_fixed(val[pos], *formats[i])
else:
converted = val[pos]
row.append(converted)
pos += 1
param_table_data.append(row)
mc = self.model.num_params
vc = self.model.volatility.num_params
dc = self.model.distribution.num_params
counts = (mc, vc, dc)
titles = ("Mean Model", "Volatility Model", "Distribution")
total = 0
for title, count in zip(titles, counts):
if count == 0:
continue
table_data = param_table_data[total : total + count]
table_stubs = stubs[total : total + count]
total += count
table = SimpleTable(table_data, stubs=table_stubs, txt_fmt=fmt_params, headers=header, title=title)
smry.tables.append(table)
#.........这里部分代码省略.........
开发者ID:Hong-Lin,项目名称:arch,代码行数:101,代码来源:base.py
示例12: summary
def summary(self):
"""
Summarize the fitted Model
Returns
-------
smry : Summary instance
This holds the summary table and text, which can be printed or
converted to various output formats.
See Also
--------
statsmodels.iolib.summary.Summary
"""
from statsmodels.iolib.summary import Summary
from statsmodels.iolib.table import SimpleTable
model = self.model
title = model.__class__.__name__ + ' Model Results'
dep_variable = 'endog'
if isinstance(self.model.endog, pd.DataFrame):
dep_variable = self.model.endog.columns[0]
elif isinstance(self.model.endog, pd.Series):
dep_variable = self.model.endog.name
seasonal_periods = None if self.model.seasonal is None else self.model.seasonal_periods
lookup = {'add': 'Additive', 'additive': 'Additive',
'mul': 'Multiplicative', 'multiplicative': 'Multiplicative', None: 'None'}
transform = self.params['use_boxcox']
box_cox_transform = True if transform else False
box_cox_coeff = transform if isinstance(transform, string_types) else self.params['lamda']
if isinstance(box_cox_coeff, float):
box_cox_coeff = '{:>10.5f}'.format(box_cox_coeff)
top_left = [('Dep. Variable:', [dep_variable]),
('Model:', [model.__class__.__name__]),
('Optimized:', [str(np.any(self.optimized))]),
('Trend:', [lookup[self.model.trend]]),
('Seasonal:', [lookup[self.model.seasonal]]),
('Seasonal Periods:', [str(seasonal_periods)]),
('Box-Cox:', [str(box_cox_transform)]),
('Box-Cox Coeff.:', [str(box_cox_coeff)])]
top_right = [
('No. Observations:', [str(len(self.model.endog))]),
('SSE', ['{:5.3f}'.format(self.sse)]),
('AIC', ['{:5.3f}'.format(self.aic)]),
('BIC', ['{:5.3f}'.format(self.bic)]),
('AICC', ['{:5.3f}'.format(self.aicc)]),
('Date:', None),
('Time:', None)]
smry = Summary()
smry.add_table_2cols(self, gleft=top_left, gright=top_right,
title=title)
formatted = self.params_formatted # type: pd.DataFrame
def _fmt(x):
abs_x = np.abs(x)
scale = 1
if abs_x != 0:
scale = int(np.log10(abs_x))
if scale > 4 or scale < -3:
return '{:>20.5g}'.format(x)
dec = min(7 - scale, 7)
fmt = '{{:>20.{0}f}}'.format(dec)
return fmt.format(x)
tab = []
for _, vals in formatted.iterrows():
tab.append([_fmt(vals.iloc[1]),
'{0:>20}'.format(vals.iloc[0]),
'{0:>20}'.format(str(bool(vals.iloc[2])))])
params_table = SimpleTable(tab, headers=['coeff', 'code', 'optimized'],
title="",
stubs=list(formatted.index))
smry.tables.append(params_table)
return smry
开发者ID:statsmodels,项目名称:statsmodels,代码行数:78,代码来源:holtwinters.py
示例13: get_statsmodels_summary
def get_statsmodels_summary(self,
title=None,
alpha=.05):
"""
title: OPTIONAL. string or None. Will be
the title of the returned summary.
If None, the default title is used.
alpha: OPTIONAL. float. Between 0.0 and
1.0. Determines the width of the
displayed, (1 - alpha)% confidence
interval.
====================
Returns: statsmodels.summary object.
"""
try:
# Get the statsmodels Summary class
from statsmodels.iolib.summary import Summary
# Get an instantiation of the Summary class.
smry = Summary()
# Get the yname and yname_list.
# Note I'm not really sure what the yname_list is.
new_yname, new_yname_list = self.choice_col, None
# Get the model name
model_name = self.model_type
##########
# Note the following commands are basically directly from
# statsmodels.discrete.discrete_model
##########
top_left = [('Dep. Variable:', None),
('Model:', [model_name]),
('Method:', ['MLE']),
('Date:', None),
('Time:', None),
#('No. iterations:', ["%d" % self.mle_retvals['iterations']]),
('converged:', [str(self.estimation_success)])
]
top_right = [('No. Observations:', ["{:,}".format(self.nobs)]),
('Df Residuals:', ["{:,}".format(self.df_resid)]),
('Df Model:', ["{:,}".format(self.df_model)]),
('Pseudo R-squ.:',
["{:.3f}".format(self.rho_squared)]),
('Pseudo R-bar-squ.:',
["{:.3f}".format(self.rho_bar_squared)]),
('Log-Likelihood:', ["{:,.3f}".format(self.llf)]),
('LL-Null:',
["{:,.3f}".format(self.null_log_likelihood)]),
]
if title is None:
title = model_name + ' ' + "Regression Results"
xnames = self.params.index.tolist()
# for top of table
smry.add_table_2cols(self,
gleft=top_left,
gright=top_right, #[],
yname=new_yname,
xname=xnames,
title=title)
# for parameters, etc
smry.add_table_params(self,
yname=[new_yname_list],
xname=xnames,
alpha=alpha,
use_t=False)
return smry
except:
print("statsmodels not installed. Resorting to standard summary")
return self.print_summaries()
开发者ID:brianhuey,项目名称:pylogit,代码行数:75,代码来源:base_multinomial_cm_v2.py
示例14: summary
def summary(self, yname=None, xname=None, title=None, alpha=.05):
"""Summarize the Regression Results
Parameters
----------
yname : string, optional
Default is `y`
xname : list of strings, optional
Default is `var_##` for ## in p the number of regressors
title : string, optional
Title for the top table. If not None, then this replaces the
default title
alpha : float
significance level for the confidence intervals
Returns
-------
smry : Summary instance
this holds the summary tables and text, which can be printed or
converted to various output formats.
See Also
--------
statsmodels.iolib.summary.Summary : class to hold summary results
"""
eigvals = self.eigenvals
condno = self.condition_number
top_left = [('Dep. Variable:', None),
('Model:', None),
('Method:', ['Least Squares']),
('Date:', None),
('Time:', None)
]
top_right = [('Pseudo R-squared:', ["%#8.4g" % self.prsquared]),
('Bandwidth:', ["%#8.4g" % self.bandwidth]),
('Sparsity:', ["%#8.4g" % self.sparsity]),
('No. Observations:', None),
('Df Residuals:', None),
('Df Model:', None)
]
if title is None:
title = self.model.__class__.__name__ + ' ' + "Regression Results"
# create summary table instance
from statsmodels.iolib.summary import Summary
smry = Summary()
smry.add_table_2cols(self, gleft=top_left, gright=top_right,
yname=yname, xname=xname, title=title)
smry.add_table_params(self, yname=yname, xname=xname, alpha=alpha,
use_t=self.use_t)
# add warnings/notes, added to text format only
etext = []
if eigvals[-1] < 1e-10:
wstr = "The smallest eigenvalue is %6.3g. This might indicate "
wstr += "that there are\n"
wstr += "strong multicollinearity problems or that the design "
wstr += "matrix is singular."
wstr = wstr % eigvals[-1]
etext.append(wstr)
elif condno > 1000: # TODO: what is recommended
wstr = "The condition number is large, %6.3g. This might "
wstr += "indicate that there are\n"
wstr += "strong multicollinearity or other numerical "
wstr += "problems."
wstr = wstr % condno
etext.append(wstr)
if etext:
smry.add_extra_txt(etext)
return smry
开发者ID:bashtage,项目名称:statsmodels,代码行数:75,代码来源:quantile_regression.py
示例15: summary
def summary(self):
"""
Constructs a summary of the results from a fit model.
Returns
-------
summary : Summary instance
Object that contains tables and facilitated export to text, html or
latex
"""
# Summary layout
# 1. Overall information
# 2. Mean parameters
# 3. Volatility parameters
# 4. Distribution parameters
# 5. Notes
model = self.model
model_name = model.name + ' - ' + model.volatility.name
# Summary Header
top_left = [('Dep. Variable:', self._dep_name),
('Mean Model:', model.name),
('Vol Model:', model.volatility.name),
('Distribution:', model.distribution.name),
('Method:', 'Maximum Likelihood'),
('', ''),
('Date:', self._datetime.strftime('%a, %b %d %Y')),
('Time:', self._datetime.strftime('%H:%M:%S'))]
top_right = [('R-squared:', '%#8.3f' % self.rsquared),
('Adj. R-squared:', '%#8.3f' % self.rsquared_adj),
('Log-Likelihood:', '%#10.6g' % self.loglikelihood),
('AIC:', '%#10.6g' % self.aic),
('BIC:', '%#10.6g' % self.bic),
('No. Observations:', self._nobs),
('Df Residuals:', self.nobs - self.num_params),
('Df Model:', self.num_params)]
title = model_name + ' Model Results'
stubs = []
vals = []
for stub, val in top_left:
stubs.append(stub)
vals.append([val])
table = SimpleTable(vals, txt_fmt=fmt_2cols, title=title, stubs=stubs)
# create summary table instance
smry = Summary()
# Top Table
# Parameter table
fmt = fmt_2cols
fmt['data_fmts'][1] = '%18s'
top_right = [('%-21s' % (' ' + k), v) for k, v in top_right]
stubs = []
vals = []
for stub, val in top_right:
stubs.append(stub)
vals.append([val])
table.extend_right(SimpleTable(vals, stubs=stubs))
smry.tables.append(table)
conf_int = np.asarray(self.conf_int())
conf_int_str = []
for c in conf_int:
conf_int_str.append('[' + format_float_fixed(c[0], 7, 3)
+ ',' + format_float_fixed(c[1], 7, 3) + ']')
stubs = self._names
header = ['coef', 'std err', 't', 'P>|t|', '95.0% Conf. Int.']
vals = (self.params,
self.std_err,
self.tvalues,
self.pvalues,
conf_int_str)
formats = [(10, 4), (9, 3), (9, 3), (9, 3), None]
pos = 0
param_table_data = []
for _ in range(len(vals[0])):
row = []
for i, val in enumerate(vals):
if isinstance(val[pos], np.float64):
converted = format_float_fixed(val[pos], *formats[i])
else:
converted = val[pos]
row.append(converted)
pos += 1
param_table_data.append(row)
mc = self.model.num_params
vc = self.model.volatility.num_params
dc = self.model.distribution.num_params
counts = (mc, vc, dc)
titles = ('Mean Model', 'Volatility Model', 'Distribution')
total = 0
for title, count in zip(titles, counts):
if count == 0:
continue
#.........这里部分代码省略.........
开发者ID:q1ang,项目名称:arch,代码行数:101,代码来源:base.py
示例16: summary
def summary(self, alpha=.05, start=None, model_name=None):
"""
Summarize the Model
Parameters
----------
alpha : float, optional
Significance level for the confidence intervals. Default is 0.05.
start : int, optional
Integer of the start observation. Default is 0.
model_name : string
The name of the model used. Default is to use model class name.
Returns
-------
summary : Summary instance
This holds the summary table and text, which can be printed or
converted to various output formats.
See Also
--------
statsmodels.iolib.summary.Summary
"""
from statsmodels.iolib.summary import Summary
model = self.model
title = 'Statespace Model Results'
if start is None:
start = 0
if self.data.dates is not None:
dates = self.data.dates
d = dates[start]
sample = ['%02d-%02d-%02d' % (d.month, d.day, d.year)]
d = dates[-1]
sample += ['- ' + '%02d-%02d-%02d' % (d.month, d.day, d.year)]
else:
sample = [str(start), ' - ' + str(self.model.nobs)]
if model_name is None:
model_name = model.__class__.__name__
top_left = [
('Dep. Variable:', None),
('Model:', [model_name]),
('Date:', None),
('Time:', None),
('Sample:', [sample[0]]),
('', [sample[1]])
]
top_right = [
('No. Observations:', [self.model.nobs]),
('Log Likelihood', ["%#5.3f" % self.llf]),
('AIC', ["%#5.3f" % self.aic]),
('BIC', ["%#5.3f" % self.bic]),
('HQIC', ["%#5.3f" % self.hqic])
]
if hasattr(self, 'cov_type'):
top_left.append(('Covariance Type:', [self.cov_type]))
summary = Summary()
summary.add_table_2cols(self, gleft=top_left, gright=top_right,
title=title)
summary.add_table_params(self, alpha=alpha,
xname=self.data.param_names, use_t=False)
# Add warnings/notes, added to text format only
etext = []
if hasattr(self, 'cov_type'):
etext.append(self.cov_kwds['description'])
if etext:
etext = ["[{0}] {1}".format(i + 1, text)
for i, text in enumerate(etext)]
etext.insert(0, "Warnings:")
summary.add_extra_txt(etext)
return summary
开发者ID:andreas-koukorinis,项目名称:statsmodels,代码行数:79,代码来源:mlemodel.py
示例17: summary
def summary(self, yname=None, xname=None, title=None, alpha=.05):
"""Summarize the Regression Results
Parameters
-----------
yname : string, optional
Default is `y`
xname : list of strings, optional
Default is `var_##` for ## in p the number of regressors
|
请发表评论