コード例 #1
0
    def _sanitize_inputs(self, family, offset, exposure):
        if family is None:
            family = families.Gaussian()
        self.family = family

        if offset is not None:
            offset = np.asarray(offset)
            if offset.shape[0] != self.endog.shape[0]:
                raise ValueError("offset is not the same length as endog")
            self.offset = offset

        if exposure is not None:
            exposure = np.log(exposure)
            if exposure.shape[0] != self.endog.shape[0]:
                raise ValueError("exposure is not the same length as endog")
            self.exposure = exposure
コード例 #2
0
 def __init__(self, endog, exog, family=None, offset=None, exposure=None):
     endog = np.asarray(endog)
     exog = np.asarray(exog)
     if endog.shape[0] != len(exog):
         msg = "Size of endog (%s) does not match the shape of exog (%s)"
         raise ValueError(msg % (endog.size, len(exog)))
     if family is None:
         family = families.Gaussian()
     if offset is not None:
         offset = np.asarray(offset)
         if offset.shape[0] != endog.shape[0]:
             raise ValueError("offset is not the same length as endog")
         self.offset = offset
     if exposure is not None:
         exposure = np.log(exposure)
         if exposure.shape[0] != endog.shape[0]:
             raise ValueError("exposure is not the same length as endog")
         self.exposure = exposure
     self.endog = endog
     self.exog = exog
     self.family = family
     self.initialize()