import numpy as np

from statsmodels.tools.testing import ParamsTableTestBunch

est = dict(
    deviance=18.59164098607571,
    dispers=1.859164098607571,
    deviance_s=18.59164098607571,
    dispers_s=1.859164098607571,
    deviance_p=24.75374834715614,
    dispers_p=2.475374834715614,
    deviance_ps=24.75374834715614,
    dispers_ps=2.475374834715614,
    bic=-9.740492454486454,
    nbml=0,
    N=17,
    ic=3,
    k=7,
    k_eq=1,
    k_dv=1,
    converged=1,
    k_autoCns=0,
    ll=-31.92732830809848,
    chi2=128.8021169250575,
    p=2.29729497374e-25,
    rc=0,
    aic=4.579685683305704,
    rank=7,
    canonical=1,
    power=0,
    df_m=6,
    df=10,
    vf=1,
    phi=1,
    k_eq_model=0,
    properties="b V",
    depvar="executions",
    which="max",
    technique="nr",
    singularHmethod="m-marquardt",
    ml_method="e2",
    crittype="log likelihood",
    user="glim_lf",
    title="Generalized linear models",
    opt="moptimize",
    chi2type="Wald",
    link="glim_l03",
    varfunc="glim_v3",
    m="1",
    a="1",
    oim="oim",
    opt1="ML",
    varfuncf="u",
    varfunct="Poisson",
    linkf="ln(u)",
    linkt="Log",
    vce="oim",
    vcetype="OIM",
    hac_lag="15",
    marginsok="default",
    marginsnotok="stdp Anscombe Cooksd Deviance Hat Likelihood Pearson Response Score Working ADJusted STAndardized STUdentized MODified",
    predict="glim_p",
    cmd="glm",
    cmdline="glm executions income perpoverty perblack LN_VC100k96 south degree, family(poisson)",
)

params_table = np.array([
    .00026110166569,  .00005187148786,  5.0336259178483,  4.812884279e-07,
    .00015943541766,  .00036276791372, np.nan,  1.9599639845401,
    0,  .07781804809828,  .07940260798777,  .98004398180811,
    .32706440886796,  -.0778082038363,  .23344430003287, np.nan,
    1.9599639845401,                0, -.09493110013466,  .02291930335216,
    -4.1419714498302,  .00003443332141, -.13985210925565, -.05001009101367,
    np.nan,  1.9599639845401,                0,  .29693462055586,
    .43751760764129,  .67868038993144,  .49734039404176,  -.5605841330232,
    1.1544533741349, np.nan,  1.9599639845401,                0,
    2.3011832004524,  .42838381728481,  5.3717790159251,  7.796361708e-08,
    1.4615663470144,  3.1408000538904, np.nan,  1.9599639845401,
    0, -18.722067603077,  4.2839791307242, -4.3702518223781,
    .00001241033322, -27.118512409818, -10.325622796337, np.nan,
    1.9599639845401,                0, -6.8014789919532,   4.146873025502,
    -1.6401464308471,  .10097472438129, -14.929200770398,  1.3262427864914,
    np.nan,  1.9599639845401,                0]).reshape(7, 9)

params_table_colnames = "b se z pvalue ll ul df crit eform".split()

params_table_rownames = ["income", "perpoverty", "perblack", "LN_VC100k96",
                         "south", "degree", "_cons"]

cov = np.array([
    2.690651253e-09,  1.942168909e-06,  9.445812833e-08,  4.703695025e-06,
    -6.082922480e-06, -.00008108248895, -.00013492774575,  1.942168909e-06,
    .00630477415526,  .00017467012687,  .00328093520848, -.01768604570302,
    .11117887243846, -.19441636422025,  9.445812833e-08,  .00017467012687,
    .00052529446615, -.00313545508833, -.00516707569472, -.03253594627601,
    .01688876616272,  4.703695025e-06,  .00328093520848, -.00313545508833,
    .19142165699616, -.00179497953339,  .30391667530759, -1.4489146451821,
    -6.082922480e-06, -.01768604570302, -.00516707569472, -.00179497953339,
    .18351269491151,   .3016848477378,  .36484063612427, -.00008108248895,
    .11117887243846, -.03253594627601,  .30391667530759,   .3016848477378,
    18.352477192481, -4.0741043266703, -.00013492774575, -.19441636422025,
    .01688876616272, -1.4489146451821,  .36484063612427, -4.0741043266703,
    17.196555889636]).reshape(7, 7)

cov_colnames = ["income", "perpoverty", "perblack", "LN_VC100k96",
                "south", "degree", "_cons"]

cov_rownames = ["income", "perpoverty", "perblack", "LN_VC100k96",
                "south", "degree", "_cons"]

