@@ -433,15 +433,15 @@ def rng_fn(cls, rng, alpha, beta, size):
433
433
class ShiftedBetaGeometric (Discrete ):
434
434
r"""Shifted Beta-Geometric distribution.
435
435
436
- This distribution is a flexible alternative to the Geometric distribution for the number of trials until a
437
- discrete event, and can be extended to support static and time-varying covariates .
436
+ This mixture distribution extends the Geometric distribution for the number of trials until a discrete event
437
+ to support heterogeneity across observations .
438
438
439
439
Hardie and Fader describe this distribution with the following PMF and survival functions in [1]_:
440
440
441
441
.. math::
442
- \mathbb{P}T=t|r, \alpha,\beta;Z(t)) = (\frac{\alpha}{\alpha+C( t-1)})^{r} - (\frac{\ alpha}{\alpha+C(t)})^{r} \\
442
+ \mathbb{P}T=t|\alpha,\beta) = (\frac{B( \alpha+1,\beta+ t-1)}{B(\ alpha,\beta}),t=1,2,... \\
443
443
\begin{align}
444
- \mathbb{S}(t|r, \alpha,\beta;Z(t)) = (\frac{\alpha}{\alpha+C( t)})^{r} \\
444
+ \mathbb{S}(t|\alpha,\beta) = (\frac{B( \alpha,\beta+ t)}{B(\alpha,\beta}),t=1,2,... \\
445
445
\end{align}
446
446
447
447
.. plot::
@@ -450,14 +450,15 @@ class ShiftedBetaGeometric(Discrete):
450
450
import matplotlib.pyplot as plt
451
451
import numpy as np
452
452
import scipy.stats as st
453
+ from scipy.special import beta
453
454
import arviz as az
454
455
plt.style.use('arviz-darkgrid')
455
456
t = np.arange(1, 11)
456
457
alpha_vals = [1., 1., 2., 2.]
457
- r_vals = [.1, .25, .5, 1.]
458
- for alpha, r in zip(alpha_vals, r_vals ):
459
- pmf = (alpha/(alpha + t - 1))**r - (alpha/(alpha+t))**r
460
- plt.plot(t, pmf, '-o', label=r'$\alpha$ = {}, $r $ = {}'.format(alpha, r ))
458
+ beta_vals = [.1, .25, .5, 1.]
459
+ for alpha, _beta in zip(alpha_vals, beta_vals ):
460
+ pmf = beta (alpha + 1, beta + t - 1) / beta (alpha, beta)
461
+ plt.plot(t, pmf, '-o', label=r'$\alpha$ = {}, $beta $ = {}'.format(alpha, beta ))
461
462
plt.xlabel('t', fontsize=12)
462
463
plt.ylabel('p(t)', fontsize=12)
463
464
plt.legend(loc=1)
@@ -469,18 +470,16 @@ class ShiftedBetaGeometric(Discrete):
469
470
470
471
Parameters
471
472
----------
472
- r : tensor_like of float
473
- Shape parameter (r > 0).
474
473
alpha : tensor_like of float
475
474
Scale parameter (alpha > 0).
476
- time_covariate_vector : tensor_like of float
477
- Vector containing dot products of time-varying covariates and coefficients .
475
+ beta : tensor_like of float
476
+ Scale parameter (beta > 0) .
478
477
479
478
References
480
479
----------
481
- .. [1] Fader, Peter & G . S. Hardie, Bruce (2020) .
482
- "Incorporating Time-Varying Covariates in a Simple Mixture Model for Discrete-Time Duration Data."
483
- https://www.brucehardie.com/notes/037/time-varying_covariates_in_BG .pdf
480
+ .. [1] Fader, P . S., & Hardie, B. G. (2007). How to project customer retention .
481
+ Journal of Interactive Marketing, 21(1), 76-90.
482
+ https://faculty.wharton.upenn.edu/wp-content/uploads/2012/04/Fader_hardie_jim_07 .pdf
484
483
"""
485
484
486
485
rv_op = sbg
0 commit comments