Package 'sld'

Title: Estimation and Use of the Quantile-Based Skew Logistic Distribution
Description: The skew logistic distribution is a quantile-defined generalisation of the logistic distribution (van Staden and King 2015). Provides random numbers, quantiles, probabilities, densities and density quantiles for the distribution. It provides Quantile-Quantile plots and method of L-Moments estimation (including asymptotic standard errors) for the distribution.
Authors: Robert King [aut, cre] , Paul van Staden [aut]
Maintainer: Robert King <[email protected]>
License: GPL (>= 2)
Version: 1.0.1
Built: 2025-03-01 03:04:20 UTC
Source: https://github.com/newystats/sld

Help Index


Fit the skew logistic distribution using L-Moments

Description

Fits the quantile-based Skew Logistic Distribution using L-Moments. fit.sld.lmom calculates the sample L Moments of a dataset and uses the method of L Moments to estimate the parameters of the skew logistic distribution. fit.sld.lmom.given fits the skew logistic using user-supplied values of the first three L Moments.

Usage

fit.sld.lmom.given(lmoms,n=NULL)
fit.sld.lmom(data)

Arguments

lmoms

A vector of length 3, containing the first and second (sample) L Moments and the 3rd (sample) L Moment ratio (τ3\tau_3)

n

The sample size

data

A vector containing a dataset

Details

The method of L-Moments estimates of the parameters of the quantile-based skew logistic distribution are:

α^=L16L3\hat\alpha=L_1 - 6 L_3

β^=2L2\hat\beta = 2 L_2

δ^=12(1+3τ3)\hat\delta= \frac 12 \left( 1 + 3\tau_3\right)

Note that L3L_3 in the α^\hat\alpha estimate is the 3rd L-Moment, not the 3rd L-Moment ratio (τ3=L3/L2\tau_3 = L_3/L_2).

fit.sld.lmom uses the samlmu function (from the lmom package) to calculate the sample L moments, then fit.sld.lmom.given to calculate the estimates.

Value

If the sample size is unknown (via using fit.sld.lmom.given and not specifying the sample size), a vector of length 3, with the estimated parameters, α^\hat\alpha, β^\hat\beta and δ^\hat\delta.

If the sample size is known, a 3 by 2 matrix. The first column contains the estimated parameters, α^\hat\alpha, β^\hat\beta and δ^\hat\delta, and the second column provides asymptotic standard errors for these.

Note that if τ3>13|\tau_3| > \frac 13, δ^\hat\delta is beyond its allowed value of [0,1] and the function returns an error. Values of τ3|\tau_3|, beyond 13\frac 13 correspond to distributions with greater skew than the exponential / reflected exponential, which form the limiting cases of the skew logistic distribution.

Author(s)

Robert King, [email protected], https://github.com/newystats and Paul van Staden

References

van Staden, P.J. and King, Robert A.R. (2015) The quantile-based skew logistic distribution, Statistics and Probability Letters 96 109–116. doi:10.1016/j.spl.2014.09.001

van Staden, Paul J. 2013 Modeling of generalized families of probability distribution in the quantile statistical universe. PhD thesis, University of Pretoria. http://hdl.handle.net/2263/40265

See Also

sld

Examples

generated.data <- rsl(300,c(0,1,.4))
estimate1 <- fit.sld.lmom(generated.data)
estimate2 <- fit.sld.lmom.given(c(0,1,.3),n=300)
data(PCB1)
hist(PCB1,prob=TRUE,main="PCB in Pelican Egg Yolk with SLD fit")
fit.pcb <- fit.sld.lmom(PCB1)
print(fit.pcb)
plotsld(fit.pcb[,1],add=TRUE,col="blue")

Calculate sample L-Moments

Description

Calculate sample L-Moments of a dataset

Usage

lmom.sample(data,max.mom=3)

Arguments

data

A vector containing a dataset

max.mom

The maximum order of L-Moment to estimate

Details

This function is a wrapper around the samlmu function from Hosking's lmom package, to give different argument defaults. It calculates sample L Moments.

Value

A vector of length max.mom. The first two elements are the first two L moments. If max.mom is greater than two, the following elements are the corresponding L moment ratios (the L Moment divided by the 2nd L Moment).

Author(s)

Robert King, [email protected], https://github.com/newystats and Paul van Staden

References

Hosking, J. R. M. (1990). L-moments: analysis and estimation of distributions using linear combinations of order statistics. Journal of the Royal Statistical Society, Series B, 52, 105–124.

Hosking, J. R. M., and Wallis, J. R. (1997). Regional frequency analysis: an approach based on L-moments. Cambridge University Press.

J. R. M. Hosking (2014). L-moments. R package, version 2.2. https://cran.r-project.org/package=lmom

See Also

sld

Examples

generated.data <- rsl(300,c(0,1,.4))
lmom.sample(data=generated.data,max.mom=3)

data(PCB1)
lmom.sample(PCB1,max.mom=3)

concentration of polychlorinated biphenyl (PCB) in the yolk lipids of pelican eggs in ppm

Description