infocrit = np.array([
    17, np.nan, -31.927328308098,                7,
    77.854656616197,   83.68715002459])

infocrit_colnames = "N ll0 ll df AIC BIC".split()

infocrit_rownames = ".".split()

predicted = np.array([
    35.226364135742,  .16681243479252,  .98022246360779,  8.1965742111206,
    .33106967806816,  .89840310811996,  1.3118965625763,  .29945519566536,
    .11764223873615,  3.6862981319427,  .35516858100891,  .46500706672668,
    2.0823004245758,   .3434439599514,  .24561515450478,  1.0650315284729,
    .62310123443604,  .41350400447845,  1.9260421991348,  .40797635912895,
    .32057955861092,  2.4171404838562,  .36215576529503,  .31702440977097,
    1.8473218679428,   .3869916498661,  .27665960788727,  2.8643238544464,
    .43869277834892,  .55124300718307,  3.1211984157562,  .44224792718887,
    .61045408248901,   3.338207244873,  .42789322137833,  .61120104789734,
    2.5269968509674,  .42458593845367,  .45554983615875,  .89725440740585,
    .59187793731689,  .31432569026947,  .97933322191238,  .37813624739647,
    .14003194868565,  .53462094068527,  .38791963458061,  .08045063912868,
    1.9790935516357,  .31954729557037,  .20208616554737]).reshape(17, 3)

predicted_colnames = "predict_mu predict_linpred_std predict_hat".split()

predicted_rownames = ["r"+str(n) for n in range(1, 18)]

resids = np.array([
    1.773634314537,   1.773634314537,  .29638093709946,  .29637759923935,
    .2988341152668,  .05034962296486,  .80342543125153,  .80342543125153,
    .27623143792152,  .27622014284134,  .28062695264816,  .09801965206861,
    4.6881031990051,  4.6881031990051,  3.0157172679901,   2.977787733078,
    4.0930528640747,  3.5735311508179,  .31370183825493,  .31370183825493,
    .1611547768116,  .16114975512028,  .16338862478733,  .08509942144156,
    .91769951581955,  .91769951581955,  .59656941890717,  .59618371725082,
    .63595855236053,  .44071426987648,   .9349684715271,   .9349684715271,
    .80822360515594,  .80661898851395,  .90597397089005,  .87787866592407,
    .07395775616169,  .07395775616169,  .05295527353883,  .05295492336154,
    .05329062789679,  .03839882463217, -.41714036464691, -.41714036464691,
    -.27668312191963, -.27663832902908,  -.2683065533638, -.17257598042488,
    -.84732186794281, -.84732186794281, -.68459099531174, -.68349820375443,
    -.6234148144722,   -.458675801754, -1.8643238544464, -1.8643238544464,
    -1.2799508571625,  -1.274356007576, -1.1015654802322, -.65087747573853,
    -2.1211984157562, -2.1211984157562, -1.4092296361923, -1.4021278619766,
    -1.2006615400314, -.67961025238037,  -2.338207244873,  -2.338207244873,
    -1.5136297941208, -1.5051733255386, -1.2797535657883, -.70043802261353,
    -1.5269968509674, -1.5269968509674, -1.0992211103439, -1.0954134464264,
    -.9605849981308, -.60427337884903,  .10274560004473,  .10274560004473,
    .10649761557579,   .1064917370677,  .10846894979477,  .11451110988855,
    .02066676132381,  .02066676132381,  .02081091701984,  .02081087417901,
    .02088368684053,  .02110289037228,  .46537905931473,  .46537905931473,
    .56824368238449,  .56713002920151,  .63647866249084,  .87048417329788,
    -.97909361124039, -.97909361124039, -.77151334285736, -.77000600099564,
    -.69597083330154, -.49471819400787]).reshape(17, 6)

resids_colnames = ["score_factor", "resid_response", "resid_anscombe",
                   "resid_deviance", "resid_pearson", "resid_working"]

resids_rownames = ["r"+str(n) for n in range(1, 18)]


results_poisson_none_nonrobust = ParamsTableTestBunch(
    params_table=params_table,
    params_table_colnames=params_table_colnames,
    params_table_rownames=params_table_rownames,
    cov=cov,
    cov_colnames=cov_colnames,
    cov_rownames=cov_rownames,
    infocrit=infocrit,
    infocrit_colnames=infocrit_colnames,
    infocrit_rownames=infocrit_rownames,
    predicted=predicted,
    predicted_colnames=predicted_colnames,
    predicted_rownames=predicted_rownames,
    resids=resids,
    resids_colnames=resids_colnames,
    resids_rownames=resids_rownames,
    **est
)

