class_docstr: Class to test equality of regression coefficients across groups
  
  This class performs tests whether the linear regression coefficients are
  the same across pre-specified groups. This can be used to test for
  structural breaks at given change points, or for ANOVA style analysis of
  differences in the effect of explanatory variables across groups.
  
  Notes
  -----
  The test is implemented by regression on the original pooled exogenous
  variables and on group dummies times the exogenous regressors.
  
  y_i = X_i beta_i + u_i  for all groups i
  
  The test is for the null hypothesis: beta_i = beta for all i
  against the alternative that at least one beta_i is different.
  
  By default it is assumed that all u_i have the same variance. If the
  keyword option het is True, then it is assumed that the variance is
  group specific. This uses WLS with weights given by the standard errors
  from separate regressions for each group.
  Note: het=True is not sufficiently tested
  
  The F-test assumes that the errors are normally distributed.
  
  
  
  original question from mailing list for equality of coefficients
  across regressions, and example in Stata FAQ
  
  *testing*:
  
  * if constant is the only regressor then the result for the F-test is
    the same as scipy.stats.f_oneway
    (which in turn is verified against NIST for not badly scaled problems)
  * f-test for simple structural break is the same as in original script
  * power and size of test look ok in examples
  * not checked/verified for heteroskedastic case
    - for constant only: ftest result is the same with WLS as with OLS - check?
  
  check: I might be mixing up group names (unique)
         and group id (integers in arange(ngroups)
         not tested for groups that are not arange(ngroups)
         make sure groupnames are always consistently sorted/ordered
         Fixed for getting the results, but groups are not printed yet, still
         inconsistent use for summaries of results.
class_docstr_tok: ["Class","to","test","equality","of","regression","coefficients","across","groups","This","class","performs","tests","whether","the","linear","regression","coefficients","are","the","same","across","pre-specified","groups",".","This","can","be","used","to","test","for","structural","breaks","at","given","change","points",",","or","for","ANOVA","style","analysis","of","differences","in","the","effect","of","explanatory","variables","across","groups",".","Notes","--","--","-","The","test","is","implemented","by","regression","on","the","original","pooled","exogenous","variables","and","on","group","dummies","times","the","exogenous","regressors",".","y_i","=","X_i","beta_i","+","u_i","for","all","groups","i","The","test","is","for","the","null","hypothesis",":","beta_i","=","beta","for","all","i","against","the","alternative","that","at","least","one","beta_i","is","different",".","By","default","it","is","assumed","that","all","u_i","have","the","same","variance",".","If","the","keyword","option","het","is","True",",","then","it","is","assumed","that","the","variance","is","group","specific",".","This","uses","WLS","with","weights","given","by","the","standard","errors","from","separate","regressions","for","each","group",".","Note",":","het=True","is","not","sufficiently","tested","The","F-test","assumes","that","the","errors","are","normally","distributed",".","original","question","from","mailing","list","for","equality","of","coefficients","across","regressions",",","and","example","in","Stata","FAQ","*","testing","*",":","*","if","constant","is","the","only","regressor","then","the","result","for","the","F-test","is","the","same","as","scipy.stats.f_oneway","(","which","in","turn","is","verified","against","NIST","for","not","badly","scaled","problems",")","*","f-test","for","simple","structural","break","is","the","same","as","in","original","script","*","power","and","size","of","test","look","ok","in","examples","*","not","checked\/verified","for","heteroskedastic","case","-","for","constant","only",":","ftest","result","is","the","same","with","WLS","as","with","OLS","-","check","?","check",":","I","might","be","mixing","up","group","names","(","unique",")","and","group","id","(","integers","in","arange","(","ngroups",")","not","tested","for","groups","that","are","not","arange","(","ngroups",")","make","sure","groupnames","are","always","consistently","sorted\/ordered","Fixed","for","getting","the","results",",","but","groups","are","not","printed","yet",",","still","inconsistent","use","for","summaries","of","results","."]
docstr: printable string of summary
  
          
docstr_tok: ["printable","string","of","summary"]
code: def print_summary(self, res):
      """printable string of summary"""
      groupind = res.groups
      # res.fitjoint()  #not really necessary, because called by ftest_summary
      if hasattr(res, "self.summarytable"):
          summtable = self.summarytable
      else:
          _, summtable = res.ftest_summary()
      txt = ""
      # print ft[0]  #skip because table is nicer
      templ = """Table of F-tests for overall or pairwise equality of coefficients'
  %(tab)s
  
  
  Notes: p-values are not corrected for many tests
         (no Bonferroni correction)
         * : reject at 5%% uncorrected confidence level
  Null hypothesis: all or pairwise coefficient are the same'
  Alternative hypothesis: all coefficients are different'
  
  
  Comparison with stats.f_oneway
  %(statsfow)s
  
  
  Likelihood Ratio Test
  %(lrtest)s
  Null model: pooled all coefficients are the same across groups,'
  Alternative model: all coefficients are allowed to be different'
  not verified but looks close to f-test result'
  
  
  OLS parameters by group from individual, separate ols regressions'
  %(olsbg)s
  for group in sorted(res.olsbygroup):
      r = res.olsbygroup[group]
      print group, r.params
  
  
  Check for heteroscedasticity, '
  variance and standard deviation for individual regressions'
  %(grh)s
  variance    ', res.sigmabygroup
  standard dev', np.sqrt(res.sigmabygroup)
  """
  
      from statsmodels.iolib import SimpleTable
  
      resvals = {}
      resvals["tab"] = str(
          SimpleTable(
              [
                  (
                      ["{!r}".format(row[0])]
                      + list(row[1])
                      + ["*"] * (row[1][1] > 0.5).item()
                  )
                  for row in summtable
              ],
              headers=[
                  "pair",
                  "F-statistic",
                  "p-value",
                  "df_denom",
                  "df_num",
              ],
          )
      )
      resvals["statsfow"] = str(
          stats.f_oneway(
              *[res.endog[groupind == gr] for gr in res.unique]
          )
      )
      # resvals['lrtest'] = str(res.lr_test())
      resvals["lrtest"] = str(
          SimpleTable(
              [res.lr_test()],
              headers=["likelihood ratio", "p-value", "df"],
          )
      )
  
      resvals["olsbg"] = str(
          SimpleTable(
              [
                  [group] + res.olsbygroup[group].params.tolist()
                  for group in sorted(res.olsbygroup)
              ]
          )
      )
      resvals["grh"] = str(
          SimpleTable(
              np.vstack([res.sigmabygroup, np.sqrt(res.sigmabygroup)]),
              headers=res.unique.tolist(),
          )
      )
  
      return templ % resvals
  
file_path: statsmodels/statsmodels/sandbox/regression/onewaygls.py
imports: import numpy
  from scipy import stats
  from statsmodels.regression.linear_model import OLS, WLS
label_desc: Use image node_id 6 for calling the OneWayLS obj's underlying member method code with example usage: obj.print_summary(res) and returns: unknown