class_docstr: # From R
  setwd('c:/workspace')
  data <- read.csv('cpunish.csv', sep=",")
  
  library(statmod)
  library(tweedie)
  
  summary(glm(EXECUTIONS ~ INCOME + SOUTH - 1,
          family=tweedie(var.power=1.5, link.power=1),
          data=data))
class_docstr_tok: ["#","From","R","setwd","(","'","c",":","\/workspace","'",")","data","<","-","read.csv","(","'cpunish.csv","'",",","sep=","''",",","''",")","library","(","statmod",")","library","(","tweedie",")","summary","(","glm","(","EXECUTIONS","~","INCOME","+","SOUTH","-","1",",","family=tweedie","(","var.power=1.5",",","link.power=1",")",",","data=data",")",")"]
code: def __init__(self):
      resid_resp = [
          28.90498242,
          0.5714367394,
          4.3135711827,
          -3.7417822942,
          -4.9544111888,
          0.4666602184,
          0.0747051827,
          -6.114236142,
          -1.0048540116,
          -6.9747602544,
          -0.7626907093,
          -0.5688093336,
          -6.9845579527,
          -1.1594503855,
          -0.6365453438,
          -0.3994222036,
          -0.732355528,
      ]
      resid_dev = [
          3.83881147757395,
          0.113622743768915,
          2.01981988071128,
          -0.938107751845672,
          -1.29607304923555,
          0.316205676540778,
          0.045273675744568,
          -1.69968893354602,
          -0.699080227540624,
          -2.1707839733642,
          -0.568738719015137,
          -0.451266938413727,
          -2.17218106358745,
          -0.774613533242944,
          -0.493831656345955,
          -0.336453094366771,
          -0.551210030548659,
      ]
      resid_pear = [
          6.02294407053171,
          0.115516970886608,
          2.9148208139849,
          -0.806210703943481,
          -1.04601155367613,
          0.338668788938945,
          0.045708693925888,
          -1.27176471794657,
          -0.5964031365026,
          -1.46974255264233,
          -0.498557360800493,
          -0.405777068096011,
          -1.47045242302365,
          -0.65086941662954,
          -0.439928270112046,
          -0.310433407220704,
          -0.485001313250992,
      ]
      resid_work = [
          28.9049727916181,
          0.571427719513967,
          4.31357425907762,
          -3.74179256698823,
          -4.9544210736226,
          0.466663015515745,
          0.0747086948013966,
          -6.114245735344,
          -1.00485035431368,
          -6.97477010217068,
          -0.76268749374494,
          -0.568806471745149,
          -6.98456778258272,
          -1.15944644619981,
          -0.636542358439925,
          -0.399419650775458,
          -0.732352367853816,
      ]
      self.resid_response = resid_resp
      self.resid_deviance = resid_dev
      self.resid_pearson = resid_pear
      self.resid_working = resid_work
      # self.null_deviance = 3731.85161919 # N/A
      self.params = [0.0000471043, 6.4721324886]
      self.bse = [0.0000246888, 3.5288126173]
      # self.aic_R = 522.14215776 # R adds 2 for dof to AIC
      # self.aic_Stata = 7.459173652869477  # stata divides by nobs
      # self.deviance = 70.6652992116034   # from Stata
      self.deviance = 36.087307138233  # from R
      # self.scale = 1.0
      # self.llf = -250.0710778504317  # from Stata, ours with scale=1
      # self.bic_Stata = -179.9959200693088  # no bic in R?
      self.df_model = 1
      self.df_resid = 15
  
      # TODO: taken from Stata; not available in sm yet
      # self.chi2 = 2699.138063147485
  
      self.fittedvalues = [
          8.09501758000751,
          8.42856326056927,
          1.68642881732415,
          7.74178229423817,
          7.95441118875248,
          1.53333978161934,
          1.92529481734232,
          8.11423614202829,
          2.00485401159015,
          7.97476025442155,
          1.76269070926448,
          1.56880933358418,
          7.98455795270665,
          2.15945038549266,
          1.63654534384372,
          1.39942220361664,
          1.73235552803559,
      ]
  
imports: import os
  import numpy
  import pandas
  from statsmodels.api import add_constant
  from statsmodels.genmod.tests.results import glm_test_resids
label_desc: Use image node_id 1 to create a new CpunishTweediePower15 object  with example: obj = CpunishTweediePower15()