est = dict(
    deviance=23.34969514421719,
    dispers=.8980651978545075,
    deviance_s=23.34969514421719,
    dispers_s=.8980651978545075,
    deviance_p=30.06164170990202,
    dispers_p=1.156216988842385,
    deviance_ps=30.06164170990202,
    dispers_ps=1.156216988842385,
    bic=-67.5595014539113,
    nbml=0,
    N=33,
    ic=3,
    k=7,
    k_eq=1,
    k_dv=1,
    converged=1,
    k_autoCns=0,
    ll=-52.96941847346162,
    chi2=183.6836771894393,
    p=5.59891844113e-37,
    rc=0,
    aic=3.634510210512826,
    rank=7,
    canonical=1,
    power=0,
    df_m=6,
    df=26,
    vf=1,
    phi=1,
    k_eq_model=0,
    properties="b V",
    depvar="executions",
    which="max",
    technique="nr",
    singularHmethod="m-marquardt",
    ml_method="e2",
    crittype="log likelihood",
    user="glim_lf",
    title="Generalized linear models",
    opt="moptimize",
    chi2type="Wald",
    wtype="fweight",
    wexp="= fweight",
    link="glim_l03",
    varfunc="glim_v3",
    m="1",
    a="1",
    oim="oim",
    opt1="ML",
    varfuncf="u",
    varfunct="Poisson",
    linkf="ln(u)",
    linkt="Log",
    vce="oim",
    vcetype="OIM",
    hac_lag="15",
    marginsok="default",
    marginsnotok="stdp Anscombe Cooksd Deviance Hat Likelihood Pearson Response Score Working ADJusted STAndardized STUdentized MODified",
    predict="glim_p",
    cmd="glm",
    cmdline="glm executions income perpoverty perblack LN_VC100k96 south degree [fweight=fweight], family(poisson)",
)

params_table = np.array([
    .00025343868829,  .00004015414514,  6.3116444744157,  2.760858933e-10,
    .00017473800999,  .00033213936659, np.nan,  1.9599639845401,
    0,  .09081422305585,  .06472607217881,  1.4030547505642,
    .16060051303473, -.03604654727537,  .21767499338706, np.nan,
    1.9599639845401,                0, -.09416451429381,  .01795769655821,
    -5.2436855689475,  1.574003474e-07, -.12936095279319, -.05896807579442,
    np.nan,  1.9599639845401,                0,  .27652273809506,
    .38626128010796,   .7158955669017,  .47405583598111, -.48053545953887,
    1.033580935729, np.nan,  1.9599639845401,                0,
    2.239890838384,  .36339399714255,  6.1638080320445,  7.101602988e-10,
    1.5276516917866,  2.9521299849815, np.nan,  1.9599639845401,
    0, -18.842583191417,   3.736940161486, -5.0422491067996,
    4.600917913e-07,  -26.16685132031, -11.518315062523, np.nan,
    1.9599639845401,                0, -6.5630017977416,  3.2352486362722,
    -2.0285927097411,  .04249979172538, -12.903972605867, -.22203098961573,
    np.nan,  1.9599639845401,                0]).reshape(7, 9)

params_table_colnames = "b se z pvalue ll ul df crit eform".split()

params_table_rownames = ["income", "perpoverty", "perblack", "LN_VC100k96",
                         "south", "degree", "_cons"]

cov = np.array([
    1.612355372e-09,  1.270985149e-06,  8.789752394e-08, -1.636449642e-07,
    -3.213686689e-06, -.00005643188411, -.00006199883309,  1.270985149e-06,
    .0041894644197,  .00016567874308, -.00066453618021, -.00943379587945,
    .07218307550995, -.11262571631082,  8.789752394e-08,  .00016567874308,
    .00032247886568, -.00355795369216, -.00391377556228, -.01880905186772,
    .01900717143416, -1.636449642e-07, -.00066453618021, -.00355795369216,
    .14919777651064,  .02481983169552,  .26952997380446, -.95915288407306,
    -3.213686689e-06, -.00943379587945, -.00391377556228,  .02481983169552,
    .13205519715924,  .44364186152042,  -.0298149336078, -.00005643188411,
    .07218307550995, -.01880905186772,  .26952997380446,  .44364186152042,
    13.964721770527, -3.6510403528048, -.00006199883309, -.11262571631082,
    .01900717143416, -.95915288407306,  -.0298149336078, -3.6510403528048,
    10.466833738501]).reshape(7, 7)

cov_colnames = ["income", "perpoverty", "perblack", "LN_VC100k96",
                "south", "degree", "_cons"]

cov_rownames = ["income", "perpoverty", "perblack", "LN_VC100k96",
                "south", "degree", "_cons"]

infocrit = np.array([
    33, np.nan, -52.969418473462,                7,
    119.93883694692,  130.41438987719])

infocrit_colnames = "N ll0 ll df AIC BIC".split()

infocrit_rownames = ".".split()