Concentration (parts per million) of polychlorinated biphenyl (PCB) in the yolk lipids of pelican (Pelecanus occidentalis) eggs, from Anacapa, California. Published by Risebrough (1972).

The data PCB are the data as published in Risebrough (1972).

These data are also used in Thas (2010), as table 1, with a difference in the 24th observation (265 in Risebrough and 256 in Thas). PCB1 is the version in table 1 of Thas (2010).

This is a subset of a wider collection of data on Pelecanus occidentalis eggs from Risebrough et al (undated).

Usage

data(PCB)

Format

The data are in one vector, named PCB.

Source

Risebrough (1972) Effects of environmental pollutants upon animals other than man, Proceedings of the 6th Berkeley Symposium on Mathematical Statistics and Probability, Volume 6: Effects of Pollution on Health, 443–463, University of California Press, Berkeley, California.

http://projecteuclid.org/euclid.bsmsp/1200514718

R.W. Risebrough, F. Gress, J.K. Baptista, D.W. Anderson and R.W Schreiber (undated) Oceanic pollution: Effects on the reproduction of Brown Pelicans Pelecanus occidentalis, unpublished manuscript

References

Thas (2010) Comparing Distributions, Springer. 978-0-387-92710-7

Examples

data(PCB)

Plots of density and distribution function for the quantile based skew logistic distribution

Description

Produces plots of density and distribution function for the quantile based skew logistic distribution. Although you could use curve(dsl(x)) to do this, the fact that the density and quantiles of this distribution are defined in terms of the depth, uu, means that a seperate function that uses the depths to produce the values to plot is more accurate and efficient.

Usage

plotsld(parameters, add=FALSE, granularity = 10000,
  xlab = "x", ylab="density", quant.probs = seq(0,1,.25), ...)
plotslc(parameters, add=FALSE, granularity = 10000,
  xlab = "quantile", ylab="depth", quant.probs = seq(0,1,.25), ...)

Arguments

parameters

A vector of length 3, giving the parameters of the quantile-based skew logistic distribution. The 3 elements are α\alpha (location), β\beta (scale) and δ\delta (skewing). α\alpha can take on any real value, β\beta can take on any positive value and δ\delta must satisfy 0δ10 \leq \delta \leq 1. δ=0.5\delta = 0.5 gives the logistic distribution, δ=0\delta = 0 gives the reflected exponential distribution and δ=1\delta = 1 gives the exponential distribution.

add

Should this add to an existing plot (using lines) or produce a new plot (using plot).

granularity

Number of points at which quantiles and density will be calculated.— see details

xlab

X axis label

ylab

Y axis label

quant.probs

Quantiles of distribution to return (see value below). Set to NULL to suppress this return entirely.

...

arguments that get passed to plot if this is a new plot

Details

The quantile-based skew logistic distribution is defined by its quantile function. The density of the distribution is available explicitly as a function of depths, uu, but not explicitly available as a function of xx (except for the special cases at δ\delta=0,0.5 and 1). This function calculates quantiles and density as a function of depths to produce a density plot plotsld or cumulative probability plot plotslc.

Value

A number of quantiles from the distribution, the default being the minimum, maximum and quartiles.

Author(s)

Robert King, [email protected], https://github.com/newystats/sld

References

van Staden, P.J. and King, Robert A.R. (2015) The quantile-based skew logistic distribution, Statistics and Probability Letters 96, 109–116. doi:10.1016/j.spl.2014.09.001

van Staden, Paul J. 2013 Modeling of generalized families of probability distribution in the quantile statistical universe. PhD thesis, University of Pretoria. http://hdl.handle.net/2263/40265

https://github.com/newystats/sld

See Also

sld

Examples

plotsld(c(0,1,1),main="Exponential Distribution")
plotsld(c(0,1,0.5),main="Logistic Distribution")
plotsld(c(0,1,0.7))
plotslc(c(0,1,0.7))

Quantile-Quantile plot against the skew logistic distribution

Description

qqgl produces a Quantile-Quantile plot of data against the quantile-based skew logistic distribution, or a Q-Q plot to compare two sets of parameter values for the quantile-based skew logistic distribution. This function does for the skew logistic distribution what qqnorm does for the normal.

Usage

qqsl(y=NULL,parameters1,parameters2=NULL,abline=TRUE,
      granularity.for.2.dists=4000,use.endpoints=FALSE,...)

Arguments

y

The data sample

parameters1

A vector of length 3, containg the parameters of the skew logistic distribution, α\alpha, β\beta and δ\delta.

parameters2

Second set of parameters of the skew logistic distribution. A vector of length 3, as described above for parameters1.

abline

A logical value, TRUE adds a line through the origian with a slope of 1 to the plot

granularity.for.2.dists

Number of quantiles to use in a Q-Q plot comparing two sets of parameter values

use.endpoints

logical. When comparing two sets of parameter values, should Q(0) and Q(1) be used? TRUE will give QQ plots including the theoretical minimum and maximum of the distribution, which is arguably not equivalent to what would be seen in QQ plots based on data. FALSE will give QQ plots based on ideal depths (type 8 quantiles, see quantile documentation), where n is the granularity.for.2.dists.

