MCPcopy Create free account
hub / github.com/statsmodels/statsmodels / NBin

Class NBin

examples/python/generic_mle.py:121–143  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

119
120
121class 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:

Callers 1

generic_mle.pyFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…