predicted = np.array([
    34.815238952637,  .16658315062523,  .96612107753754,  7.3026847839355,
    .32757967710495,  .78363972902298,  1.2540435791016,  .26076200604439,
    .08527097851038,  3.9734709262848,  .24942673742771,  .24720433354378,
    2.0739872455597,  .24682784080505,  .12635557353497,  1.1471545696259,
    .45427960157394,  .23673823475838,  1.7763512134552,  .27608770132065,
    .13540133833885,  2.2698366641998,  .25641229748726,   .1492355465889,
    1.6349502801895,  .27634221315384,  .12485299259424,  2.7504913806915,
    .39550569653511,  .43024495244026,   2.862185716629,  .39729079604149,
    .45176732540131,  3.5617923736572,  .39150056242943,  .54592549800873,
    2.6135795116425,  .29556328058243,  .22831618785858,    .775799036026,
    .40655690431595,  .12823067605495,  .93375068902969,  .29390665888786,
    .08065843582153,  .56681954860687,  .28863781690598,  .04722274839878,
    1.8914022445679,  .21889741718769,  .09062857925892]).reshape(17, 3)

predicted_colnames = "predict_mu predict_linpred_std predict_hat".split()

predicted_rownames = ["r"+str(n) for n in range(1, 18)]

resids = np.array([
    2.1847612857819,  2.1847612857819,  .36650228500366,  .36649596691132,
    .3702706694603,  .06275302171707,  1.6973150968552,  1.6973150968552,
    .60597640275955,  .60585051774979,  .62808901071548,  .23242343962193,
    4.7459564208984,  4.7459564208984,  3.0897438526154,  3.0483965873718,
    4.2380628585815,  3.7845225334167,  .02652905881405,  .02652905881405,
    .01329397037625,  .01329396758229,  .01330873556435,  .00667654490098,
    .92601269483566,  .92601269483566,  .60273587703705,  .60233747959137,
    .64300429821014,  .44648909568787,   .8528453707695,   .8528453707695,
    .72065913677216,  .71955502033234,   .7962681055069,   .7434441447258,
    .22364875674248,  .22364875674248,  .16446639597416,  .16445553302765,
    .16780391335487,  .12590345740318, -.26983660459518, -.26983660459518,
    -.1828535348177, -.18284019827843,  -.1791032999754, -.11887931078672,
    -.63495022058487, -.63495022058487, -.53598040342331, -.53542107343674,
    -.49657794833183, -.38836058974266, -1.7504912614822, -1.7504912614822,
    -1.2204585075378, -1.2154930830002, -1.0554916858673, -.63642859458923,
    -1.862185716629,  -1.862185716629, -1.2788465023041, -1.2732635736465,
    -1.1007128953934, -.65061664581299, -2.5617923736572, -2.5617923736572,
    -1.617108464241, -1.6071890592575, -1.3574055433273, -.71924245357513,
    -1.6135795116425, -1.6135795116425, -1.1469231843948, -1.1426799297333,
    -.99809640645981, -.61738300323486,  .22420094907284,  .22420094907284,
    .24363535642624,  .24356025457382,  .25454398989677,  .28899359703064,
    .06624934077263,  .06624934077263,  .06777309626341,  .06777160614729,
    .06855925172567,  .07094971090555,  .43318045139313,  .43318045139313,
    .51954871416092,  .51871728897095,  .57536894083023,  .76422989368439,
    -.89140218496323, -.89140218496323,  -.7140833735466,  -.7128586769104,
    -.64815932512283, -.47129172086716]).reshape(17, 6)

resids_colnames = ["score_factor", "resid_response", "resid_anscombe",
                   "resid_deviance", "resid_pearson", "resid_working"]

resids_rownames = ["r"+str(n) for n in range(1, 18)]


results_poisson_fweight_nonrobust = ParamsTableTestBunch(
    params_table=params_table,
    params_table_colnames=params_table_colnames,
    params_table_rownames=params_table_rownames,
    cov=cov,
    cov_colnames=cov_colnames,
    cov_rownames=cov_rownames,
    infocrit=infocrit,
    infocrit_colnames=infocrit_colnames,
    infocrit_rownames=infocrit_rownames,
    predicted=predicted,
    predicted_colnames=predicted_colnames,
    predicted_rownames=predicted_rownames,
    resids=resids,
    resids_colnames=resids_colnames,
    resids_rownames=resids_rownames,
    **est
)

