def summary(self, yname=None, xname=None, title=None, alpha=0.05): df = pd.DataFrame() df["Type"] = (["Mean"] * self.k_exog + ["Scale"] * self.k_scale + ["Smooth"] * self.k_smooth + ["SD"] * self.k_noise) df["coef"] = self.params try: df["std err"] = np.sqrt(np.diag(self.cov_params())) except Exception: df["std err"] = np.nan from scipy.stats.distributions import norm df["tvalues"] = df.coef / df["std err"] df["P>|t|"] = 2 * norm.sf(np.abs(df.tvalues)) f = norm.ppf(1 - alpha / 2) df["[%.3f" % (alpha / 2)] = df.coef - f * df["std err"] df["%.3f]" % (1 - alpha / 2)] = df.coef + f * df["std err"] df.index = self.model.data.param_names summ = summary2.Summary() if title is None: title = "Gaussian process regression results" summ.add_title(title) summ.add_df(df) return summ
def summary(self): df = pd.DataFrame() m = self.model.k_fep + self.model.k_vcp df["Type"] = (["F" for k in range(self.model.k_fep)] + ["R" for k in range(self.model.k_vcp)]) df["Post. Mean"] = self.params[0:m] if self.cov_params.ndim == 2: v = np.diag(self.cov_params)[0:m] df["Post. SD"] = np.sqrt(v) else: df["Post. SD"] = np.sqrt(self.cov_params[0:m]) # Convert variance parameters to natural scale df["VC"] = np.exp(df["Post. Mean"]) df["VC (LB)"] = np.exp(df["Post. Mean"] - 2 * df["Post. SD"]) df["VC (UB)"] = np.exp(df["Post. Mean"] + 2 * df["Post. SD"]) df["VC"] = ["%.3f" % x for x in df.VC] df["VC (LB)"] = ["%.3f" % x for x in df["VC (LB)"]] df["VC (UB)"] = ["%.3f" % x for x in df["VC (UB)"]] df.loc[df.index < self.model.k_fep, "VC"] = "" df.loc[df.index < self.model.k_fep, "VC (LB)"] = "" df.loc[df.index < self.model.k_fep, "VC (UB)"] = "" df.index = self.model.fep_names + self.model.vcp_names summ = summary2.Summary() summ.add_title(self.model.family.__class__.__name__ + " Mixed GLM Results") summ.add_df(df) return summ
def summary(self): summ = summary2.Summary() summ.add_title('Factor analysis results') loadings_no_rot = pd.DataFrame( self.loadings_no_rot, columns=["factor %d" % (i) for i in range(self.loadings_no_rot.shape[1])], index=self.endog_names ) if hasattr(self, "eigenvals"): # eigenvals not available for ML method eigenvals = pd.DataFrame( [self.eigenvals], columns=self.endog_names, index=['']) summ.add_dict({'': 'Eigenvalues'}) summ.add_df(eigenvals) communality = pd.DataFrame([self.communality], columns=self.endog_names, index=['']) summ.add_dict({'': ''}) summ.add_dict({'': 'Communality'}) summ.add_df(communality) summ.add_dict({'': ''}) summ.add_dict({'': 'Pre-rotated loadings'}) summ.add_df(loadings_no_rot) summ.add_dict({'': ''}) if self.rotation_method is not None: loadings = pd.DataFrame( self.loadings, columns=["factor %d" % (i) for i in range(self.loadings.shape[1])], index=self.endog_names ) summ.add_dict({'': '%s rotated loadings' % (self.rotation_method)}) summ.add_df(loadings) return summ
def summary2(self, xname=None, yname=None, title=None, alpha=.05, float_format="%.4f"): """Experimental summary function for regression results Parameters ---------- xname : List of strings of length equal to the number of parameters Names of the independent variables (optional) yname : string Name of the dependent variable (optional) 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 float_format: string print format for floats in parameters summary 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.summary2.Summary : class to hold summary results """ from statsmodels.iolib import summary2 smry = summary2.Summary() smry.add_base(results=self, alpha=alpha, float_format=float_format, xname=xname, yname=yname, title=title) return smry
def summary(self): summ = summary2.Summary() summ.add_title("Regression FDR results") summ.add_df(self.fdr_df) return summ
def summary(self): summ = summary2.Summary() summ.add_title('Cancorr results') summ.add_df(self.stats) summ.add_dict({'': ''}) summ.add_dict({'Multivariate Statistics and F Approximations': ''}) summ.add_df(self.stats_mv) return summ
def summary(self): """create summary results Returns ------- summary : summary2.Summary instance """ summ = summary2.Summary() summ.add_title('Anova') summ.add_df(self.anova_table) return summ
def summary2(self, xname=None, yname=None, title=None, alpha=.05, float_format="%.4f"): """Experimental summary function for regression results Parameters ---------- yname : str Name of the dependent variable (optional) xname : list[str], optional Names for the exogenous variables. Default is `var_##` for ## in the number of regressors. Must match the number of parameters in the model title : str, optional Title for the top table. If not None, then this replaces the default title alpha : float significance level for the confidence intervals float_format : str print format for floats in parameters summary 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.summary2.Summary : class to hold summary results """ from statsmodels.iolib import summary2 smry = summary2.Summary() smry.add_base(results=self, alpha=alpha, float_format=float_format, xname=xname, yname=yname, title=title) return smry
def summary(self, title=None, alpha=.05): """ Summarize the #1lab_results of running MICE. 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. """ from statsmodels.iolib import summary2 from statsmodels.compat.collections import OrderedDict smry = summary2.Summary() float_format = "%8.3f" info = OrderedDict() info["Method:"] = "MICE" info["Model:"] = self.model_class.__name__ info["Dependent variable:"] = self.endog_names info["Sample size:"] = "%d" % self.model.data.data.shape[0] info["Scale"] = "%.2f" % self.scale info["Num. imputations"] = "%d" % len(self.model.results_list) smry.add_dict(info, align='l', float_format=float_format) param = summary2.summary_params(self, alpha=alpha) param["FMI"] = self.frac_miss_info smry.add_df(param, float_format=float_format) smry.add_title(title=title, results=self) return smry
def summary(self, show_contrast_L=False, show_transform_M=False, show_constant_C=False): """ Summary of test results Parameters ---------- show_contrast_L : bool Whether to show contrast_L matrix show_transform_M : bool Whether to show transform_M matrix show_constant_C : bool Whether to show the constant_C """ summ = summary2.Summary() summ.add_title('Multivariate linear model') for key in self.results: summ.add_dict({'': ''}) df = self.results[key]['stat'].copy() df = df.reset_index() c = df.columns.values c[0] = key df.columns = c df.index = ['', '', '', ''] summ.add_df(df) if show_contrast_L: summ.add_dict({key: ' contrast L='}) df = pd.DataFrame(self.results[key]['contrast_L'], columns=self.exog_names) summ.add_df(df) if show_transform_M: summ.add_dict({key: ' transform M='}) df = pd.DataFrame(self.results[key]['transform_M'], index=self.endog_names) summ.add_df(df) if show_constant_C: summ.add_dict({key: ' constant C='}) df = pd.DataFrame(self.results[key]['constant_C']) summ.add_df(df) return summ
def summary(self): df = pd.DataFrame() m = self.model.k_fep + self.model.k_vcp df["Type"] = (["M" for k in range(self.model.k_fep)] + ["V" for k in range(self.model.k_vcp)]) df["Post. Mean"] = self.params[0:m] if self._cov_params.ndim == 2: v = np.diag(self._cov_params)[0:m] df["Post. SD"] = np.sqrt(v) else: df["Post. SD"] = np.sqrt(self._cov_params[0:m]) # Convert variance parameters to natural scale df["SD"] = np.exp(df["Post. Mean"]) df["SD (LB)"] = np.exp(df["Post. Mean"] - 2 * df["Post. SD"]) df["SD (UB)"] = np.exp(df["Post. Mean"] + 2 * df["Post. SD"]) df["SD"] = ["%.3f" % x for x in df.SD] df["SD (LB)"] = ["%.3f" % x for x in df["SD (LB)"]] df["SD (UB)"] = ["%.3f" % x for x in df["SD (UB)"]] df.loc[df.index < self.model.k_fep, "SD"] = "" df.loc[df.index < self.model.k_fep, "SD (LB)"] = "" df.loc[df.index < self.model.k_fep, "SD (UB)"] = "" df.index = self.model.fep_names + self.model.vcp_names summ = summary2.Summary() summ.add_title(self.model.family.__class__.__name__ + " Mixed GLM Results") summ.add_df(df) summ.add_text( "Parameter types are mean structure (M) and variance structure (V)" ) summ.add_text( "Variance parameters are modeled as log standard deviations") return summ
def summary(self, title=None, alpha=.05): """ Summarize the results of running multiple imputation. Parameters ---------- title : str, 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. """ from statsmodels.iolib import summary2 smry = summary2.Summary() float_format = "%8.3f" info = {} info["Method:"] = "MI" info["Model:"] = self.mi.model.__name__ info["Dependent variable:"] = self._model.endog_names info["Sample size:"] = "%d" % self.mi.imp.data.shape[0] info["Num. imputations"] = "%d" % self.mi.nrep smry.add_dict(info, align='l', float_format=float_format) param = summary2.summary_params(self, alpha=alpha) param["FMI"] = self.fmi smry.add_df(param, float_format=float_format) smry.add_title(title=title, results=self) return smry