class_docstr: Results are from Stata 11
class_docstr_tok: ["Results","are","from","Stata","11"]
code: def logit():
      obj = Namespace()
      obj.nobs = 32
      obj.params = [
          2.82611297201,
          0.0951576702557,
          2.37868772835,
          -13.0213483201,
      ]
      obj.cov_params = [
          [
              1.59502033639,
              -0.036920566629,
              0.427615725153,
              -4.57347950298,
          ],
          [
              -0.036920566629,
              0.0200375937069,
              0.0149126464275,
              -0.346255757562,
          ],
          [
              0.427615725153,
              0.0149126464275,
              1.13329715236,
              -2.35916128427,
          ],
          [
              -4.57347950298,
              -0.346255757562,
              -2.35916128427,
              24.3179625937,
          ],
      ]
      obj.bse = [
          1.26294114526,
          0.141554207662,
          1.06456430165,
          4.93132462871,
      ]
  
      obj.resid_pearson = [
          -0.1652382,
          -0.2515266,
          -0.4800059,
          -0.1630655,
          0.8687437,
          -0.1900454,
          -0.165002,
          -0.2331563,
          -0.3535812,
          0.6647838,
          -0.1583799,
          -0.4843181,
          -0.689527,
          2.043449,
          -0.7516119,
          -0.1764176,
          -0.2380445,
          -0.2003426,
          -1.199277,
          0.7164842,
          -0.255713,
          0.3242821,
          -0.5646816,
          -2.400189,
          0.4392082,
          1.038473,
          0.75747,
          -0.6659256,
          0.4336657,
          0.2404583,
          -1.060033,
          2.829577,
      ]
  
      obj.resid_dev = [
          -0.2321102,
          -0.3502712,
          -0.6439626,
          -0.2290982,
          1.060478,
          -0.2663844,
          -0.2317827,
          -0.3253788,
          -0.4853875,
          0.8555557,
          -0.2225972,
          -0.6491808,
          -0.8819993,
          1.813269,
          -0.9463985,
          -0.247583,
          -0.3320177,
          -0.2805444,
          -1.335131,
          0.9103027,
          -0.3559217,
          0.4471892,
          -0.744005,
          -1.955074,
          0.5939538,
          1.209638,
          0.952332,
          -0.8567857,
          0.5870719,
          0.335292,
          -1.227311,
          2.096639,
      ]
  
      # from gretl
      obj.resid_generalized = [
          -0.026578,
          -0.059501,
          -0.187260,
          -0.025902,
          0.430107,
          -0.034858,
          -0.026504,
          -0.051559,
          -0.111127,
          0.306489,
          -0.024470,
          -0.189997,
          -0.322240,
          0.806789,
          -0.360990,
          -0.030184,
          -0.053626,
          -0.038588,
          -0.589872,
          0.339214,
          -0.061376,
          0.095153,
          -0.241772,
          -0.852091,
          0.161709,
          0.518867,
          0.364579,
          -0.307219,
          0.158296,
          0.054660,
          -0.529117,
          0.888969,
      ]
  
      obj.phat = np.array(
          [
              0.02657799236476,
              0.05950126051903,
              0.18725991249084,
              0.02590163610876,
              0.56989300251007,
              0.03485824912786,
              0.02650404907763,
              0.05155897513032,
              0.11112663894892,
              0.69351142644882,
              0.02447037212551,
              0.18999740481377,
              0.32223951816559,
              0.1932111531496,
              0.36098992824554,
              0.03018374741077,
              0.05362640321255,
              0.03858831897378,
              0.58987241983414,
              0.66078591346741,
              0.06137581542134,
              0.90484726428986,
              0.24177247285843,
              0.85209089517593,
              0.8382905125618,
              0.48113295435905,
              0.63542068004608,
              0.30721867084503,
              0.84170418977737,
              0.94534027576447,
              0.52911710739136,
              0.1110308393836,
          ]
      )
      obj.yhat = np.array(
          [
              -3.6007342338562,
              -2.7604126930237,
              -1.4679137468338,
              -3.6272060871124,
              0.28141465783119,
              -3.3209850788116,
              -3.6035962104797,
              -2.9120934009552,
              -2.0792844295502,
              0.81658720970154,
              -3.6855175495148,
              -1.4500269889832,
              -0.74349880218506,
              -1.429278254509,
              -0.57107019424438,
              -3.4698030948639,
              -2.8705959320068,
              -3.2154531478882,
              0.36343798041344,
              0.66679841279984,
              -2.7273993492126,
              2.2522828578949,
              -1.1429864168167,
              1.7510952949524,
              1.6455633640289,
              -0.07550399750471,
              0.55554306507111,
              -0.81315463781357,
              1.6709630489349,
              2.8504176139832,
              0.11660042405128,
              -2.0802545547485,
          ]
      )
      obj.llf = -12.8896334653335
      obj.llnull = -20.5917296966173
      obj.df_model = 3
      obj.df_resid = (
          32 - 4
      )  # TODO: is this right? not reported in stata
      obj.llr = 15.4041924625676
      obj.prsquared = 0.374038332124624
      obj.llr_pvalue = 0.00150187761112892
      obj.aic = 33.779266930667
      obj.bic = 39.642210541866
      obj.z = [2.237723415, 0.6722348408, 2.234423721, -2.640537645]
      obj.conf_int = [
          [0.3507938, 5.301432],
          [-0.1822835, 0.3725988],
          [0.29218, 4.465195],
          [-22.68657, -3.35613],
      ]
      obj.pvalues = [
          0.0252390974,
          0.5014342039,
          0.0254552063,
          0.0082774596,
      ]
  
      # taken from margins command
      obj.margeff_nodummy_dydx = [
          0.36258084688424,
          0.01220841099085,
          0.30517768382304,
      ]
      obj.margeff_nodummy_dydx_se = [0.1094412, 0.0177942, 0.0923796]
      obj.margeff_nodummy_dydxmean = [
          0.53385885781692,
          0.01797548988961,
          0.44933926079386,
      ]
      obj.margeff_nodummy_dydxmean_se = [0.237038, 0.0262369, 0.1967626]
      obj.margeff_nodummy_dydxmedian = [
          0.25009492465091,
          0.00842091261329,
          0.2105003352955,
      ]
      obj.margeff_nodummy_dydxmedian_se = [
          0.1546708,
          0.0134314,
          0.0928183,
      ]
      obj.margeff_nodummy_dydxzero = [
          6.252993785e-06,
          2.105437138e-07,
          5.263030788e-06,
      ]
      obj.margeff_nodummy_dydxzero_se = [0.0000288, 9.24e-07, 0.000025]
      obj.margeff_nodummy_dyex = [
          1.1774000792198,
          0.27896245178384,
          0.16960002159996,
      ]
      obj.margeff_nodummy_dyex_se = [0.3616481, 0.4090679, 0.0635583]
      obj.margeff_nodummy_dyexmean = [
          1.6641381583512,
          0.39433730945339,
          0.19658592659731,
      ]
      obj.margeff_nodummy_dyexmean_se = [
          0.7388917,
          0.5755722,
          0.0860836,
      ]
      # NOTE: PSI at median should be a NaN or 'omitted'
      obj.margeff_nodummy_dyexmedian = [
          0.76654095836557,
          0.18947053379898,
          0,
      ]
      obj.margeff_nodummy_dyexmedian_se = [0.4740659, 0.302207, 0]
      # NOTE: all should be NaN
      # TODO: re above Note, since the values below are *not* NaN,
      #  should something be done about this?
      obj.margeff_nodummy_dyexzero = [0, 0, 0]
      obj.margeff_nodummy_dyexzero_se = [0, 0, 0]
  
      obj.margeff_nodummy_eydx = [
          1.8546366266779,
          0.06244722072812,
          1.5610138123033,
      ]
      obj.margeff_nodummy_eydx_se = [0.847903, 0.0930901, 0.7146715]
      obj.margeff_nodummy_eydxmean = [
          2.1116143062702,
          0.0710998816585,
          1.7773072368626,
      ]
      obj.margeff_nodummy_eydxmean_se = [1.076109, 0.1081501, 0.9120842]
      obj.margeff_nodummy_eydxmedian = [
          2.5488082240624,
          0.0858205793373,
          2.1452853812126,
      ]
      obj.margeff_nodummy_eydxmedian_se = [
          1.255377,
          0.1283771,
          1.106872,
      ]
      obj.margeff_nodummy_eydxzero = [
          2.8261067189993,
          0.0951574597115,
          2.3786824653103,
      ]
      obj.margeff_nodummy_eydxzero_se = [1.262961, 0.1415544, 1.064574]
      obj.margeff_nodummy_eyex = [
          5.4747106798973,
          1.3173389907576,
          0.44600395466634,
      ]
      obj.margeff_nodummy_eyex_se = [2.44682, 1.943525, 0.1567618]
      obj.margeff_nodummy_eyexmean = [
          6.5822977203268,
          1.5597536538833,
          0.77757191612739,
      ]
      obj.margeff_nodummy_eyexmean_se = [3.354433, 2.372543, 0.3990368]
      obj.margeff_nodummy_eyexmedian = [
          7.8120973525952,
          1.9309630350892,
          0,
      ]
      obj.margeff_nodummy_eyexmedian_se = [3.847731951, 2.888485089, 0]
  
      obj.margeff_nodummy_eyexzero = [0, 0, 0]
      obj.margeff_nodummy_eyexzero_se = [0, 0, 0]
  
      # for below GPA = 2.0, psi = 1
      obj.margeff_nodummy_atexog1 = [
          0.1456333017086,
          0.00490359933927,
          0.12257689308426,
      ]
      obj.margeff_nodummy_atexog1_se = [0.145633, 0.0111226, 0.1777101]
      # for below GPA at mean, tuce = 21, psi = 0
      obj.margeff_nodummy_atexog2 = [
          0.25105129214546,
          0.00845311433473,
          0.2113052923675,
      ]
      obj.margeff_nodummy_atexog2_se = [0.1735778, 0.012017, 0.0971515]
  
      # must get this from older margeff or i.psi then margins
      obj.margeff_dummy_dydx = [
          0.36258084688424,
          0.01220841099085,
          0.35751515254729,
      ]
      obj.margeff_dummy_dydx_se = [0.1094412, 0.0177942, 0.1420034]
      obj.margeff_dummy_dydxmean = [
          0.53385885781692,
          0.01797548988961,
          0.4564984096959,
      ]
      obj.margeff_dummy_dydxmean_se = [0.237038, 0.0262369, 0.1810537]
      # from margeff
      obj.margeff_dummy_count_dydx_median = [
          0.250110487483923,
          0.008426867847905,
          0.441897738279663,
      ]
      obj.margeff_dummy_count_dydx_median_se = [
          0.1546736661,
          0.0134551951,
          0.1792363708,
      ]
  
      # estimate with i.psi for the below then use margins
      obj.margeff_dummy_eydx = [
          1.8546366266779,
          0.06244722072812,
          1.5549034398832,
      ]
      obj.margeff_dummy_eydx_se = [0.847903, 0.0930901, 0.7283702]
      # ie
      #  margins, eydx(*) at((mean) _all)
      obj.margeff_dummy_eydxmean = [
          2.1116143062702,
          0.0710998816585,
          1.6631775707188,
      ]
      obj.margeff_dummy_eydxmean_se = [1.076109, 0.1081501, 0.801205]
  
      # TODO: Should we remove the commented-out code below?
      # Factor variables not allowed in below
      # test raises
      # obj.margeff_dummy_dydxzero
      # obj.margeff_dummy_eydxmedian
      # obj.margeff_dummy_eydxzero
      # obj.margeff_dummy_dyex
      # obj.margeff_dummy_dyexmean
      # obj.margeff_dummy_dyexmedian
      # obj.margeff_dummy_dyexzero
      # obj.margeff_dummy_eyex
      # obj.margeff_count_dummy_dydx_median
      # obj.margeff_count_dummy_dydx_median_se
  
      # NOTE: need old version of margeff for nodisc but at option is broken
      # stata command is margeff, count nodisc
      # this can be replicated with the new results by margeff
      # and then using margins for the last value
      obj.margeff_count_dydx = [
          0.3625767598018,
          0.0122068569914,
          0.3051777,
      ]
      obj.margeff_count_dydx_se = [
          0.1094379569,
          0.0177869773,
          0.0923796,
      ]
  
      # middle value taken from margeff rest from margins
      obj.margeff_count_dydxmean = [
          0.5338588,
          0.01797186545386,
          0.4493393,
      ]
      obj.margeff_count_dydxmean_se = [0.237038, 0.0262211, 0.1967626]
  
      # with new version of margeff this is just a call to
      # margeff
      # mat list e(margeff_b), nonames format(%17.16g)
      obj.margeff_count_dummy_dydxoverall = [
          0.362576759801767,
          0.012206856991439,
          0.357515163621704,
      ]
      # AFAICT, an easy way to get se is
      # mata
      # V = st_matrix("e(margeff_V)")
      # se = diagonal(cholesky(diag(V)))
      # last SE taken from margins with i.psi, do not know how they
      # do not know why margeff is different, but trust official results
      obj.margeff_count_dummy_dydxoverall_se = [
          0.1094379569,
          0.0177869773,
          0.1420034,
      ]
  
      # from new margeff
      obj.margeff_count_dummy_dydxmean = [
          0.533849340033768,
          0.017971865453858,
          0.456498405282412,
      ]
      obj.margeff_count_dummy_dydxmean_se = [
          0.2370202503,
          0.0262210796,
          0.1810536852,
      ]
  
      # for below GPA = 2.0, psi = 1
      obj.margeff_dummy_atexog1 = [
          0.1456333017086,
          0.00490359933927,
          0.0494715429937,
      ]
      obj.margeff_dummy_atexog1_se = [0.145633, 0.0111226, 0.0731368]
      # for below GPA at mean, tuce = 21, psi = 0
      obj.margeff_dummy_atexog2 = [
          0.25105129214546,
          0.00845311433473,
          0.44265645632553,
      ]
      obj.margeff_dummy_atexog2_se = [0.1735778, 0.012017, 0.1811925]
      # The test for the prediction table was taken from Gretl
      # Gretl Output matched the Stata output here for params and SE
      obj.pred_table = np.array([[18, 3], [3, 8]])
      return obj
  
imports: import os
  import numpy
label_desc: Use image node_id 2 for calling the Spector obj's underlying member method code with example usage: obj.logit() and returns: obj