est = dict(
    deviance=12.02863083186947,
    dispers=1.202863083186947,
    deviance_s=12.02863083186947,
    dispers_s=1.202863083186947,
    deviance_p=15.48630027479802,
    dispers_p=1.548630027479802,
    deviance_ps=15.48630027479802,
    dispers_ps=1.548630027479802,
    bic=-16.30350260869269,
    nbml=0,
    N=17,
    ic=3,
    k=7,
    k_eq=1,
    k_dv=1,
    converged=1,
    k_autoCns=0,
    ll=-27.28727618329841,
    chi2=94.62492461274286,
    p=3.30927661191e-18,
    rc=0,
    aic=4.033797198035106,
    rank=7,
    canonical=1,
    power=0,
    df_m=6,
    df=10,
    vf=1,
    phi=1,
    k_eq_model=0,
    properties="b V",
    depvar="executions",
    which="max",
    technique="nr",
    singularHmethod="m-marquardt",
    ml_method="e2",
    crittype="log likelihood",
    user="glim_lf",
    title="Generalized linear models",
    opt="moptimize",
    chi2type="Wald",
    wtype="aweight",
    wexp="= fweight",
    link="glim_l03",
    varfunc="glim_v3",
    m="1",
    a="1",
    oim="oim",
    opt1="ML",
    varfuncf="u",
    varfunct="Poisson",
    linkf="ln(u)",
    linkt="Log",
    vce="oim",
    vcetype="OIM",
    hac_lag="15",
    marginsok="default",
    marginsnotok="stdp Anscombe Cooksd Deviance Hat Likelihood Pearson Response Score Working ADJusted STAndardized STUdentized MODified",
    predict="glim_p",
    cmd="glm",
    cmdline="glm executions income perpoverty perblack LN_VC100k96 south degree [aweight=fweight], family(poisson)",
)

params_table = np.array([
    .00025343868829,  .00005594520811,  4.5301232557793,  5.894928560e-06,
    .00014378809529,  .00036308928129, np.nan,  1.9599639845401,
    0,  .09081422305585,  .09018031800722,  1.0070293059798,
    .31392069129295, -.08593595235267,  .26756439846436, np.nan,
    1.9599639845401,                0, -.09416451429381,  .02501975991718,
    -3.7636058301716,  .00016748080115, -.14320234263332, -.04512668595429,
    np.nan,  1.9599639845401,                0,  .27652273809507,
    .53816281293549,  .51382728692594,  .60737274844619, -.77825699307725,
    1.3313024692674, np.nan,  1.9599639845401,                0,
    2.239890838384,  .50630271729905,   4.424015044464,  9.688326910e-06,
    1.2475557472031,  3.2322259295649, np.nan,  1.9599639845401,
    0, -18.842583191417,  5.2065333302747, -3.6190267105084,
    .00029571311817, -29.047201003062, -8.6379653797707, np.nan,
    1.9599639845401,                0, -6.5630017977417,  4.5075460479893,
    -1.4560032727052,  .14539171490364, -15.397629710457,  2.2716261149733,
    np.nan,  1.9599639845401,                0]).reshape(7, 9)

params_table_colnames = "b se z pvalue ll ul df crit eform".split()

params_table_rownames = ["income", "perpoverty", "perblack", "LN_VC100k96",
                         "south", "degree", "_cons"]

cov = np.array([
    3.129866310e-09,  2.467206465e-06,  1.706246053e-07, -3.176637541e-07,
    -6.238332985e-06, -.00010954424563,   -.000120350676,  2.467206465e-06,
    .00813248975588,  .00032161167774, -.00128998199687, -.01831266258952,
    .14012008775466, -.21862639048575,  1.706246053e-07,  .00032161167774,
    .00062598838631, -.00690661599067, -.00759732903266, -.03651168891971,
    .03689627396044, -3.176637541e-07, -.00128998199687, -.00690661599067,
    .28961921322663,  .04817967329131,  .52320524326798, -1.8618850102603,
    -6.238332985e-06, -.01831266258952, -.00759732903266,  .04817967329131,
    .2563424415444,  .86118714295143, -.05787604759173, -.00010954424563,
    .14012008775466, -.03651168891971,  .52320524326798,  .86118714295143,
    27.107989319261, -7.0873136260377,   -.000120350676, -.21862639048575,
    .03689627396044, -1.8618850102603, -.05787604759173, -7.0873136260377,
    20.317971374744]).reshape(7, 7)

cov_colnames = ["income", "perpoverty", "perblack", "LN_VC100k96",
                "south", "degree", "_cons"]

cov_rownames = ["income", "perpoverty", "perblack", "LN_VC100k96",
                "south", "degree", "_cons"]

infocrit = np.array([
    17, np.nan, -27.287276183298,                7,
    68.574552366597,   74.40704577499])

infocrit_colnames = "N ll0 ll df AIC BIC".split()

infocrit_rownames = ".".split()

