Repository navigation
REF: change default derivative in CDFLink - #7287
Conversation
|
related issue #1878 I wanted to get this in the next release, needs checking again, maybe with some more cdflinks, or a generic cdf/scipy distribution link class. |
|
student t link would be useful to add and a good test case, and can be compared with cauchy and probit link as verification. It looks easy enough to get cdf, inverse_deriv = pdf and inverse_deriv2 = d pdf(x) / dx parking derivative from wolfram alpha d/dx c * (1 + x^2 / v )^{- (v+1)/ 2) d^2/dx^2 (c (1 + x^2/v)^(-1/2 (v + 1))) |
|
related: NegativeBinomial link does not specify inverse_deriv2 (from Wolfram alpha:) d^2/dz^2 -1/(alpha * (1 - exp(-z))) = CLogLog also does not have inverse_deriv2 deriv: loglog uses inverse_deriv2 = self.inverse_deriv(z) * (np.exp(-z) - 1) log and logit are also missing inverse_deriv2 |
|
cdflink equivalent of other links loglog is gumbel_r, cloglog is gumbel_l gl_link(x) == links.cloglog()(x) should be good for unit tests |
|
something wrong with default deriv (the two cdflinks only specify the distribution) update the problem is at the boundaries which I had included also p in link is clipped cdflink (link.inverse is cdf) looks like using derivatives of inverse would be more stable as multiplicative factors (-> 0, instead of -> inf). for unit tests: If I want to pass current tests for probit at atol/rtol at around 1e-5, then I need to clip at 1e-3, e.g. aside: using even number of points avoids p = 0.5 at which deriv2 is zero (error ratio become nan/inf) |
4e3a900 to
756bbea
Compare
|
This includes now some refactoring and enhancements for numdiff scalar parameter case, enough for what I need in links and transforms with vectorized scalar derivative. |
|
error/exception in unit tests for Markovswitching. type problem not wrong numbers or shape, there is no asarray in approx_fprime_cs, also not in approx_fprime |
31ec013 to
a949d80
Compare
|
no the error looks more serious, problem with shape and dim handling (I don't see an obvious reason for the error) I will also move the vectorized scalar case for |
|
still same error parameter x in test case is 2-d row vector I have to revert also the change len(x) -> asarray(x).shape[-1] It's only a test case, no non-test code breaks (as far as code is run in unit tests) |
|
I'm avoiding 2-d refactoring changes to current approx_fprime function in this PR. |
|
bad design: binary links subclass Logit and might inherit the wrong methods. I was testing inherited behavior with a minimal class, but it produces wrong numbers instead of raising NotImplementedError According to code comments, the only reason to inherit from Logit is the naming: It might be useful to allow link users to change default for epsilon in |
|
current base class e.g. this works as minimal class (aside requires complex numbers, I add it as unit test case but will not change it here. |
f36d111 to
05497e2
Compare
|
PR should be about ready for merge. file search doesn't find other cases of |
05497e2 to
d7a8be9
Compare
d7a8be9 to
9d89288
Compare
this is part of #7226 that is not included in #7286
related change that should be included here is numerical derivative #1783