# SKD: Skew Family Distributions In lqr: Robust Linear Quantile Regression

## Description

Density, distribution function, quantile function and random generation for a Skew Family Distribution useful for quantile regression. This family of distribution includes skewed versions of the Normal, Student's t, Laplace, Slash and Contaminated Normal distribution, all with location parameter equal to `mu`, scale parameter `sigma` and skewness parameter `p`.

## Usage

 ```1 2 3 4 5 6``` ```dSKD(y, mu = 0, sigma = 1, p = 0.5, dist = "normal", nu = "", gama = "") pSKD(q, mu = 0, sigma = 1, p = 0.5, dist = "normal", nu = "", gama = "", lower.tail = TRUE) qSKD(prob, mu = 0, sigma = 1, p = 0.5, dist = "normal", nu = "", gama = "", lower.tail = TRUE) rSKD(n, mu = 0, sigma = 1, p = 0.5, dist = "normal", nu = "", gama = "") ```

## Arguments

 `y,q` vector of quantiles. `prob` vector of probabilities. `n` number of observations. `mu` location parameter. `sigma` scale parameter. `p` skewness parameter. `dist` represents the distribution to be used for the error term. The values are `normal` for Normal distribution, `t` for Student's t distribution, `laplace` for Laplace distribution, `slash` for Slash distribution and `cont` for the Contaminated normal distribution. `nu` It represents the degrees of freedom when `dist = t`. For the Slash distribution (`dist = slash`) it is a shape parameter ν>0. For the Contaminated Normal distribution, ν is the parameter that represents the percentage of outliers. When is not provided, we use the MLE. `gama` It represents a scale factor for the contaminated normal distribution. When is not provided, we use the MLE. `lower.tail` logical; if TRUE (default), probabilities are P[X ≤ x] otherwise, P[X > x].

## Details

If `mu`, `sigma`, `p` or `dist` are not specified they assume the default values of 0, 1, 0.5 and `normal`, respectively, belonging to the Symmetric Standard Normal Distribution denoted by SKN(0,1,0.5).

The scale parameter `sigma` must be positive and non zero. The skew parameter `p` must be between zero and one (0<`p`<1).

This family of distributions generalize the skew distributions in Wichitaksorn et.al. (2014) as an scale mixture of skew normal distribution. Also the Three-Parameter Asymmetric Laplace Distribution defined in Koenker and Machado (1999) is a special case.

## Value

`dSKD` gives the density, `pSKD` gives the distribution function, `qSKD` gives the quantile function, and `rSKD` generates a random sample.

The length of the result is determined by n for `rSKD`, and is the maximum of the lengths of the numerical arguments for the other functions `dSKD`, `pSKD` and `qSKD`.

## Note

The numerical arguments other than `n` are recycled to the length of the result.

## Author(s)

Christian E. Galarza <[email protected]>, Luis Benites <[email protected]> and Victor H. Lachos <[email protected]>

Maintainer: Christian E. Galarza <[email protected]>

## References

Galarza, C.M., V. H. Lachos, Cabral, CRB. and Castro L.M. (2017) Robust Quantile Regression using a Generalized Class of Skewed Distributions. Stat. <doi: 10.1002/sta4.140>.

Wichitaksorn, N., Choy, S. T., & Gerlach, R. (2014). A generalized class of skew distributions and associated robust quantile regression models. Canadian Journal of Statistics, 42(4), 579-596.

`lqr`,`ais`
 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30``` ```## Not run: ## Let's plot (Normal Vs. Student-t's with 4 df) ##Density sseq = seq(15,65,length.out = 1000) dens = dSKD(y=sseq,mu=50,sigma=3,p=0.75) plot(sseq,dens,type="l",lwd=2,col="red",xlab="x",ylab="f(x)", main="Normal Vs. t(4) densities") dens2 = dSKD(y=sseq,mu=50,sigma=3,p=0.75,dist="t",nu=4) lines(sseq,dens2,type="l",lwd=2,col="blue",lty=2) ## Distribution Function df = pSKD(q=sseq,mu=50,sigma=3,p=0.75,dist = "laplace") plot(sseq,df,type="l",lwd=2,col="blue",xlab="x",ylab="F(x)", main="Laplace Distribution function") abline(h=1,lty=2) ##Inverse Distribution Function prob = seq(0.001,0.999,length.out = 1000) idf = qSKD(prob=prob,mu=50,sigma=3,p=0.25,dist="cont",nu=0.3,gama=0.1) # 1 min appox plot(prob,idf,type="l",lwd=2,col="gray30",xlab="x",ylab=expression(F^{-1}~(x))) title(main="Skew Cont. Normal Inverse Distribution function") abline(v=c(0,1),lty=2) #Random Sample Histogram sample = rSKD(n=20000,mu=50,sigma=3,p=0.2,dist="slash",nu=3) seqq2 = seq(25,100,length.out = 1000) dens3 = dSKD(y=seqq2,mu=50,sigma=3,p=0.2,dist="slash",nu=3) hist(sample,breaks = 70,freq = FALSE,ylim=c(0,1.05*max(dens3,na.rm = TRUE)),main="") title(main="Histogram and True density") lines(seqq2,dens3,col="blue",lwd=2) ## End(Not run) ```