predicted = np.array([
    34.815238952637,  .23209382593632,  1.8754115104675,  7.3026847839355,
    .45640400052071,   1.521183013916,  1.2540435791016,  .36330956220627,
    .16552601754665,  3.9734709262848,  .34751656651497,  .47986721992493,
    2.0739872455597,  .34389564394951,   .2452784627676,  1.1471545696259,
    .63293009996414,  .45955070853233,  1.7763512134552,  .38466224074364,
    .2628378868103,  2.2698366641998,  .35724925994873,  .28969252109528,
    1.6349502801895,  .38501682877541,  .24236169457436,  2.7504913806915,
    .55104273557663,  .83518141508102,   2.862185716629,  .55352979898453,
    .87696009874344,  3.5617923736572,  .54546248912811,  1.0597376823425,
    2.6135795116425,  .41179683804512,  .44320201873779,    .775799036026,
    .5664399266243,  .24891836941242,  .93375068902969,  .40948873758316,
    .15657225251198,  .56681954860687,  .40214782953262,  .09166768193245,
    1.8914022445679,  .30498126149178,  .17592607438564]).reshape(17, 3)

predicted_colnames = "predict_mu predict_linpred_std predict_hat".split()

predicted_rownames = ["r"+str(n) for n in range(1, 18)]

resids = np.array([
    2.1847612857819,  2.1847612857819,  .36650228500366,  .36649596691132,
    .3702706694603,  .06275302171707,  1.6973150968552,  1.6973150968552,
    .60597640275955,  .60585051774979,  .62808901071548,  .23242343962193,
    4.7459564208984,  4.7459564208984,  3.0897438526154,  3.0483965873718,
    4.2380628585815,  3.7845225334167,  .02652905881405,  .02652905881405,
    .01329397037625,  .01329396758229,  .01330873556435,  .00667654490098,
    .92601269483566,  .92601269483566,  .60273587703705,  .60233747959137,
    .64300429821014,  .44648909568787,   .8528453707695,   .8528453707695,
    .72065913677216,  .71955502033234,   .7962681055069,   .7434441447258,
    .22364875674248,  .22364875674248,  .16446639597416,  .16445553302765,
    .16780391335487,  .12590345740318, -.26983660459518, -.26983660459518,
    -.1828535348177, -.18284019827843,  -.1791032999754, -.11887931078672,
    -.63495022058487, -.63495022058487, -.53598040342331, -.53542107343674,
    -.49657794833183, -.38836058974266, -1.7504912614822, -1.7504912614822,
    -1.2204585075378, -1.2154930830002, -1.0554916858673, -.63642859458923,
    -1.862185716629,  -1.862185716629, -1.2788465023041, -1.2732635736465,
    -1.1007128953934, -.65061664581299, -2.5617923736572, -2.5617923736572,
    -1.617108464241, -1.6071890592575, -1.3574055433273, -.71924245357513,
    -1.6135795116425, -1.6135795116425, -1.1469231843948, -1.1426799297333,
    -.99809640645981, -.61738300323486,  .22420094907284,  .22420094907284,
    .24363535642624,  .24356025457382,  .25454398989677,  .28899359703064,
    .06624934077263,  .06624934077263,  .06777309626341,  .06777160614729,
    .06855925172567,  .07094971090555,  .43318045139313,  .43318045139313,
    .51954871416092,  .51871728897095,  .57536894083023,  .76422989368439,
    -.89140218496323, -.89140218496323,  -.7140833735466,  -.7128586769104,
    -.64815932512283, -.47129172086716]).reshape(17, 6)

resids_colnames = ["score_factor", "resid_response", "resid_anscombe",
                   "resid_deviance", "resid_pearson", "resid_working"]

resids_rownames = ["r"+str(n) for n in range(1, 18)]


results_poisson_aweight_nonrobust = ParamsTableTestBunch(
    params_table=params_table,
    params_table_colnames=params_table_colnames,
    params_table_rownames=params_table_rownames,
    cov=cov,
    cov_colnames=cov_colnames,
    cov_rownames=cov_rownames,
    infocrit=infocrit,
    infocrit_colnames=infocrit_colnames,
    infocrit_rownames=infocrit_rownames,
    predicted=predicted,
    predicted_colnames=predicted_colnames,
    predicted_rownames=predicted_rownames,
    resids=resids,
    resids_colnames=resids_colnames,
    resids_rownames=resids_rownames,
    **est
)

