| 119 | |
| 120 | |
| 121 | class NBin(GenericLikelihoodModel): |
| 122 | |
| 123 | def __init__(self, endog, exog, **kwds): |
| 124 | super(NBin, self).__init__(endog, exog, **kwds) |
| 125 | |
| 126 | def nloglikeobs(self, params): |
| 127 | alph = params[-1] |
| 128 | beta = params[:-1] |
| 129 | ll = _ll_nb2(self.endog, self.exog, beta, alph) |
| 130 | return -ll |
| 131 | |
| 132 | def fit(self, start_params=None, maxiter=10000, maxfun=5000, **kwds): |
| 133 | # we have one additional parameter and we need to add it for summary |
| 134 | self.exog_names.append('alpha') |
| 135 | if start_params == None: |
| 136 | # Reasonable starting values |
| 137 | start_params = np.append(np.zeros(self.exog.shape[1]), .5) |
| 138 | # intercept |
| 139 | start_params[-2] = np.log(self.endog.mean()) |
| 140 | return super(NBin, self).fit(start_params=start_params, |
| 141 | maxiter=maxiter, |
| 142 | maxfun=maxfun, |
| 143 | **kwds) |
| 144 | |
| 145 | |
| 146 | # Two important things to notice: |
no outgoing calls
no test coverage detected
searching dependent graphs…