"""
Results for test_glm.py.

Hard-coded from R or Stata.  Note that some of the remaining discrepancy vs.
Stata may be because Stata uses ML by default unless you specifically ask for
IRLS.
"""
import os

import numpy as np
import pandas as pd

from statsmodels.api import add_constant
from statsmodels.genmod.tests.results import glm_test_resids

# Test Precisions
DECIMAL_4 = 4
DECIMAL_3 = 3
DECIMAL_2 = 2
DECIMAL_1 = 1
DECIMAL_0 = 0


class Longley:
    """
    Longley used for TestGlmGaussian

    Results are from Stata and R.
    """
    def __init__(self):

        self.resids = np.array([
            [267.34002976,  267.34002976,  267.34002976,
             267.34002976, 267.34002976],
            [-94.0139424,   -94.0139424,   -94.0139424,   -94.0139424,
             -94.0139424],
            [46.28716776,   46.28716776,   46.28716776,   46.28716776,
             46.28716776],
            [-410.11462193, -410.11462193, -410.11462193, -410.11462193,
             -410.11462193],
            [309.71459076,  309.71459076,  309.71459076,  309.71459076,
             309.71459076],
            [-249.31121533, -249.31121533, -249.31121533, -249.31121533,
             -249.31121533],
            [-164.0489564,  -164.0489564,  -164.0489564,  -164.0489564,
             -164.0489564],
            [-13.18035687,  -13.18035687,  -13.18035687,  -13.18035687,
             -13.18035687],
            [14.3047726,    14.3047726,    14.3047726,    14.3047726,
             14.3047726],
            [455.39409455,  455.39409455,  455.39409455,  455.39409455,
             455.39409455],
            [-17.26892711,  -17.26892711,  -17.26892711,  -17.26892711,
             -17.26892711],
            [-39.05504252,  -39.05504252,  -39.05504252,  -39.05504252,
             -39.05504252],
            [-155.5499736,  -155.5499736,  -155.5499736,  -155.5499736,
             -155.5499736],
            [-85.67130804,  -85.67130804,  -85.67130804,  -85.67130804,
             -85.67130804],
            [341.93151396,  341.93151396,  341.93151396,  341.93151396,
             341.93151396],
            [-206.75782519, -206.75782519, -206.75782519, -206.75782519,
             -206.75782519]])
        self.null_deviance = 185008826  # taken from R.
        self.params = np.array([
            1.50618723e+01,  -3.58191793e-02,
            -2.02022980e+00, -1.03322687e+00,  -5.11041057e-02,
            1.82915146e+03, -3.48225863e+06])
        self.bse = np.array([
            8.49149258e+01,   3.34910078e-02, 4.88399682e-01,
            2.14274163e-01,   2.26073200e-01,
            4.55478499e+02, 8.90420384e+05])
        self.aic_R = 235.23486961695903  # R adds 2 for dof to AIC
        self.aic_Stata = 14.57717943930524  # stata divides by nobs
        self.deviance = 836424.0555058046   # from R
        self.scale = 92936.006167311629
        self.llf = -109.61743480847952
        self.null_deviance = 185008826  # taken from R. Rpy bug

        self.bic_Stata = 836399.1760177979  # no bic in R?
        self.df_model = 6
        self.df_resid = 9

        # TODO: taken from Stata; not available in sm yet
        self.chi2 = 1981.711859508729

        self.prsquared = 0.90
        self.prsquared_cox_snell = 1.00

        # self.pearson_chi2 = 836424.1293162981   # from Stata (?)
        self.fittedvalues = np.array([
            60055.659970240202, 61216.013942398131,
            60124.71283224225, 61597.114621930756, 62911.285409240052,
            63888.31121532945, 65153.048956395127, 63774.180356866214,
            66004.695227399934, 67401.605905447621,
            68186.268927114084,  66552.055042522494,
            68810.549973595422, 69649.67130804155, 68989.068486039061,
            70757.757825193927])