est = dict(
    deviance=23.34969514421719,
    dispers=2.33496951442172,
    deviance_s=23.34969514421719,
    dispers_s=2.33496951442172,
    deviance_p=30.06164170990202,
    dispers_p=3.006164170990202,
    deviance_ps=30.06164170990202,
    dispers_ps=3.006164170990202,
    bic=-4.982438296344967,
    nbml=0,
    N=17,
    ic=3,
    k=7,
    k_eq=1,
    k_dv=1,
    converged=1,
    k_autoCns=0,
    ll=-52.96941847346162,
    chi2=356.6637749656061,
    p=5.72458312679e-74,
    rc=0,
    aic=7.055225702760191,
    rank=7,
    canonical=1,
    power=0,
    df_m=6,
    df=10,
    vf=1,
    phi=1,
    k_eq_model=0,
    properties="b V",
    depvar="executions",
    which="max",
    technique="nr",
    singularHmethod="m-marquardt",
    ml_method="e2",
    crittype="log pseudolikelihood",
    user="glim_lf",
    title="Generalized linear models",
    opt="moptimize",
    chi2type="Wald",
    wtype="pweight",
    wexp="= fweight",
    link="glim_l03",
    varfunc="glim_v3",
    m="1",
    a="1",
    oim="oim",
    opt1="ML",
    varfuncf="u",
    varfunct="Poisson",
    linkf="ln(u)",
    linkt="Log",
    vcetype="Robust",
    hac_lag="15",
    marginsok="default",
    marginsnotok="stdp Anscombe Cooksd Deviance Hat Likelihood Pearson Response Score Working ADJusted STAndardized STUdentized MODified",
    predict="glim_p",
    cmd="glm",
    cmdline="glm executions income perpoverty perblack LN_VC100k96 south degree [pweight=fweight], family(poisson)",
)

params_table = np.array([
    .00025343868829,   .0000298866597,  8.4799937786829,  2.252059827e-17,
    .00019486191167,  .00031201546491, np.nan,  1.9599639845401,
    0,  .09081422305585,  .08414617969117,  1.0792435662456,
    .28047916301946, -.07410925857549,  .25573770468718, np.nan,
    1.9599639845401,                0, -.09416451429381,  .01946961498728,
    -4.8364856909253,  1.321547815e-06, -.13232425846174, -.05600477012587,
    np.nan,  1.9599639845401,                0,  .27652273809506,
    .36112179485191,  .76573261995571,  .44383541350407, -.43126297384714,
    .98430845003726, np.nan,  1.9599639845401,                0,
    2.239890838384,  .43098853454849,  5.1971007551989,  2.024206636e-07,
    1.3951688329193,  3.0846128438487, np.nan,  1.9599639845401,
    0, -18.842583191417,  4.5147658917489, -4.1735460139479,
    .00002998950578, -27.691361737874, -9.9938046449589, np.nan,
    1.9599639845401,                0, -6.5630017977416,  3.3999612612355,
    -1.930316639948,   .0535676165153, -13.226803418595,  .10079982311137,
    np.nan,  1.9599639845401,                0]).reshape(7, 9)

params_table_colnames = "b se z pvalue ll ul df crit eform".split()

params_table_rownames = ["income", "perpoverty", "perblack", "LN_VC100k96",
                         "south", "degree", "_cons"]

cov = np.array([
    8.932124278e-10,  1.512127962e-06,  1.877263788e-07, -4.562869239e-06,
    -2.023379829e-06, -.00001228516761, -.00002423071544,  1.512127962e-06,
    .00708057955662,  .00028427703202,  -.0019549511748, -.00596332288528,
    .20022061835302, -.18678265108673,  1.877263788e-07,  .00028427703202,
    .00037906590775, -.00453407701816, -.00623061980467, -.04659404972535,
    .02694184589715, -4.562869239e-06,  -.0019549511748, -.00453407701816,
    .13040895071706,   .0836259691825,  .89260578257395, -.82275604425197,
    -2.023379829e-06, -.00596332288528, -.00623061980467,   .0836259691825,
    .18575111691225,  1.0698498854979, -.64859219982217, -.00001228516761,
    .20022061835302, -.04659404972535,  .89260578257395,  1.0698498854979,
    20.383111057299, -12.482192460755, -.00002423071544, -.18678265108673,
    .02694184589715, -.82275604425197, -.64859219982217, -12.482192460755,
    11.559736577902]).reshape(7, 7)

cov_colnames = ["income", "perpoverty", "perblack", "LN_VC100k96",
                "south", "degree", "_cons"]

cov_rownames = ["income", "perpoverty", "perblack", "LN_VC100k96",
                "south", "degree", "_cons"]

infocrit = np.array([
    17, np.nan, -52.969418473462,                7,
    119.93883694692,  125.77133035532])

infocrit_colnames = "N ll0 ll df AIC BIC".split()

infocrit_rownames = ".".split()