...

graphical parameters, passed to qqplot

Details

See sld for more details on the Skew Logistic Distribution. A Q-Q plot provides a way to visually assess the correspondence between a dataset and a particular distribution, or between two distributions.

Value

A list of the same form as that returned by qqline

x

The x coordinates of the points that were/would be plotted, corresponding to a skew logistic distibution with parameters α\alpha, β\beta and δ\delta.

y

The original y vector, i.e., the corresponding y coordinates, or a corresponding set of quantiles from a skew logistic distribution with the second set of parameters

Author(s)

Robert King, [email protected], https://github.com/newystats/sld and Paul van Staden

References

van Staden, P.J. and King, R.A.R. (2015) The quantile-based skew logistic distribution, Statistics and Probability Letters 96 109–116. doi:10.1016/j.spl.2014.09.001

van Staden, Paul J. 2013 Modeling of generalized families of probability distribution in the quantile statistical universe. PhD thesis, University of Pretoria. http://hdl.handle.net/2263/40265

https://github.com/newystats/sld

See Also

sld

Examples

qqsl(y=rsl(100,c(0,1,0.7)),parameters1=c(0,1,0.7))
qqsl(parameters1=c(0,1,0.7),parameters2=c(0,0.9,0.5),col="blue")

The quantile-based Skew Logistic Distribution

Description

Density, density quantile, distribution and quantile functions and random generation for the quantile-based skew logistic distribution.

Usage

dsl(x,parameters,inverse.eps=.Machine$double.eps,max.iterations=500)
dqsl(p,parameters)
psl(q,parameters,inverse.eps=.Machine$double.eps,max.iterations=500)
qsl(p,parameters)
rsl(n,parameters)

Arguments

x, q

vector of quantiles.

p

vector of probabilities.

n

number of observations.

parameters

A vector of length 3, giving the parameters of the quantile-based skew logistic distribution. The 3 elements are α\alpha (location), β\beta (scale) and δ\delta (skewing). α\alpha can take on any real value, β\beta can take on any positive value and δ\delta must satisfy 0δ10 \leq \delta \leq 1. δ=0.5\delta = 0.5 gives the logistic distribution, δ=0\delta = 0 gives the reflected exponential distribution and δ=1\delta = 1 gives the exponential distribution.

inverse.eps

Accuracy of calculation for the numerical determination of F(x)F(x), defaults to .Machine$double.eps

max.iterations

Maximum number of iterations in the numerical determination of F(x)F(x), defaults to 500

Details

The quantile-based skew logistic distribution is a generalisation of the logistic distribution, defined by its quantile funtion, Q(u), the inverse of the distribution function.

Q(u)=α+β[(1δ)log(u)δ(log(1u))])Q(u)= \alpha + \beta \left[ (1- \delta) \log (u) - \delta (\log (1-u)) \right] )

for β>0\beta > 0 and 0δ10 \leq \delta \leq 1.

The distribution was first used by Gilchrist (2000) in the book Statistical Modelling with Quantile Functions. Full details of the properties of the distributions, including moments, L-moments and estimation via L-Moments are given in van Staden and King (2015).

The distribution is defined by its quantile function and its distribution and density functions do not exist in closed form (except for some special cases). Accordingly, the results from psl and dsl are the result of numerical solutions to the quantile function, using the Newton-Raphson method. Since the density quantile function, f(Q(u))f(Q(u)), does exist, an additional function, dqsl, computes this.

The distribution has closed form method of L-Moment estimates (see fit.sld.lmom for details). The 4th L-Moment ratio of the the distribution is constant τ4=16\tau_4 = \frac{1}{6} for all values of δ\delta. The 3rd L-Moment ratio of the distribution is restricted to 13τ313\frac{-1}{3} \leq \tau_3 \leq \frac{1}{3}, being the the 3rd L-moment ratio values of the reflected exponential and the exponential distributions respectively.

Value

dsl gives the density (based on the quantile density and a numerical solution to Q(u)=xQ(u)=x),

dqsl gives the density quantile,

psl gives the distribution function (based on a numerical solution to Q(u)=x and dqsl

qsl gives the quantile function, and

rsl generates random deviates.

Author(s)

Robert King, [email protected], https://github.com/newystats/

References

Gilchrist, W.G. (2000) Statistical Modelling with Quantile Functions Chapman & Hall, print 978-1-58488-174-2, e-book 978-1-4200-3591-9.

van Staden, P.J. and King, Robert A.R. (2015) The quantile-based skew logistic distribution, Statistics and Probability Letters 96 109–116. doi:10.1016/j.spl.2014.09.001

van Staden, Paul J. 2013 Modeling of generalized families of probability distribution in the quantile statistical universe. PhD thesis, University of Pretoria. http://hdl.handle.net/2263/40265

https://github.com/newystats/sld

Examples

qsl(seq(0,1,0.02),c(0,1,0.123))
psl(seq(-2,2,0.2),c(0,1,.1),inverse.eps=1e-10)
rsl(21,c(3,2,0.3))