Helpful Stan Functions
Unit Johnson SU distribution functions

Functions

real unit_johnson_lpdf (vector x, real mu, real sigma)
 
real unit_johnson_cdf (real x, real mu, real sigma)
 
real unit_johnson_lcdf (real x, real mu, real sigma)
 
real unit_johnson_lccdf (real x, real mu, real sigma)
 
real unit_johnson_rng (real mu, real sigma)
 

Detailed Description

The distribution is defined for outcomes bounded between the open (0, 1) interval. It is described in detail at Gündüz, S., & Korkmaz, M. Ç. (2020). A New Unit Distribution Based On The Unbounded Johnson Distribution Rule: The Unit Johnson SU Distribution. Pakistan Journal of Statistics and Operation Research, 16(3), 471-490. https://doi.org/10.18187/pjsor.v16i3.3421.

real unit_johnson_lpdf(vector x, real mu, real sigma) {
int N = num_elements(x);
return N * log(sigma) - sum(log(x) + log1m(x) + 0.5 * log1p(square(logit(x))))
+ std_normal_lpdf(mu + sigma * asinh(logit(x)));
}
real unit_johnson_cdf(real x, real mu, real sigma) {
return std_normal_cdf(mu + sigma * asinh(logit(x)));
}
real unit_johnson_lcdf(real x, real mu, real sigma) {
return std_normal_lcdf(mu + sigma * asinh(logit(x)));
}
real unit_johnson_lccdf(real x, real mu, real sigma) {
return std_normal_lccdf(mu + sigma * asinh(logit(x)));
}
real unit_johnson_rng(real mu, real sigma) {
real u = uniform_rng(0, 1);
real x = sinh((inv_Phi(u) - mu) / sigma);
return inv_logit(x);
}
real unit_johnson_lcdf(real x, real mu, real sigma)
Definition: unit_johnson_su.stanfunctions:75
real unit_johnson_cdf(real x, real mu, real sigma)
Definition: unit_johnson_su.stanfunctions:53
real unit_johnson_rng(real mu, real sigma)
Definition: unit_johnson_su.stanfunctions:116
real unit_johnson_lccdf(real x, real mu, real sigma)
Definition: unit_johnson_su.stanfunctions:96
real unit_johnson_lpdf(vector x, real mu, real sigma)
Definition: unit_johnson_su.stanfunctions:30

Function Documentation

◆ unit_johnson_cdf()

real unit_johnson_cdf ( real  x,
real  mu,
real  sigma 
)

Unit Johnson SU cumulative density function

The Unit Johnson SU distribution is defined as

\[ F(y \mid \mu,\sigma) = \Phi(\mu + \sigma \sinh^{-1}(\text{logit}(y)) ) \]

where \(\mu\) is the location parameter defined on the \(\mathbb{R}\) and \(\sigma\) is a scale parameter, restricted to the positive reals, \(\mathbb{R}^+\).

Author
Sean Pinkney
Parameters
xVector
muReal
sigmaReal (0,Inf) scale parameter
Returns
cumulative density

◆ unit_johnson_lccdf()

real unit_johnson_lccdf ( real  x,
real  mu,
real  sigma 
)

Unit Johnson SU log complementary cumulative density function

The Unit Johnson SU complementary cumulative distribution is defined as

\[ S(y \mid \mu,\sigma) = 1 - \Phi(\mu + \sigma \sinh^{-1}(\text{logit}(y)) ) \]

where \(\mu\) is the location parameter defined on the \(\mathbb{R}\) and \(\sigma\) is a scale parameter, restricted to the positive reals, \(\mathbb{R}^+\).

Author
Sean Pinkney
Parameters
xVector
muReal
sigmaReal (0,Inf) scale parameter
Returns
log complementary cumulative density

◆ unit_johnson_lcdf()

real unit_johnson_lcdf ( real  x,
real  mu,
real  sigma 
)

Unit Johnson SU log cumulative density function

The Unit Johnson SU cumulative is defined as

\[ F(y \mid \mu,\sigma) = \Phi(\mu + \sigma \sinh^{-1}(\text{logit}(y)) ) \]

where \(\mu\) is the location parameter defined on the \(\mathbb{R}\) and \(\sigma\) is a scale parameter, restricted to the positive reals, \(\mathbb{R}^+\).

Author
Sean Pinkney
Parameters
xVector
muReal
sigmaReal (0,Inf) scale parameter
Returns
log cumulative density

◆ unit_johnson_lpdf()

real unit_johnson_lpdf ( vector  x,
real  mu,
real  sigma 
)

The Unit Johnson SU distribution is defined as

\[ p(y \mid \mu,\sigma) = \frac{\sigma}{y (1 - y) \sqrt{1 + \text{logit}(y)^2}}\phi(\mu + \sigma \sinh^{-1}(\text{logit}(y)) ) \]

where \(\mu\) is the location parameter defined on the \(\mathbb{R}\) and \(\sigma\) is a scale parameter, restricted to the positive reals, \(\mathbb{R}^+\).

Author
Sean Pinkney
Parameters
xVector
muReal
sigmaReal (0, Inf) scale parameter
Returns
log probability

◆ unit_johnson_rng()

real unit_johnson_rng ( real  mu,
real  sigma 
)

Unit Johnson SU random number generator function

A unit Johnson SU can be generated by

\begin{aligned} u &\sim \mathcal{U}(0,\,1) \\ x &= \sinh^{-1}\bigg(\frac{\Phi^{-1}(u) - \mu}{\sigma}\bigg) \\ y &= \text{inv_logit}(x) \end{aligned}

where \( x \sim \text{Johnson }S_U(\mu, \sigma)\) and \( y \sim UJS_U(\mu, \sigma)\).

Author
Sean Pinkney
Parameters
muReal
sigmaReal (0, Inf) scale parameter
Returns
realization of Unit Johhson SU with given mu and sigma