predicted = np.array([
    34.815238952637,  .06858423352242,  7.3026847839355,  .25687274336815,
    1.2540435791016,  .41320022940636,  3.9734709262848,  .16020278632641,
    2.0739872455597,  .22170753777027,  1.1471545696259,  .51121062040329,
    1.7763512134552,   .2167394310236,  2.2698366641998,   .2456086575985,
    1.6349502801895,  .25546172261238,  2.7504913806915,   .4417819082737,
    2.862185716629,  .61734634637833,  3.5617923736572,  .51518148183823,
    2.6135795116425,  .34006628394127,    .775799036026,    .292076587677,
    .93375068902969,  .39795544743538,  .56681954860687,  .31529840826988,
    1.8914022445679,  .26116076111794]).reshape(17, 2)

predicted_colnames = "predict_mu predict_linpred_std".split()

predicted_rownames = ["r"+str(n) for n in range(1, 18)]

resids = np.array([
    2.1847612857819,  2.1847612857819,  .36650228500366,  .36649596691132,
    .3702706694603,  .06275302171707,  1.6973150968552,  1.6973150968552,
    .60597640275955,  .60585051774979,  .62808901071548,  .23242343962193,
    4.7459564208984,  4.7459564208984,  3.0897438526154,  3.0483965873718,
    4.2380628585815,  3.7845225334167,  .02652905881405,  .02652905881405,
    .01329397037625,  .01329396758229,  .01330873556435,  .00667654490098,
    .92601269483566,  .92601269483566,  .60273587703705,  .60233747959137,
    .64300429821014,  .44648909568787,   .8528453707695,   .8528453707695,
    .72065913677216,  .71955502033234,   .7962681055069,   .7434441447258,
    .22364875674248,  .22364875674248,  .16446639597416,  .16445553302765,
    .16780391335487,  .12590345740318, -.26983660459518, -.26983660459518,
    -.1828535348177, -.18284019827843,  -.1791032999754, -.11887931078672,
    -.63495022058487, -.63495022058487, -.53598040342331, -.53542107343674,
    -.49657794833183, -.38836058974266, -1.7504912614822, -1.7504912614822,
    -1.2204585075378, -1.2154930830002, -1.0554916858673, -.63642859458923,
    -1.862185716629,  -1.862185716629, -1.2788465023041, -1.2732635736465,
    -1.1007128953934, -.65061664581299, -2.5617923736572, -2.5617923736572,
    -1.617108464241, -1.6071890592575, -1.3574055433273, -.71924245357513,
    -1.6135795116425, -1.6135795116425, -1.1469231843948, -1.1426799297333,
    -.99809640645981, -.61738300323486,  .22420094907284,  .22420094907284,
    .24363535642624,  .24356025457382,  .25454398989677,  .28899359703064,
    .06624934077263,  .06624934077263,  .06777309626341,  .06777160614729,
    .06855925172567,  .07094971090555,  .43318045139313,  .43318045139313,
    .51954871416092,  .51871728897095,  .57536894083023,  .76422989368439,
    -.89140218496323, -.89140218496323,  -.7140833735466,  -.7128586769104,
    -.64815932512283, -.47129172086716]).reshape(17, 6)

resids_colnames = ["score_factor", "resid_response", "resid_anscombe",
                   "resid_deviance", "resid_pearson", "resid_working"]

resids_rownames = ["r"+str(n) for n in range(1, 18)]


results_poisson_pweight_nonrobust = ParamsTableTestBunch(
    params_table=params_table,
    params_table_colnames=params_table_colnames,
    params_table_rownames=params_table_rownames,
    cov=cov,
    cov_colnames=cov_colnames,
    cov_rownames=cov_rownames,
    infocrit=infocrit,
    infocrit_colnames=infocrit_colnames,
    infocrit_rownames=infocrit_rownames,
    predicted=predicted,
    predicted_colnames=predicted_colnames,
    predicted_rownames=predicted_rownames,
    resids=resids,
    resids_colnames=resids_colnames,
    resids_rownames=resids_rownames,
    **est
)

est = dict(
    k_eq_model=0,
    phi=1,
    vf=1,
    df=10,
    df_m=6,
    power=0,
    canonical=1,
    rank=7,
    aic=4.579685683305704,
    rc=0,
    p=5.09268495340e-76,
    chi2=366.2131475852884,
    ll=-31.92732830809848,
    k_autoCns=0,
    converged=1,
    k_dv=1,
    k_eq=1,
    k=7,
    ic=3,
    N=17,
    nbml=0,
    bic=-9.740492454486454,
    dispers_ps=2.475374834715614,
    deviance_ps=24.75374834715614,
    dispers_p=2.475374834715614,
    deviance_p=24.75374834715614,
    dispers_s=1.859164098607571,
    deviance_s=18.59164098607571,
    dispers=1.859164098607571,
    deviance=18.59164098607571,
    cmdline="glm executions income perpoverty perblack LN_VC100k96 south degree, family(poisson) vce(robust)",
    cmd="glm",
    predict="glim_p",