class GaussianLog:
    """
    Uses generated data.  These results are from R and Stata.
    """
    def __init__(self):
        self.resids = np.array([
            [3.20800000e-04, 3.20800000e-04,
             8.72100000e-04, 3.20800000e-04,   3.20800000e-04],
            [8.12100000e-04,   8.12100000e-04,   2.16350000e-03,
             8.12100000e-04,   8.12100000e-04],
            [-2.94800000e-04,  -2.94800000e-04,  -7.69700000e-04,
             -2.94800000e-04,  -2.94800000e-04],
            [1.40190000e-03,   1.40190000e-03,   3.58560000e-03,
             1.40190000e-03,   1.40190000e-03],
            [-2.30910000e-03,  -2.30910000e-03,  -5.78490000e-03,
             -2.30910000e-03,  -2.30910000e-03],
            [1.10380000e-03,   1.10380000e-03,   2.70820000e-03,
             1.10380000e-03,   1.10380000e-03],
            [-5.14000000e-06,  -5.14000000e-06,  -1.23000000e-05,
             -5.14000000e-06,  -5.14000000e-06],
            [-1.65500000e-04,  -1.65500000e-04,  -3.89200000e-04,
             -1.65500000e-04,  -1.65500000e-04],
            [-7.55400000e-04,  -7.55400000e-04,  -1.73870000e-03,
             -7.55400000e-04,  -7.55400000e-04],
            [-1.39800000e-04,  -1.39800000e-04,  -3.14800000e-04,
             -1.39800000e-04,  -1.39800000e-04],
            [-7.17000000e-04,  -7.17000000e-04,  -1.58000000e-03,
             -7.17000000e-04,  -7.17000000e-04],
            [-1.12200000e-04,  -1.12200000e-04,  -2.41900000e-04,
             -1.12200000e-04,  -1.12200000e-04],
            [3.22100000e-04,   3.22100000e-04,   6.79000000e-04,
             3.22100000e-04,   3.22100000e-04],
            [-3.78000000e-05,  -3.78000000e-05,  -7.79000000e-05,
             -3.78000000e-05,  -3.78000000e-05],
            [5.54500000e-04,   5.54500000e-04,   1.11730000e-03,
             5.54500000e-04,   5.54500000e-04],
            [3.38400000e-04,   3.38400000e-04,   6.66300000e-04,
             3.38400000e-04,   3.38400000e-04],
            [9.72000000e-05,   9.72000000e-05,   1.87000000e-04,
             9.72000000e-05,   9.72000000e-05],
            [-7.92900000e-04,  -7.92900000e-04,  -1.49070000e-03,
             -7.92900000e-04,  -7.92900000e-04],
            [3.33000000e-04,   3.33000000e-04,   6.11500000e-04,
             3.33000000e-04,   3.33000000e-04],
            [-8.35300000e-04,  -8.35300000e-04,  -1.49790000e-03,
             -8.35300000e-04,  -8.35300000e-04],
            [-3.99700000e-04,  -3.99700000e-04,  -6.99800000e-04,
             -3.99700000e-04,  -3.99700000e-04],
            [1.41300000e-04,   1.41300000e-04,   2.41500000e-04,
             1.41300000e-04,   1.41300000e-04],
            [-8.50700000e-04,  -8.50700000e-04,  -1.41920000e-03,
             -8.50700000e-04,  -8.50700000e-04],
            [1.43000000e-06,   1.43000000e-06,   2.33000000e-06,
             1.43000000e-06,   1.43000000e-06],
            [-9.12000000e-05,  -9.12000000e-05,  -1.44900000e-04,
             -9.12000000e-05,  -9.12000000e-05],
            [6.75500000e-04,   6.75500000e-04,   1.04650000e-03,
             6.75500000e-04,   6.75500000e-04],
            [3.97900000e-04,   3.97900000e-04,   6.01100000e-04,
             3.97900000e-04,   3.97900000e-04],
            [1.07000000e-05,   1.07000000e-05,   1.57000000e-05,
             1.07000000e-05,   1.07000000e-05],
            [-8.15200000e-04,  -8.15200000e-04,  -1.17060000e-03,
             -8.15200000e-04,  -8.15200000e-04],
            [-8.46400000e-04,  -8.46400000e-04,  -1.18460000e-03,
             -8.46400000e-04,  -8.46400000e-04],
            [9.91200000e-04,   9.91200000e-04,   1.35180000e-03,
             9.91200000e-04,   9.91200000e-04],
            [-5.07400000e-04,  -5.07400000e-04,  -6.74200000e-04,
             -5.07400000e-04,  -5.07400000e-04],
            [1.08520000e-03,   1.08520000e-03,   1.40450000e-03,
             1.08520000e-03,   1.08520000e-03],
            [9.56100000e-04,   9.56100000e-04,   1.20500000e-03,
             9.56100000e-04,   9.56100000e-04],
            [1.87500000e-03,   1.87500000e-03,   2.30090000e-03,
             1.87500000e-03,   1.87500000e-03],
            [-1.93920000e-03,  -1.93920000e-03,  -2.31650000e-03,
             -1.93920000e-03,  -1.93920000e-03],
            [8.16000000e-04,   8.16000000e-04,   9.48700000e-04,
             8.16000000e-04,   8.16000000e-04],
            [1.01520000e-03,   1.01520000e-03,   1.14860000e-03,
             1.01520000e-03,   1.01520000e-03],
            [1.04150000e-03,   1.04150000e-03,   1.14640000e-03,
             1.04150000e-03,   1.04150000e-03],
            [-3.88200000e-04,  -3.88200000e-04,  -4.15600000e-04,
             -3.88200000e-04,  -3.88200000e-04],
            [9.95900000e-04,   9.95900000e-04,   1.03690000e-03,
             9.95900000e-04,   9.95900000e-04],
            [-6.82800000e-04,  -6.82800000e-04,  -6.91200000e-04,
             -6.82800000e-04,  -6.82800000e-04],
            [-8.11400000e-04,  -8.11400000e-04,  -7.98500000e-04,
             -8.11400000e-04,  -8.11400000e-04],
            [-1.79050000e-03,  -1.79050000e-03,  -1.71250000e-03,
             -1.79050000e-03,  -1.79050000e-03],
            [6.10000000e-04,   6.10000000e-04,   5.66900000e-04,
             6.10000000e-04,   6.10000000e-04],
            [2.52600000e-04,   2.52600000e-04,   2.28100000e-04,
             2.52600000e-04,   2.52600000e-04],
            [-8.62500000e-04,  -8.62500000e-04,  -7.56400000e-04,
             -8.62500000e-04,  -8.62500000e-04],
            [-3.47300000e-04,  -3.47300000e-04,  -2.95800000e-04,
             -3.47300000e-04,  -3.47300000e-04],
            [-7.79000000e-05,  -7.79000000e-05,  -6.44000000e-05,
             -7.79000000e-05,  -7.79000000e-05],
            [6.72000000e-04,   6.72000000e-04,   5.39400000e-04,
             6.72000000e-04,   6.72000000e-04],
            [-3.72100000e-04,  -3.72100000e-04,  -2.89900000e-04,
             -3.72100000e-04,  -3.72100000e-04],
            [-1.22900000e-04,  -1.22900000e-04,  -9.29000000e-05,
             -1.22900000e-04,  -1.22900000e-04],
            [-1.63470000e-03,  -1.63470000e-03,  -1.19900000e-03,
             -1.63470000e-03,  -1.63470000e-03],
            [2.64400000e-04,   2.64400000e-04,   1.88100000e-04,
             2.64400000e-04,   2.64400000e-04],
            [1.79230000e-03,   1.79230000e-03,   1.23650000e-03,
             1.79230000e-03,   1.79230000e-03],
            [-1.40500000e-04,  -1.40500000e-04,  -9.40000000e-05,
             -1.40500000e-04,  -1.40500000e-04],
            [-2.98500000e-04,  -2.98500000e-04,  -1.93600000e-04,
             -2.98500000e-04,  -2.98500000e-04],
            [-9.33100000e-04,  -9.33100000e-04,  -5.86400000e-04,
             -9.33100000e-04,  -9.33100000e-04],
            [9.11200000e-04,   9.11200000e-04,   5.54900000e-04,
             9.11200000e-04,   9.11200000e-04],
            [-1.31840000e-03,  -1.31840000e-03,  -7.77900000e-04,
             -1.31840000e-03,  -1.31840000e-03],
            [-1.30200000e-04,  -1.30200000e-04,  -7.44000000e-05,
             -1.30200000e-04,  -1.30200000e-04],
            [9.09300000e-04,   9.09300000e-04,   5.03200000e-04,
             9.09300000e-04,   9.09300000e-04],
            [-2.39500000e-04,  -2.39500000e-04,  -1.28300000e-04,
             -2.39500000e-04,  -2.39500000e-04],
            [7.15300000e-04,   7.15300000e-04,   3.71000000e-04,
             7.15300000e-04,   7.15300000e-04],
            [5.45000000e-05,   5.45000000e-05,   2.73000000e-05,
             5.45000000e-05,   5.45000000e-05],
            [2.85310000e-03,   2.85310000e-03,   1.38600000e-03,
             2.85310000e-03,   2.85310000e-03],
            [4.63400000e-04,   4.63400000e-04,   2.17800000e-04,
             4.63400000e-04,   4.63400000e-04],
            [2.80900000e-04,   2.80900000e-04,   1.27700000e-04,
             2.80900000e-04,   2.80900000e-04],
            [5.42000000e-05,   5.42000000e-05,   2.38000000e-05,
             5.42000000e-05,   5.42000000e-05],
            [-3.62300000e-04,  -3.62300000e-04,  -1.54000000e-04,
             -3.62300000e-04,  -3.62300000e-04],
            [-1.11900000e-03,  -1.11900000e-03,  -4.59800000e-04,
             -1.11900000e-03,  -1.11900000e-03],
            [1.28900000e-03,   1.28900000e-03,   5.11900000e-04,
             1.28900000e-03,   1.28900000e-03],
            [-1.40820000e-03,  -1.40820000e-03,  -5.40400000e-04,
             -1.40820000e-03,  -1.40820000e-03],
            [-1.69300000e-04,  -1.69300000e-04,  -6.28000000e-05,
             -1.69300000e-04,  -1.69300000e-04],
            [-1.03620000e-03,  -1.03620000e-03,  -3.71000000e-04,
             -1.03620000e-03,  -1.03620000e-03],
            [1.49150000e-03,   1.49150000e-03,   5.15800000e-04,
             1.49150000e-03,   1.49150000e-03],
            [-7.22000000e-05,  -7.22000000e-05,  -2.41000000e-05,
             -7.22000000e-05,  -7.22000000e-05],
            [5.49000000e-04,   5.49000000e-04,   1.76900000e-04,
             5.49000000e-04,   5.49000000e-04],
            [-2.12320000e-03,  -2.12320000e-03,  -6.60400000e-04,
             -2.12320000e-03,  -2.12320000e-03],
            [7.84000000e-06,   7.84000000e-06,   2.35000000e-06,
             7.84000000e-06,   7.84000000e-06],
            [1.15580000e-03,   1.15580000e-03,   3.34700000e-04,
             1.15580000e-03,   1.15580000e-03],
            [4.83400000e-04,   4.83400000e-04,   1.35000000e-04,
             4.83400000e-04,   4.83400000e-04],
            [-5.26100000e-04,  -5.26100000e-04,  -1.41700000e-04,
             -5.26100000e-04,  -5.26100000e-04],
            [-1.75100000e-04,  -1.75100000e-04,  -4.55000000e-05,
             -1.75100000e-04,  -1.75100000e-04],
            [-1.84600000e-03,  -1.84600000e-03,  -4.62100000e-04,
             -1.84600000e-03,  -1.84600000e-03],
            [2.07200000e-04,   2.07200000e-04,   5.00000000e-05,
             2.07200000e-04,   2.07200000e-04],
            [-8.54700000e-04,  -8.54700000e-04,  -1.98700000e-04,
             -8.54700000e-04,  -8.54700000e-04],
            [-9.20000000e-05,  -9.20000000e-05,  -2.06000000e-05,
             -9.20000000e-05,  -9.20000000e-05],
            [5.35700000e-04,   5.35700000e-04,   1.15600000e-04,
             5.35700000e-04,   5.35700000e-04],
            [-7.67300000e-04,  -7.67300000e-04,  -1.59400000e-04,
             -7.67300000e-04,  -7.67300000e-04],
            [-1.79710000e-03,  -1.79710000e-03,  -3.59500000e-04,
             -1.79710000e-03,  -1.79710000e-03],
            [1.10910000e-03,   1.10910000e-03,   2.13500000e-04,
             1.10910000e-03,   1.10910000e-03],
            [-5.53800000e-04,  -5.53800000e-04,  -1.02600000e-04,
             -5.53800000e-04,  -5.53800000e-04],
            [7.48000000e-04,   7.48000000e-04,   1.33400000e-04,
             7.48000000e-04,   7.48000000e-04],
            [4.23000000e-04,   4.23000000e-04,   7.26000000e-05,
             4.23000000e-04,   4.23000000e-04],
            [-3.16400000e-04,  -3.16400000e-04,  -5.22000000e-05,
             -3.16400000e-04,  -3.16400000e-04],
            [-6.63200000e-04,  -6.63200000e-04,  -1.05200000e-04,
             -6.63200000e-04,  -6.63200000e-04],
            [1.33540000e-03,   1.33540000e-03,   2.03700000e-04,
             1.33540000e-03,   1.33540000e-03],
            [-7.81200000e-04,  -7.81200000e-04,  -1.14600000e-04,
             -7.81200000e-04,  -7.81200000e-04],
            [1.67880000e-03,   1.67880000e-03,   2.36600000e-04,
             1.67880000e-03,   1.67880000e-03]])

        self.null_deviance = 56.691617808182208
        self.params = np.array([
            9.99964386e-01, -1.99896965e-02, -1.00027232e-04])
        self.bse = np.array([1.42119293e-04, 1.20276468e-05, 1.87347682e-07])
        self.aic_R = -1103.8187213072656  # adds 2 for dof for scale

        self.aic_Stata = -11.05818072104212  # divides by nobs for e(aic)
        self.deviance = 8.68876986288542e-05
        self.scale = 8.9574946938163984e-07  # from R but e(phi) in Stata
        self.llf = 555.9093606536328
        self.bic_Stata = -446.7014211525822
        self.df_model = 2
        self.df_resid = 97
        self.chi2 = 33207648.86501769   # from Stata not in sm
        self.fittedvalues = np.array([
            2.7181850213327747,  2.664122305869506,
            2.6106125414084405, 2.5576658143523567, 2.5052916730829535,
            2.4534991313100165, 2.4022966718815781, 2.3516922510411282,
            2.3016933031175575, 2.2523067456332542, 2.2035389848154616,
            2.1553959214958001, 2.107882957382607, 2.0610050016905817,
            2.0147664781120667, 1.969171332114154, 1.9242230385457144,
            1.8799246095383746, 1.8362786026854092, 1.7932871294825108,
            1.7509518640143886, 1.7092740518711942, 1.6682545192788105,
            1.6278936824271399, 1.5881915569806042, 1.5491477677552221,
            1.5107615585467538, 1.4730318020945796, 1.4359570101661721,
            1.3995353437472129, 1.3637646233226499, 1.3286423392342188,
            1.2941656621002184, 1.2603314532836074, 1.2271362753947765,
            1.1945764028156565, 1.162647832232141, 1.1313462931621328,
            1.1006672584668622, 1.0706059548334832, 1.0411573732173065,
            1.0123162792324054, 0.98407722347970683, 0.95643455180206194,
            0.92938241545618494, 0.90291478119174029, 0.87702544122826565,
            0.85170802312101246, 0.82695599950720078, 0.80276269772458597,
            0.77912130929465073, 0.75602489926313921, 0.73346641539106316,
            0.71143869718971686, 0.68993448479364294, 0.66894642766589496,
            0.64846709313034534, 0.62848897472617915, 0.60900450038011367,
            0.5900060403922629, 0.57148591523195513, 0.55343640314018494,
            0.5358497475357491, 0.51871816422248385, 0.50203384839536769,
            0.48578898144361343, 0.46997573754920047, 0.45458629007964013,
            0.4396128177740814, 0.42504751072218311, 0.41088257613548018,
            0.39711024391126759, 0.38372277198930843, 0.37071245150195081,
            0.35807161171849949, 0.34579262478494655, 0.33386791026040569,
            0.32228993945183393, 0.31105123954884056, 0.30014439756060574,
            0.28956206405712448, 0.27929695671718968, 0.26934186368570684,
            0.25968964674310463, 0.25033324428976694, 0.24126567414856051,
            0.23248003618867552, 0.22396951477412205, 0.21572738104035141,
            0.20774699500257574, 0.20002180749946474, 0.19254536197598673,
            0.18531129610924435, 0.17831334328122878, 0.17154533390247831,
            0.16500119659068577, 0.15867495920834204, 0.15256074976354628,
            0.14665279717814039, 0.14094543192735109])


