Repository navigation
ENH Betareg rebased2 - #7282
ENH Betareg rebased2#7282josef-pkt wants to merge 25 commits into
Conversation
|
Hello @josef-pkt! Thanks for opening this PR. We checked the lines you've touched for PEP 8 issues, and found:
|
|
I get these 3 types of warnings (reformatted) |
|
This pull request introduces 3 alerts when merging 42ecff4 into b08825a - view on LGTM.com new alerts:
|
|
unit tests for this are still green, pep-8 failures one statespace test failure on WindowsTest python39_win_latest |
josef-pkt
left a comment
There was a problem hiding this comment.
hessian is not used, and therefore not unit tested
Is it working correctly?
| varname Estimate StdError zvalue Pr(>|z|) | ||
| (Intercept) -0.62254806 0.223853539 -2.781051 5.418326e-03 | ||
| income -0.01229884 0.003035585 -4.051556 5.087819e-05 | ||
| persons 0.11846210 0.035340667 3.352005 8.022853e-04""" |
There was a problem hiding this comment.
I guess we need to strip "***" to get column converted to numeric
I don't know if pandas handles scientific format like 5.087819e-05 in csv
There was a problem hiding this comment.
unit tests seem to work with stars ?
| age -0.03471 0.03276 -1.059 0.289""" | ||
|
|
||
|
|
||
| expected_income_mean = pd.read_table(io.StringIO(_income_estimates_mean), sep="\s+") |
There was a problem hiding this comment.
read_table -> read_csv
| >>> from sm.families.links import identity | ||
| >>> Z = patsy.dmatrix('~ temp', dat, return_type='dataframe') | ||
| >>> mod = Beta.from_formula('iyield ~ C(batch, Treatment(10)) + temp', | ||
| ... dat, exog_precision=Z, link_precision=identity()) |
There was a problem hiding this comment.
add example when exog_precision is defined by formula
usage for it is not clear, from_formula uses exog_precision_formula keyword
|
|
||
| @classmethod | ||
| def from_formula(cls, formula, data, exog_precision_formula=None, | ||
| *args, **kwargs): |
There was a problem hiding this comment.
check usage, API with and without formula for precision part
| beta = (1 - mu) * phi | ||
|
|
||
| if np.any(alpha <= np.finfo(float).eps): return np.array(-np.inf) | ||
| if np.any(beta <= np.finfo(float).eps): return np.array(-np.inf) |
There was a problem hiding this comment.
is this in place of a clip?
both mu and phi are positive with default links
I guess this only handles the case >=0 and <= eps, essentially =0.
|
|
||
| d1 = np.dot(sf[:, 0], self.exog) | ||
| d2 = np.dot(sf[:, 1], self.exog_precision) | ||
| return np.concatenate((d1, d2)) |
| mut = digamma((1 - mu) * phi) - digamma(phi) | ||
|
|
||
| t = 1. / self.link.deriv(mu) | ||
| h = 1. / self.link_precision.deriv(phi) |
There was a problem hiding this comment.
make this less "backwards", (i.e. I prefer inverse links)
use link derive_inverse(linpred)
|
API issues/questions
aside: it looks like ZeroInflated models don't allow for formula for exog_infl part, does not override inherited from_formula get_distribution looks good, needs checking for consistent naming and interface with other models refactor: this should inherit from something like the top discrete model instead of GenericLikelihoodModel |
|
I was trying out the 2 test case examples in a notebook. params and bse agree with the R base on numbers in unit test reasonably well.
I guess around 2 weeks of work. |
|
offset option is missing |
rebased version of #4238
no changes except skipped 2nd commit additing csv file to package data in setup.py
no test failures locally, but many warnings. including pandas deprecation warnings