Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
7358630
Implemented llf for genericZeroInflated model
evgenyzhurko Jun 12, 2017
6bf3af5
Tests for ZIPoisson
evgenyzhurko Jun 12, 2017
3f6f925
Implemented score for ZIPoisson and tests
evgenyzhurko Jun 13, 2017
f9cb18f
Fixed score, added hessian, added predict
evgenyzhurko Jun 17, 2017
b1c34cf
Deleted unused code
evgenyzhurko Jun 17, 2017
f353d89
Refactored predict, added result class
evgenyzhurko Jun 19, 2017
26d00d1
Added formulas and description, changed params positions
evgenyzhurko Jun 22, 2017
0b59911
Generalization for score
evgenyzhurko Jun 22, 2017
ef22fcd
Partial implementation for generic hessian
evgenyzhurko Jun 22, 2017
e687d51
Reorganized hessian structure
evgenyzhurko Jun 23, 2017
26db05e
Added possibility to use Logit and Probit inflation
evgenyzhurko Jun 23, 2017
244ebd6
Added dtype for llf in evaluating
evgenyzhurko Jun 23, 2017
c0b6fa8
Added inflation parameters to output
evgenyzhurko Jun 25, 2017
fbecd66
Added different score for logit and probit inflation
evgenyzhurko Jul 3, 2017
03aebd1
Fix logpmf and argchech in ZIP distribution
evgenyzhurko Jul 3, 2017
2572ba7
Own hessian and score for probit and logit inflation
evgenyzhurko Jul 4, 2017
1126b66
Added tests for probit inflation
evgenyzhurko Jul 4, 2017
5cfecab
Refactored zipoisson distribution
evgenyzhurko Jul 18, 2017
579caed
Added test with offset for ZIP
evgenyzhurko Jul 18, 2017
7d3fafa
Added _lazywhere copy to compat.scipy
evgenyzhurko Jul 19, 2017
3e53780
Added test for mean and variance
evgenyzhurko Jul 20, 2017
9f9b061
Fixed problem in tests
evgenyzhurko Jul 21, 2017
01ae8e7
Added test for fit_regularized
evgenyzhurko Jul 21, 2017
7c82a58
Added ZIGP-p
evgenyzhurko Aug 10, 2017
7ba53bf
Implemented ZIGP-p distribution, refactored predict prob for ZI models
evgenyzhurko Aug 11, 2017
04fbd8e
Refactored ZIGP-p
evgenyzhurko Aug 14, 2017
dac7ee0
Refactored tests for ZI models
evgenyzhurko Aug 14, 2017
b4b402b
Fixed problem with parameters in output
evgenyzhurko Aug 14, 2017
5119b75
Implemented tests for ZIGP model
evgenyzhurko Aug 14, 2017
1d898ce
Added tests for predict ZiNBP, ZIP models
evgenyzhurko Aug 23, 2017
865902d
Implemented ZINB-P model
evgenyzhurko Aug 23, 2017
c919536
Implemented tests for ZINB, refactored for ZIP, ZIGP
evgenyzhurko Aug 23, 2017
8d79fcd
Refactored tests
evgenyzhurko Aug 24, 2017
e0416b0
Implemented tests for ZiNBP predict probabilities
evgenyzhurko Aug 26, 2017
ba27767
Clipped zero value for w
evgenyzhurko Aug 28, 2017
540f4e3
Improved docs for zero-inflated models
evgenyzhurko Aug 28, 2017
1bfab0e
Changed way to find start params
evgenyzhurko Aug 29, 2017
bf85618
Fixed problem with ZINB-P start_params
evgenyzhurko Aug 29, 2017
733463f
Refactored Generic zi model
evgenyzhurko Aug 30, 2017
86d87ba
Refactored predict for zero-inflated models
evgenyzhurko Aug 30, 2017
ba8f019
Added offset and exposure for _predict_prob
evgenyzhurko Aug 31, 2017
95bd417
Removed mean from prob_main
evgenyzhurko Aug 31, 2017
bc6b566
Fixed bug with 1d exog_infl in predict_prob and decreased rtol and at…
evgenyzhurko Aug 31, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions statsmodels/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
MNLogit, NegativeBinomial,
GeneralizedPoisson,
NegativeBinomialP)
from .discrete.count_model import (ZeroInflatedPoisson,
ZeroInflatedGeneralizedPoisson,
ZeroInflatedNegativeBinomialP)
from .tsa import api as tsa
from .duration.survfunc import SurvfuncRight
from .duration.hazard_regression import PHReg
Expand Down
44 changes: 44 additions & 0 deletions statsmodels/compat/scipy.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,3 +206,47 @@ def _next_regular(target):
if p5 < match:
match = p5
return match

def _valarray(shape, value=np.nan, typecode=None):
"""Return an array of all value.
"""

out = np.ones(shape, dtype=bool) * value
if typecode is not None:
out = out.astype(typecode)
if not isinstance(out, np.ndarray):
out = np.asarray(out)
return out

def _lazywhere(cond, arrays, f, fillvalue=None, f2=None):
"""
np.where(cond, x, fillvalue) always evaluates x even where cond is False.
This one only evaluates f(arr1[cond], arr2[cond], ...).
For example,
>>> a, b = np.array([1, 2, 3, 4]), np.array([5, 6, 7, 8])
>>> def f(a, b):
return a*b
>>> _lazywhere(a > 2, (a, b), f, np.nan)
array([ nan, nan, 21., 32.])
Notice it assumes that all `arrays` are of the same shape, or can be
broadcasted together.
"""
if fillvalue is None:
if f2 is None:
raise ValueError("One of (fillvalue, f2) must be given.")
else:
fillvalue = np.nan
else:
if f2 is not None:
raise ValueError("Only one of (fillvalue, f2) can be given.")

arrays = np.broadcast_arrays(*arrays)
temp = tuple(np.extract(cond, arr) for arr in arrays)
tcode = np.mintypecode([a.dtype.char for a in arrays])
out = _valarray(np.shape(arrays[0]), value=fillvalue, typecode=tcode)
np.place(out, cond, f(*temp))
if f2 is not None:
temp = tuple(np.extract(~cond, arr) for arr in arrays)
np.place(out, ~cond, f2(*temp))

return out
Loading