# Buggy code
def __init__(
    self,
    t=None,
    F=None,
    sd=None,
    effect=None,
    df_denom=None,
    df_num=None,
    alpha=0.05,
    **kwds,
):
    self.effect = effect  # Let it be None for F
    if F is not None:
        self.distribution = "F"
        self.fvalue = F
        self.statistic = self.fvalue
        self.df_denom = df_denom
        self.df_num = df_num
        self.dist = fdist
        self.dist_args = (df_num, df_denom)
        self.pvalue = fdist.sf(F, df_num, df_denom)
    elif t is not None:
        self.distribution = "t"
        self.tvalue = t
        self.statistic = t  # generic alias
        self.sd = sd
        self.df_denom = df_denom
        self.dist = student_t
        self.dist_args = (df_denom,)
        self.pvalue = self.dist.sf(np.abs(t), df_denom) * 2
    elif "statistic" in kwds:
        # TODO: currently targeted to normal distribution, and chi2
        self.distribution = kwds["distribution"]
        self.statistic = kwds["statistic"]
        self.tvalue = value = kwds["statistic"]  # keep alias
        # TODO: for results instance we decided to use tvalues also for normal
        self.sd = sd
        self.dist = getattr(stats, self.distribution)
        self.dist_args = ()
        if self.distribution is "chi2":
            self.pvalue = self.dist.sf(self.statistic, df_denom)
        else:
            "normal"
            self.pvalue = np.full_like(value, np.nan)
            not_nan = ~np.isnan(value)
            self.pvalue[not_nan] = self.dist.sf(np.abs(value[not_nan])) * 2

    # cleanup
    # should we return python scalar?
    self.pvalue = np.squeeze(self.pvalue)


# Traceback (LinAlgError)
resols2r.wald_test(np.eye(len(resols2r.params)))
---------------------------------------------------------------------------
LinAlgError                               Traceback (most recent call last)
<ipython-input-18-702444fbfca8> in <module>()
----> 1 resols2r.wald_test(np.eye(len(resols2r.params)))

...\statsmodels\base\model.py in wald_test(self, r_matrix, cov_p, scale, invcov, use_f)
1665                                  "dimensions that are asymptotically "
1666                                  "non-normal")
-> 1667             invcov = np.linalg.inv(cov_p)
1668
1669         if (hasattr(self, 'mle_settings') and

...\python-3.4.4.amd64\lib\site-packages\numpy\linalg\linalg.py in inv(a)
524     signature = 'D->D' if isComplexType(t) else 'd->d'
525     extobj = get_linalg_error_extobj(_raise_linalgerror_singular)
--> 526     ainv = _umath_linalg.inv(a, signature=signature, extobj=extobj)
527     return wrap(ainv.astype(result_t, copy=False))
528

...\python-3.4.4.amd64\lib\site-packages\numpy\linalg\linalg.py in _raise_linalgerror_singular(err, flag)
88
89 def _raise_linalgerror_singular(err, flag):
---> 90     raise LinAlgError("Singular matrix")
91
92 def _raise_linalgerror_nonposdef(err, flag):

LinAlgError: Singular matrix

# Fixed code
def __init__(
    self,
    t=None,
    F=None,
    sd=None,
    effect=None,
    df_denom=None,
    df_num=None,
    alpha=0.05,
    **kwds,
):
    self.effect = effect  # Let it be None for F
    if F is not None:
        self.distribution = "F"
        self.fvalue = F
        self.statistic = self.fvalue
        self.df_denom = df_denom
        self.df_num = df_num
        self.dist = fdist
        self.dist_args = (df_num, df_denom)
        self.pvalue = fdist.sf(F, df_num, df_denom)
    elif t is not None:
        self.distribution = "t"
        self.tvalue = t
        self.statistic = t  # generic alias
        self.sd = sd
        self.df_denom = df_denom
        self.dist = student_t
        self.dist_args = (df_denom,)
        self.pvalue = self.dist.sf(np.abs(t), df_denom) * 2
    elif "statistic" in kwds:
        # TODO: currently targeted to normal distribution, and chi2
        self.distribution = kwds["distribution"]
        self.statistic = kwds["statistic"]
        self.tvalue = value = kwds["statistic"]  # keep alias
        # TODO: for results instance we decided to use tvalues also for normal
        self.sd = sd
        self.dist = getattr(stats, self.distribution)
        self.dist_args = kwds.get("dist_args", ())
        if self.distribution is "chi2":
            self.pvalue = self.dist.sf(self.statistic, df_denom)
            self.df_denom = df_denom
        else:
            "normal"
            self.pvalue = np.full_like(value, np.nan)
            not_nan = ~np.isnan(value)
            self.pvalue[not_nan] = self.dist.sf(np.abs(value[not_nan])) * 2

    # cleanup
    # should we return python scalar?
    self.pvalue = np.squeeze(self.pvalue)