class GaussianInverse:
    """
    This test uses generated data.  Results are from R and Stata.
    """
    def __init__(self):
        self.resids = np.array([
            [-5.15300000e-04, -5.15300000e-04,
             5.14800000e-04, -5.15300000e-04,  -5.15300000e-04],
            [-2.12500000e-04,  -2.12500000e-04,   2.03700000e-04,
             -2.12500000e-04,  -2.12500000e-04],
            [-1.71400000e-04,  -1.71400000e-04,   1.57200000e-04,
             -1.71400000e-04,  -1.71400000e-04],
            [1.94020000e-03,   1.94020000e-03,  -1.69710000e-03,
             1.94020000e-03,   1.94020000e-03],
            [-6.81100000e-04,  -6.81100000e-04,   5.66900000e-04,
             -6.81100000e-04,  -6.81100000e-04],
            [1.21370000e-03,   1.21370000e-03,  -9.58800000e-04,
             1.21370000e-03,   1.21370000e-03],
            [-1.51090000e-03,  -1.51090000e-03,   1.13070000e-03,
             -1.51090000e-03,  -1.51090000e-03],
            [3.21500000e-04,   3.21500000e-04,  -2.27400000e-04,
             3.21500000e-04,   3.21500000e-04],
            [-3.18500000e-04,  -3.18500000e-04,   2.12600000e-04,
             -3.18500000e-04,  -3.18500000e-04],
            [3.75600000e-04,   3.75600000e-04,  -2.36300000e-04,
             3.75600000e-04,   3.75600000e-04],
            [4.82300000e-04,   4.82300000e-04,  -2.85500000e-04,
             4.82300000e-04,   4.82300000e-04],
            [-1.41870000e-03,  -1.41870000e-03,   7.89300000e-04,
             -1.41870000e-03,  -1.41870000e-03],
            [6.75000000e-05,   6.75000000e-05,  -3.52000000e-05,
             6.75000000e-05,   6.75000000e-05],
            [4.06300000e-04,   4.06300000e-04,  -1.99100000e-04,
             4.06300000e-04,   4.06300000e-04],
            [-3.61500000e-04,  -3.61500000e-04,   1.66000000e-04,
             -3.61500000e-04,  -3.61500000e-04],
            [-2.97400000e-04,  -2.97400000e-04,   1.28000000e-04,
             -2.97400000e-04,  -2.97400000e-04],
            [-9.32700000e-04,  -9.32700000e-04,   3.75800000e-04,
             -9.32700000e-04,  -9.32700000e-04],
            [1.16270000e-03,   1.16270000e-03,  -4.38500000e-04,
             1.16270000e-03,   1.16270000e-03],
            [6.77900000e-04,   6.77900000e-04,  -2.39200000e-04,
             6.77900000e-04,   6.77900000e-04],
            [-1.29330000e-03,  -1.29330000e-03,   4.27000000e-04,
             -1.29330000e-03,  -1.29330000e-03],
            [2.24500000e-04,   2.24500000e-04,  -6.94000000e-05,
             2.24500000e-04,   2.24500000e-04],
            [1.05510000e-03,   1.05510000e-03,  -3.04900000e-04,
             1.05510000e-03,   1.05510000e-03],
            [2.50400000e-04,   2.50400000e-04,  -6.77000000e-05,
             2.50400000e-04,   2.50400000e-04],
            [4.08600000e-04,   4.08600000e-04,  -1.03400000e-04,
             4.08600000e-04,   4.08600000e-04],
            [-1.67610000e-03,  -1.67610000e-03,   3.96800000e-04,
             -1.67610000e-03,  -1.67610000e-03],
            [7.47600000e-04,   7.47600000e-04,  -1.65700000e-04,
             7.47600000e-04,   7.47600000e-04],
            [2.08200000e-04,   2.08200000e-04,  -4.32000000e-05,
             2.08200000e-04,   2.08200000e-04],
            [-8.00800000e-04,  -8.00800000e-04,   1.55700000e-04,
             -8.00800000e-04,  -8.00800000e-04],
            [5.81200000e-04,   5.81200000e-04,  -1.05900000e-04,
             5.81200000e-04,   5.81200000e-04],
            [1.00980000e-03,   1.00980000e-03,  -1.72400000e-04,
             1.00980000e-03,   1.00980000e-03],
            [2.77400000e-04,   2.77400000e-04,  -4.44000000e-05,
             2.77400000e-04,   2.77400000e-04],
            [-5.02800000e-04,  -5.02800000e-04,   7.55000000e-05,
             -5.02800000e-04,  -5.02800000e-04],
            [2.69800000e-04,   2.69800000e-04,  -3.80000000e-05,
             2.69800000e-04,   2.69800000e-04],
            [2.01300000e-04,   2.01300000e-04,  -2.67000000e-05,
             2.01300000e-04,   2.01300000e-04],
            [-1.19690000e-03,  -1.19690000e-03,   1.48900000e-04,
             -1.19690000e-03,  -1.19690000e-03],
            [-6.94200000e-04,  -6.94200000e-04,   8.12000000e-05,
             -6.94200000e-04,  -6.94200000e-04],
            [5.65500000e-04,   5.65500000e-04,  -6.22000000e-05,
             5.65500000e-04,   5.65500000e-04],
            [4.93100000e-04,   4.93100000e-04,  -5.10000000e-05,
             4.93100000e-04,   4.93100000e-04],
            [3.25000000e-04,   3.25000000e-04,  -3.17000000e-05,
             3.25000000e-04,   3.25000000e-04],
            [-7.70200000e-04,  -7.70200000e-04,   7.07000000e-05,
             -7.70200000e-04,  -7.70200000e-04],
            [2.58000000e-05,   2.58000000e-05,  -2.23000000e-06,
             2.58000000e-05,   2.58000000e-05],
            [-1.52800000e-04,  -1.52800000e-04,   1.25000000e-05,
             -1.52800000e-04,  -1.52800000e-04],
            [4.52000000e-05,   4.52000000e-05,  -3.48000000e-06,
             4.52000000e-05,   4.52000000e-05],
            [-6.83900000e-04,  -6.83900000e-04,   4.97000000e-05,
             -6.83900000e-04,  -6.83900000e-04],
            [-7.77600000e-04,  -7.77600000e-04,   5.34000000e-05,
             -7.77600000e-04,  -7.77600000e-04],
            [1.03170000e-03,   1.03170000e-03,  -6.70000000e-05,
             1.03170000e-03,   1.03170000e-03],
            [1.20000000e-03,   1.20000000e-03,  -7.37000000e-05,
             1.20000000e-03,   1.20000000e-03],
            [-7.71600000e-04,  -7.71600000e-04,   4.48000000e-05,
             -7.71600000e-04,  -7.71600000e-04],
            [-3.37000000e-04,  -3.37000000e-04,   1.85000000e-05,
             -3.37000000e-04,  -3.37000000e-04],
            [1.19880000e-03,   1.19880000e-03,  -6.25000000e-05,
             1.19880000e-03,   1.19880000e-03],
            [-1.54610000e-03,  -1.54610000e-03,   7.64000000e-05,
             -1.54610000e-03,  -1.54610000e-03],
            [9.11600000e-04,   9.11600000e-04,  -4.27000000e-05,
             9.11600000e-04,   9.11600000e-04],
            [-4.70800000e-04,  -4.70800000e-04,   2.09000000e-05,
             -4.70800000e-04,  -4.70800000e-04],
            [-1.21550000e-03,  -1.21550000e-03,   5.13000000e-05,
             -1.21550000e-03,  -1.21550000e-03],
            [1.09160000e-03,   1.09160000e-03,  -4.37000000e-05,
             1.09160000e-03,   1.09160000e-03],
            [-2.72000000e-04,  -2.72000000e-04,   1.04000000e-05,
             -2.72000000e-04,  -2.72000000e-04],
            [-7.84500000e-04,  -7.84500000e-04,   2.84000000e-05,
             -7.84500000e-04,  -7.84500000e-04],
            [1.53330000e-03,   1.53330000e-03,  -5.28000000e-05,
             1.53330000e-03,   1.53330000e-03],
            [-1.84450000e-03,  -1.84450000e-03,   6.05000000e-05,
             -1.84450000e-03,  -1.84450000e-03],
            [1.68550000e-03,   1.68550000e-03,  -5.26000000e-05,
             1.68550000e-03,   1.68550000e-03],
            [-3.06100000e-04,  -3.06100000e-04,   9.10000000e-06,
             -3.06100000e-04,  -3.06100000e-04],
            [1.00950000e-03,   1.00950000e-03,  -2.86000000e-05,
             1.00950000e-03,   1.00950000e-03],
            [5.22000000e-04,   5.22000000e-04,  -1.41000000e-05,
             5.22000000e-04,   5.22000000e-04],
            [-2.18000000e-05,  -2.18000000e-05,   5.62000000e-07,
             -2.18000000e-05,  -2.18000000e-05],
            [-7.80600000e-04,  -7.80600000e-04,   1.92000000e-05,
             -7.80600000e-04,  -7.80600000e-04],
            [6.81400000e-04,   6.81400000e-04,  -1.60000000e-05,
             6.81400000e-04,   6.81400000e-04],
            [-1.43800000e-04,  -1.43800000e-04,   3.23000000e-06,
             -1.43800000e-04,  -1.43800000e-04],
            [7.76000000e-04,   7.76000000e-04,  -1.66000000e-05,
             7.76000000e-04,   7.76000000e-04],
            [2.54900000e-04,   2.54900000e-04,  -5.22000000e-06,
             2.54900000e-04,   2.54900000e-04],
            [5.77500000e-04,   5.77500000e-04,  -1.13000000e-05,
             5.77500000e-04,   5.77500000e-04],
            [7.58100000e-04,   7.58100000e-04,  -1.42000000e-05,
             7.58100000e-04,   7.58100000e-04],
            [-8.31000000e-04,  -8.31000000e-04,   1.49000000e-05,
             -8.31000000e-04,  -8.31000000e-04],
            [-2.10340000e-03,  -2.10340000e-03,   3.62000000e-05,
             -2.10340000e-03,  -2.10340000e-03],
            [-8.89900000e-04,  -8.89900000e-04,   1.47000000e-05,
             -8.89900000e-04,  -8.89900000e-04],
            [1.08570000e-03,   1.08570000e-03,  -1.71000000e-05,
             1.08570000e-03,   1.08570000e-03],
            [-1.88600000e-04,  -1.88600000e-04,   2.86000000e-06,
             -1.88600000e-04,  -1.88600000e-04],
            [9.10000000e-05,   9.10000000e-05,  -1.32000000e-06,
             9.10000000e-05,   9.10000000e-05],
            [1.07700000e-03,   1.07700000e-03,  -1.50000000e-05,
             1.07700000e-03,   1.07700000e-03],
            [9.04100000e-04,   9.04100000e-04,  -1.21000000e-05,
             9.04100000e-04,   9.04100000e-04],
            [-2.20000000e-04,  -2.20000000e-04,   2.83000000e-06,
             -2.20000000e-04,  -2.20000000e-04],
            [-1.64030000e-03,  -1.64030000e-03,   2.02000000e-05,
             -1.64030000e-03,  -1.64030000e-03],
            [2.20600000e-04,   2.20600000e-04,  -2.62000000e-06,
             2.20600000e-04,   2.20600000e-04],
            [-2.78300000e-04,  -2.78300000e-04,   3.17000000e-06,
             -2.78300000e-04,  -2.78300000e-04],
            [-4.93000000e-04,  -4.93000000e-04,   5.40000000e-06,
             -4.93000000e-04,  -4.93000000e-04],
            [-1.85000000e-04,  -1.85000000e-04,   1.95000000e-06,
             -1.85000000e-04,  -1.85000000e-04],
            [-7.64000000e-04,  -7.64000000e-04,   7.75000000e-06,
             -7.64000000e-04,  -7.64000000e-04],
            [7.79600000e-04,   7.79600000e-04,  -7.61000000e-06,
             7.79600000e-04,   7.79600000e-04],
            [2.88400000e-04,   2.88400000e-04,  -2.71000000e-06,
             2.88400000e-04,   2.88400000e-04],
            [1.09370000e-03,   1.09370000e-03,  -9.91000000e-06,
             1.09370000e-03,   1.09370000e-03],
            [3.07000000e-04,   3.07000000e-04,  -2.68000000e-06,
             3.07000000e-04,   3.07000000e-04],
            [-8.76000000e-04,  -8.76000000e-04,   7.37000000e-06,
             -8.76000000e-04,  -8.76000000e-04],
            [-1.85300000e-04,  -1.85300000e-04,   1.50000000e-06,
             -1.85300000e-04,  -1.85300000e-04],
            [3.24700000e-04,   3.24700000e-04,  -2.54000000e-06,
             3.24700000e-04,   3.24700000e-04],
            [4.59600000e-04,   4.59600000e-04,  -3.47000000e-06,
             4.59600000e-04,   4.59600000e-04],
            [-2.73300000e-04,  -2.73300000e-04,   1.99000000e-06,
             -2.73300000e-04,  -2.73300000e-04],
            [1.32180000e-03,   1.32180000e-03,  -9.29000000e-06,
             1.32180000e-03,   1.32180000e-03],
            [-1.32620000e-03,  -1.32620000e-03,   9.00000000e-06,
             -1.32620000e-03,  -1.32620000e-03],
            [9.62000000e-05,   9.62000000e-05,  -6.31000000e-07,
             9.62000000e-05,   9.62000000e-05],
            [-6.04400000e-04,  -6.04400000e-04,   3.83000000e-06,
             -6.04400000e-04,  -6.04400000e-04],
            [-6.66300000e-04,  -6.66300000e-04,   4.08000000e-06,
             -6.66300000e-04,  -6.66300000e-04]])
        self.null_deviance = 6.8088354977561  # from R, Rpy bug
        self.params = np.array([1.00045997,  0.01991666,  0.00100126])
        self.bse = np.array([4.55214070e-04, 7.00529313e-05, 1.84478509e-06])
        self.aic_R = -1123.1528237643774
        self.aic_Stata = -11.25152876811373
        self.deviance = 7.1612915365488368e-05
        self.scale = 7.3827747608449547e-07
        self.llf = 565.57641188218872
        self.bic_Stata = -446.7014364279675
        self.df_model = 2
        self.df_resid = 97
        self.chi2 = 2704006.698904491
        self.fittedvalues = np.array([
            0.99954024,  0.97906956,  0.95758077, 0.93526008,  0.91228657,
            0.88882978,  0.8650479,   0.84108646,  0.81707757,  0.79313958,
            0.76937709,  0.74588129,  0.72273051,  0.69999099,  0.67771773,
            0.65595543,  0.63473944,  0.61409675,  0.59404691,  0.57460297,
            0.55577231,  0.53755742,  0.51995663,  0.50296478,  0.48657379,
            0.47077316,  0.4555505,   0.44089187,  0.42678213,  0.41320529,
            0.40014475,  0.38758348,  0.37550428,  0.36388987,  0.35272306,
            0.34198684,  0.33166446,  0.32173953,  0.31219604,  0.30301842,
            0.29419156,  0.28570085,  0.27753216,  0.26967189,  0.26210695,
            0.25482476,  0.24781324,  0.2410608,   0.23455636,  0.22828931,
            0.22224947,  0.21642715,  0.21081306,  0.20539835,  0.20017455,
            0.19513359,  0.19026777,  0.18556972,  0.18103243,  0.17664922,
            0.1724137,   0.16831977,  0.16436164,  0.16053377,  0.15683086,
            0.15324789,  0.14978003,  0.1464227,   0.14317153,  0.14002232,
            0.13697109,  0.13401403,  0.1311475,   0.12836802,  0.12567228,
            0.1230571,   0.12051944,  0.11805642,  0.11566526,  0.1133433,
            0.11108802,  0.10889699,  0.10676788,  0.10469847,  0.10268664,
            0.10073034,  0.09882763,  0.09697663,  0.09517555,  0.09342267,
            0.09171634,  0.09005498,  0.08843707,  0.08686116,  0.08532585,
            0.08382979,  0.0823717,   0.08095035,  0.07956453,  0.07821311])


class Star98:
    """
    Star98 class used with TestGlmBinomial
    """
    def __init__(self):
        self.params = (
            -0.0168150366,  0.0099254766, -0.0187242148,
            -0.0142385609, 0.2544871730,  0.2406936644,  0.0804086739,
            -1.9521605027, -0.3340864748, -0.1690221685,  0.0049167021,
            -0.0035799644, -0.0140765648, -0.0040049918, -0.0039063958,
            0.0917143006,  0.0489898381,  0.0080407389,  0.0002220095,
            -0.0022492486, 2.9588779262)
        self.bse = (
            4.339467e-04, 6.013714e-04, 7.435499e-04, 4.338655e-04,
