The family of two-piece distributions

This R markdown contains illustrative examples about the family of two-piece distributions and the `twopiece’ R package. A more detailed description of the family of two-piece distributions can be found at Rubio and Steel (2020). Additional examples on the twopiece R package can be found at “twopiece R package”.

Suppose that \(f\) is a unimodal symmetric (about \(0\)) probability density function (pdf) from the location-scale family, possibly including a shape parameter \(\delta\). Then, the pdf of a member of the two-piece family of distributions is: \[ s\left(x; \mu,\sigma_1,\sigma_2, \delta\right) = \begin{cases} \dfrac{2}{\sigma_1+\sigma_2}f\left(\dfrac{x-\mu}{\sigma_1};\delta\right), \mbox{if } x < \mu, \\ \dfrac{2}{\sigma_1+\sigma_2}f\left(\dfrac{x-\mu}{\sigma_2};\delta\right), \mbox{if } x \geq \mu. \\ \end{cases} \] For example,

  1. if \(f\) is the Normal pdf, then \(s\) is the two-piece Normal distribution proposed by Fechner (1897),
  2. if \(f\) is the Laplace distribution, then \(s\) is the asymmetric (or two-piece) Laplace distribution,
  3. if \(f\) is the Student-\(t\) distribution with \(\delta>0\) degrees of freedom, then we obtain the two-piece \(t\) distribution.

The parameters of \(s\) have a clear interpretation: \(\mu\) is the (unique) mode of \(s\), \(\sigma_1\) controls the scale (spread) of \(s\) on the left-hand side of \(\mu\), while \(\sigma_2\) controls the scale on the right-hand side of \(\mu\), and the interpretation of \(\delta\) is the same as that in \(f\). Other interpretable parameterisations of these distributions are presented in Arellano-Valle, Gómez, and Quintana (2005) and Rubio and Steel (2014). The mass allocated to both sides of the mode is only a function of the ratio of \(\sigma_1\) and \(\sigma_2\), in particular \(P(X<\mu)=\sigma_1/(\sigma_1+\sigma_2)\), for any choice of \(f\).

R code

rm(list=ls())
# Load the twopiece R package
#library(devtools)
#install_github("FJRubio67/twopiece")
library(twopiece)

# Two-piece normal density
dtpn <- function(x, mu = 0, sigma1 = 1, sigma2 = 1, log = FALSE){
  val <- dtp3(x, mu = mu, par1 = sigma1, par2 = sigma2, FUN = dnorm, param = "tp", log = log)
  return(val)
}

# Two-piece Cauchy density
dtpc <- function(x, mu = 0, sigma1 = 1, sigma2 = 1, log = FALSE){
  val <- dtp4(x, mu = mu, par1 = sigma1, par2 = sigma2, delta = 1, FUN = dt, param = "tp", log = log)
  return(val)
}

# Two-piece normal examples
f <- Vectorize(function(x) dtpn(x,0,1,1))

f1 <- Vectorize(function(x) dtpn(x,0,1,2))
f2 <- Vectorize(function(x) dtpn(x,0,1,3))
f3 <- Vectorize(function(x) dtpn(x,0,1,5))

# Two-piece Cauchy examples
h <- Vectorize(function(x) dtpc(x,0,1,1))

h1 <- Vectorize(function(x) dtpc(x,0,2,1))
h2 <- Vectorize(function(x) dtpc(x,0,3,1))
h3 <- Vectorize(function(x) dtpc(x,0,5,1))

# Figure 1a
U <- 10
L <- -5
curve(f,L,U, n= 1000, xlab = "x", ylab = "Density", main ="Two-piece Normal", lwd = 2, cex.axis = 1.5, cex.lab = 1.5)
curve(f1,L,U, n= 1000,add=T, col="red", lwd = 2)
curve(f2,L,U, n= 1000,add=T, col="green", lwd = 2)
curve(f3,L,U, n= 1000,add=T, col="blue", lwd = 2)

# Figure 1b
U <- 7.5
L <- -15
curve(h,L,U, n= 1000, xlab = "x", ylab = "Density", main ="Two-piece Cauchy", lwd = 2, cex.axis = 1.5, cex.lab = 1.5)
curve(h1,L,U, n= 1000,add=T, col="red", lwd = 2)
curve(h2,L,U, n= 1000,add=T, col="green", lwd = 2)
curve(h3,L,U, n= 1000,add=T, col="blue", lwd = 2)

Arellano-Valle, R. B., H. W. Gómez, and F. A. Quintana. 2005. “Statistical Inference for a General Class of Asymmetric Distributions.” Journal of Statistical Planning and Inference 128 (2): 427–43.
Fechner, G. T. 1897. Kollektivmasslehre. Leipzig: Engelmann.
Rubio, F. J., and M. F. J. Steel. 2014. “Inference in Two-Piece Location-Scale Models with Jeffreys Priors.” Bayesian Analysis 9 (1): 1–22.
———. 2020. “The Family of Two-Piece Distributions.” Significance 17 (1): 12–13.