Repository navigation
Description
more flexible distributions and corresponding regression models can be created by monotonic, non-linear transformation of random variables.
My old code for creating distribution classes is in the sandbox. My version doesn't require monotonicity and works also for e.g. square transformation. (At the time I wrote that, I didn't have any real application for it.)
for example tensorflow has sinh-arcsinh as transformation model that can take base distribution as argument.
https://www.tensorflow.org/probability/api_docs/python/tfp/distributions/SinhArcsinh
examples
- sinh-arcsinh
- johnson-SU, i.e. sinh, e.g. based on normal distribution https://github.com/scipy/scipy/blob/master/scipy/stats/_continuous_distns.py#L4032
- Birnbaum-Sanders and variation (R to R++)
sqrt(x) - 1 / sqrt(x)orx - 1 / x - transformation to unit interval, e.g. Johnson-SB (which might be exp-logit normal)
I'm currently mainly interested in the first 3.
extra
composition of transformation, e.g.
- log birnbaum-sanders is sinh transformation
- birnbaum-sanders is sqrt transformation combined with base
x - 1 / xtransformation. There are other versions and generalizations for it. - plain logit
1 / (1+x)versus exp-logit1 / (1 + exp(x))where exp transforms R -> R+
implementation
- generic: based on what I have in the sandbox, we create a new distribution that combines transformation and base distribution and takes both as argument
- special cases:
- some statistics like moments only have nice or analytical expressions in specific transformation-distribution combinations
(Distributions have a genericexpectmethod based on numerical integration, but that will not be efficient if we have to do it a few thousand or million times) - computational efficiency, for regression models we can use simpler expression for loglike and similar in some cases
- some statistics like moments only have nice or analytical expressions in specific transformation-distribution combinations
- tools, requirements
- transformation and inverse transformation, domain and range of transformation
- derivatives of the transformation, first and second should be enough
- derivatives with respect to parameters of the transformation. I don't know yet what we need.
specific issue:
Clipping and enforcing domain for transformation or inverse transformation.
AFAICS, all transformation mapping real line to R+ or interval (0, 1) define open spaces, i.e. we get inf or zero division at boundaries. (similar to some cases with links in GLM or discrete)
implementation convention
Which is transform and which is inverse transform? e.g. Do we define transformation to normality or from normality?
Same question as link versus inverse link classes but more general use cases. Links are currently only used as non-linear mean functions.
edit The tradition might be reversed from what I want.
E,g Log transformation is to normality or other distribution, i.e. z = log(x) is normal. and x = exp(z) is log-normal distributed
(I always find this reversed, I would prefer that transformation is defined from R to restricted space, e.g. R+ or from R+ to (0, 1)
e.g. log-normal is the distribution of an exp transformed normal random variable exp-normal.
or Birnbaum-Sanders is the "bs" transformation of a normal distribution, and not: if we "bs" transform a BS random variable, then it is normally distributed.
)
Activity
josef-pkt commentedon Jan 5, 2021
example first draft of sinh-arcsinh transformation
(derivation based on Wolfram alpha verified by numerical derivatives. Not simplified yet for common terms
d controls tail heaviness, kurtosis
e controls skew
base distribution is (d, e) = (1, 0) which is identity transformation
immediate use case, create random variables
example: light tailed, symmetric rv based on normal distribution
aside
special property of sinh-arcsinh: same functional form of transform and inverse transform.
I didn't use it in the above
zis transformed variableHowever, derivatives with respect to params will differ, or require an extra term for the [1 / d, -e / d] params transformation
josef-pkt commentedon Jan 5, 2021
first draft of Birnbaum-Saunders transformation, not verified yet
josef-pkt commentedon Jan 5, 2021
and the last of the three: sinh, Johnson's SU transformation
aside consistency checks based on code that we use in Link classes for second derivatives
josef-pkt commentedon Jan 5, 2021
looking at my ancient code (before 2011 when I got pissed off in scipy.stats and stopped working on distributions)
This only defines cdf and ppf
https://github.com/statsmodels/statsmodels/blob/master/statsmodels/sandbox/distributions/transformed.py#L53
I don't know why pdf is missing, the unit tests for it include pdf
I had written a chain transformation class to chain transformation
https://github.com/statsmodels/statsmodels/blob/master/statsmodels/sandbox/distributions/transform_functions.py#L147
AFAIR, I didn't try and do much with it.
The non-monotonic (u- or hump shaped) version includes pdf
https://github.com/statsmodels/statsmodels/blob/master/statsmodels/sandbox/distributions/transformed.py#L326
The old code still runs with current scipy, it has some basic unit test. However, some of the "frameworky" things link numargs and names might be easier now.
I think we can add something like this mainly targeted to our own application and not support it as a generic extension to scipy distributions.
We don't need parameter support for the base distributions like normal and logistic, but we need to support shape parameters like df in t-distribution.
The main candidates for base distributions are normal, t and logistic, and we want generic support for others for experimentation or quick analysis.
3 transformations times 3 distributions already makes 9 new distributions and models.
josef-pkt commentedon Jan 6, 2021
xrand is a Gaussian random sample
the following is for t minus inverse transform, similar to BS without the sqrt
but I need to check which is which, I'm not sure what I did in the sandbox, part of the pdf method of TransfTwo_gen uses
(self.derivplus(x)*self.kls._pdf(self.funcinvplus(x),*args, **kwargs)but now I needed to use
deriv_inversefor the jacobian of the transformationI'm using naming convention from GLM Link classes, (which is more recent than my old code)
josef-pkt commentedon Jan 7, 2021
another class of transformations are CDFLinks
in the context here, they convert to and from uniform distribution, i.e. probability integral transform PIT
In GLM we use them to convert R to (0,1)-Interval, or from any other space of a non-uniform distribution to (0,1)
cdf: R -> (0,1)
ppf: (0, 1) -> R
It's not really used to create new flexible distribution, PIT usage is "trivial" because we don't need derivatives or other properties.
The only more complex usecase seems to be as CDFLink, i.e. sigmoid shaped transformation for mean function or params.
aside:
Usage of cdf links in Binomial/Bernoulli requires only standardized form, i.e. fixed loc-scale because those are not separately identified in the models. We can use
scalefor heteroscedasticity, i.e. variation in variance as long as we pin down the location, i.e. one reference point with fixed scale. We don't have that yet, and I'm not sure whether we need it in CDFLinks or handle that as model.scale parameter.I guess I will keep them as
linksfor now.What I would like to get are parameterized CDFLink based on flexible distributions,
e.g. SinhArcsinhLogistic CDFLink, i.e. combine SinhArcsinh transformation with a CDFLink.
josef-pkt commentedon Mar 5, 2021
another group of references unit-xxx distributions - transformation to unit interval (0, 1)
one transformation that I haven't seen before y = exp(-x) for x in R+
I only skimmed a few of these articles,
Ghitany, M. E., J. Mazucheli, A. F. B. Menezes, and F. Alqallaf. 2019. “The Unit-Inverse Gaussian Distribution: A New Alternative to Two-Parameter Distributions on the Unit Interval.” Communications in Statistics - Theory and Methods 48 (14): 3423–38. https://doi.org/10.1080/03610926.2018.1476717.
Guerra, Renata Rojas, Fernando A. Peña-Ramírez, and Marcelo Bourguignon. 2020. “The Unit Extended Weibull Families of Distributions and Its Applications.” Journal of Applied Statistics 0 (0): 1–19. https://doi.org/10.1080/02664763.2020.1796936.
Gündüz, Selim, and Mustafa Ç Korkmaz. 2020. “A New Unit Distribution Based On The Unbounded Johnson Distribution Rule: The Unit Johnson SU Distribution.” Pakistan Journal of Statistics and Operation Research, August, 471–90. https://doi.org/10.18187/pjsor.v16i3.3421.
Haq, Muhammad Ahsan ul, Sharqa Hashmi, Khaoula Aidi, Pedro Luiz Ramos, and Francisco Louzada. 2020. “Unit Modified Burr-III Distribution: Estimation, Characterizations and Validation Test.” Annals of Data Science, June. https://doi.org/10.1007/s40745-020-00298-6.
Mazucheli, J., A. F. B. Menezes, L. B. Fernandes, R. P. de Oliveira, and M. E. Ghitany. 2020. “The Unit-Weibull Distribution as an Alternative to the Kumaraswamy Distribution for the Modeling of Quantiles Conditional on Covariates.” Journal of Applied Statistics 47 (6): 954–74. https://doi.org/10.1080/02664763.2019.1657813.
Mazucheli, J, AFB Menezes, and ME Ghitany. 2018. “The Unit-Weibull Distribution and Associated Inference.”
Mazucheli, Josmar, AF Menezes, and Sanku Dey. n.d. “The Unit-Birnbaum-Saunders Distribution with Applications.”
Chilean Journal of Statistics Vol. 9, No. 1, April 2018, 47-57
Mazucheli, Josmar, André Felipe Berdusco Menezes, and Subrata Chakraborty. 2018. “On the One Parameter Unit-Lindley Distribution and Its Associated Regression Model for Proportion Data.” Journal of Applied Statistics, August. https://www.tandfonline.com/doi/abs/10.1080/02664763.2018.1511774.
Mazucheli, Josmar, André Felipe Menezes, and Sanku Dey. 2019. “Unit-Gompertz Distribution with Applications.” Statistica 79 (1): 25–43. https://doi.org/10.6092/issn.1973-2201/8497.
Menezes, André Felipe Berdusco, Josmar Mazucheli, Sanku Dey, André Felipe Berdusco Menezes, Josmar Mazucheli, and Sanku Dey. 2018. “THE UNIT-LOGISTIC DISTRIBUTION: DIFFERENT METHODS OF ESTIMATION.” Pesquisa Operacional 38 (3): 555–78. https://doi.org/10.1590/0101-7438.2018.038.03.0555.
Nadarajah, Saralees, and Stephen Chan. 2020. “On Moments of the Unit Lindley Distribution.” Journal of Applied Statistics 47 (5): 947–49. https://doi.org/10.1080/02664763.2019.1675607.
Mazucheli, Josmar, AF Menezes, and Sanku Dey. “The Unit-Birnbaum-Saunders Distribution with Applications.”
They combine -log or exp(-x) with BS transformation.
That might be a test case for chaining transformations.
josef-pkt commentedon Mar 5, 2021
distributions on R+, mainly for lifetime analysis and different shapes of hazard function
mainly extensions to Weibull
I only skimmed a few parts.
The advantage is that many have closed form expressions based on exp in weibull cdf,
In one group of transformations, the extension corresponds to cumulative hazard function as generator.
GURVICH, M. R., A. T. DiBENEDETTO, and S. V. RANADE. 1997. “A New Statistical Distribution for Characterizing the Random Strength of Brittle Materials.” Journal of Materials Science 32 (10): 2559–64. https://doi.org/10.1023/A:1018594215963.
Ahmad, Zubair, and Zawar Hussain. 2017. “Flexible Weibull Distribution.” Journal of Computer and Mathematical Sciences 8 (6): 251–60.
Lai, C. D. 2013. “Constructions and Applications of Lifetime Distributions.” Applied Stochastic Models in Business and Industry 29 (2): 127–40. https://doi.org/10.1002/asmb.948.
Lai, C. D., D. N. P. Murthy, and M. Xie. 2011. “Weibull Distributions.” WIREs Computational Statistics 3 (3): 282–87. https://doi.org/10.1002/wics.157.
Lai, C. D., M. Xie, and D. N. P. Murthy. 2005. “Reply to ‘On Some Recent Modifications of Weibull Distribution.’” IEEE Transactions on Reliability 54 (4): 563–563. https://doi.org/10.1109/TR.2005.858812.
Murthy, D. N. P, M Xie, and Renyan Jiang. 2004. Weibull Models. Hoboken, N.J.: Wiley-InterScience. http://www.123library.org/book_details/?id=25807.
Nadarajah, S., and S. Kotz. 2005. “On Some Recent Modifications of Weibull Distribution.” IEEE Transactions on Reliability 54 (4): 561–62. https://doi.org/10.1109/TR.2005.858811.
Pham, H., and C. Lai. 2007. “On Recent Generalizations of the Weibull Distribution.” IEEE Transactions on Reliability 56 (3): 454–58. https://doi.org/10.1109/TR.2007.903352.
Raqab, Mohammad Z., Shafiqah A. Al-Awadhi, and Debasis Kundu. 2018. “Discriminating among Weibull, Log-Normal, and Log-Logistic Distributions.” Communications in Statistics - Simulation and Computation 47 (5): 1397–1419. https://doi.org/10.1080/03610918.2017.1315729.
josef-pkt commentedon Dec 3, 2021
Desousa, Mário F., Helton Saulo, Víctor Leiva, and Paulo Scalco. 2018. “On a Tobit–Birnbaum–Saunders Model with an Application to Medical Data.” Journal of Applied Statistics 45 (5): 932–55. https://doi.org/10.1080/02664763.2017.1322559.
parameterization of BS
AFAIR BS, they have an extra alpha in there to parameterize, e.g. 0.5 in standard BS