| Type: | Package |
| Title: | Distributions and Gradients |
| Version: | 1.0.0 |
| Depends: | R (≥ 3.0.0) |
| Description: | Provides density, distribution function, quantile function and random generation for the split normal and split-t distributions, and computes their mean, variance, skewness and kurtosis for the two distributions (Li, F, Villani, M. and Kohn, R. (2010) <doi:10.1016/j.jspi.2010.04.031>). |
| License: | GPL-2 | GPL-3 [expanded from: GPL (≥ 2)] |
| BugReports: | https://github.com/feng-li/dng/issues |
| URL: | https://github.com/feng-li/dng/ |
| Encoding: | UTF-8 |
| Imports: | Rcpp (≥ 0.12.9) |
| LinkingTo: | Rcpp |
| Suggests: | testthat |
| RoxygenNote: | 7.3.1 |
| NeedsCompilation: | yes |
| Packaged: | 2026-04-30 02:12:19 UTC; fli |
| Author: | Feng Li |
| Maintainer: | Feng Li <feng.li@gsm.pku.edu.cn> |
| Repository: | CRAN |
| Date/Publication: | 2026-05-03 06:30:11 UTC |
Generalized hypergeometric function
Description
Evaluate generalized hypergeometric series used by the split-t gradient calculations.
Usage
ghypergeo(a, b, z, k)
Arguments
a |
matrix of upper hypergeometric parameters. |
b |
matrix of lower hypergeometric parameters. |
z |
vector of hypergeometric function arguments. |
k |
maximum number of hypergeometric series terms. Non-positive values use the package default. |
Value
A one-column numeric matrix of generalized hypergeometric function
values. Rows of a, rows of b, and values of z are
recycled to the output length.
See Also
gsplitt()
Split-normal distribution
Description
Density distribution function, quantile function and random generation function for the split normal distribution.
Usage
dsplitn(x, mu, sigma, lmd, logarithm)
gsplitn(y, par, parCaller, denscaller)
psplitn(q, mu, sigma, lmd)
qsplitn(p, mu, sigma, lmd)
rsplitn(n, mu, sigma, lmd)
Arguments
x |
vector of quantiles. |
mu |
vector of location parameter. (The mode of the density) |
sigma |
vector of standard deviations. |
lmd |
vector of skewness parameters (>0). If is 1, reduced to symmetric normal distribution. |
logarithm |
logical; if TRUE, probabilities p are given as log(p). |
y |
vector of quantiles for gradient evaluation. |
par |
list with |
parCaller |
character scalar naming the parameter to differentiate:
|
denscaller |
character vector selecting gradients to compute. Use
|
q |
vector of quantiles. |
p |
vector of probability. |
n |
number of observations. If length(n) > 1, the length is taken to be the number required. |
Details
The random ' variable y follows a split-normal distribution, y~N(\mu, '
\sigma, \lambda), which has density:
1/(1+\lambda)\sigma ' \sqrt(2/\pi)
exp{-(y-\mu)*2/2\sigma^2}, if y<=\mu
'
1/(1+\lambda)\sigma \sqrt(2/\pi)
exp{-(y-\mu)*2/2\sigma^2 \lambda^2}, ' if y>\mu
where \sigma>0 and
\lambda>0. The Split-normal ' distribution reduce to normal distribution when
\lambda=1.
Value
dsplitn gives the density; psplitn gives the percentile;
qsplitn gives the quantile; and rsplitn gives the random
variables. gsplitn returns a list with elements u and d
containing gradients of the CDF and log-density. Invalid arguments will result
in return value NaN, with a warning.
The numerical arguments other than n are recycled to the length of the result. Only the first elements of the logical arguments are used.
Functions
-
gsplitn(): Gradients for the split-normal CDF and log-density. -
psplitn(): Percentile for the split-normal distribution. -
qsplitn(): Quantile for the split-normal distribution. -
rsplitn(): Randon variables from the split-normal distribution.
Author(s)
Feng Li, Jiayue Zeng
References
Villani, M., & Larsson, R. (2006) The Multivariate Split Normal Distribution and Asymmetric Principal Components Analysis. Sveriges Riksbank Working Paper Series, No. 175.
See Also
splitn_mean(),
splitn_var(),splitn_skewness() and
splitn_kurtosis() for numerical characteristics of the
split-normal distribution.
Examples
n <- 3
mu <- c(0,1,2)
sigma <- c(1,2,3)
lmd <- c(1,2,3)
q0 <- rsplitn(n, mu, sigma, lmd)
d0 <- dsplitn(q0, mu, sigma, lmd, logarithm = FALSE)
p0 <- psplitn(q0, mu, sigma, lmd)
q1 <- qsplitn(p0,mu, sigma, lmd)
all.equal(q0, q1)
Moments of the split normal distribution
Description
Computing the mean, variance, skewness and kurtosis for the split-normal distribution.
Usage
splitn_kurtosis(lmd)
splitn_mean(mu, sigma, lmd)
splitn_skewness(sigma, lmd)
splitn_var(sigma, lmd)
Arguments
lmd |
vector of skewness parameters (>0). If is 1, reduce to normal distribution. |
mu |
vector of location parameter. (The mode of the density) |
sigma |
vector of standard deviations. |
Value
splitn_mean gives the mean. splitn_var gives the
variance. splitn_skewness gives the skewness.
splitn_kurtosis gives the kurtosis. (splitn_mean,
splitn_var,splitn_skeness and splitn_kurtosis are all
vectors.
Functions
-
splitn_kurtosis(): Kurtosis for the split-normal distribution. -
splitn_skewness(): Skewness for the split-normal distribution. -
splitn_var(): Variance for the split-normal distribution.
Author(s)
Feng Li, Jiayue Zeng
References
Villani, M., & Larsson, R. (2006) The Multivariate Split Normal Distribution and Asymmetric Principal Components Analysis. Sveriges Riksbank Working Paper Series, No. 175.
See Also
psplitn() dsplitn() qsplitn() and
rsplitn() for the split-normal distribution.
Examples
mu <- c(0,1,2)
sigma <- c(0.5,1,2)
lmd <- c(1,2,3)
mean0 <- splitn_mean(mu, sigma, lmd)
var0 <- splitn_var(sigma, lmd)
skewness0 <- splitn_skewness(sigma, lmd)
kurtosis0 <- splitn_kurtosis(lmd)
Split-t distribution
Description
Density, distribution function, quantile function and random generation for the normal distribution for the split student-t distribution.
Usage
dsplitt(x, mu, df, phi, lmd, logarithm)
gsplitt(y, par, parCaller, denscaller)
psplitt(q, mu, df, phi, lmd)
qsplitt(p, mu, df, phi, lmd)
rsplitt(n, mu, df, phi, lmd)
Arguments
x |
vector of quantiles. |
mu |
vector of location parameter. (The mode of the density) |
df |
degrees of freedom (> 0, can be non-integer). df = Inf is also allowed. |
phi |
vector of scale parameters (>0). |
lmd |
vector of skewness parameters (>0). If is 1, reduced to the symmetric student t distribution. |
logarithm |
logical; if TRUE, probabilities p are given as log(p). |
y |
vector of quantiles for gradient evaluation. |
par |
list with |
parCaller |
character scalar naming the parameter to differentiate:
|
denscaller |
character vector selecting gradients to compute. Use
|
q |
vector of quantiles. |
p |
vector of probability. |
n |
number of observations. If length(n) > 1, the length is taken to be the number required. |
Details
The random variable y follows a split-t distribution with \nu>0
degrees of freedom, y~t(\mu, \phi, \lambda, \nu),
if its density function is of the form
C K(\mu, \phi, \nu,)I(y\leq\mu) + C K(\mu, \lambda \phi,
\nu)I(y>\mu),
where,
K(\mu, \phi, \nu,) =[\nu/(\nu+(y-\mu)^2 /\phi
^2)]^{(\nu+1)/2}
is the kernel of a student t density with variance
\phi ^2\nu/(\nu-2) and
c = 2[(1+\lambda)\phi (\sqrt \nu)
Beta(\nu/2,1/2)]^{-1}
is the normalization constant.
Value
dsplitt gives the density; psplitt gives the percentile;
qsplitt gives the quantile; and rsplitt gives the random
variables. gsplitt returns a list with elements u and d
containing gradients of the CDF and log-density. Invalid arguments will
result in return value NaN, with a warning.
The numerical arguments other than n are recycled to the length of the result. Only the first elements of the logical arguments are used.
Functions
-
gsplitt(): Gradients for the split-t CDF and log-density. -
psplitt(): Percentile for the split-t distribution. -
qsplitt(): Quantile for the split-t distribution. -
rsplitt(): Randon variables from the split-t distribution.
Author(s)
Feng Li, Jiayue Zeng
References
Li, F., Villani, M., & Kohn, R. (2010). Flexible modeling of conditional distributions using smooth mixtures of asymmetric student t densities. Journal of Statistical Planning & Inference, 140(12), 3638-3654.
See Also
splitt_mean(),
splitt_var(),splitt_skewness() and
splitt_kurtosis() for numerical characteristics of the
Split-t distribution.
Examples
n <- 3
mu <- c(0,1,2)
df <- rep(10,3)
phi <- c(0.5,1,2)
lmd <- c(1,2,3)
q0 <- rsplitt(n, mu, df, phi, lmd)
d0 <- dsplitt(q0, mu, df, phi, lmd, logarithm = FALSE)
p0 <- psplitt(q0, mu, df, phi, lmd)
q1 <- qsplitt(p0,mu, df, phi, lmd)
all.equal(q0, q1)
Moments of the split-t distribution
Description
Computing the mean, variance, skewness and kurtosis for the split student-t distribution.
Usage
splitt_kurtosis(df, phi, lmd)
splitt_mean(mu, df, phi, lmd)
splitt_skewness(df, phi, lmd)
splitt_var(df, phi, lmd)
Arguments
df |
degrees of freedom (> 0, can be non-integer). df = Inf is allowed. |
phi |
vector of scale parameters (> 0). |
lmd |
vector of skewness parameters (> 0). If is 1, reduced to symmetric student t distribution. |
mu |
vector of location parameter. (The mode of the density) |
Value
splitt_mean gives the mean. splitt_var gives the
variance. splitt_skewness gives the skewness. splitt_kurtosis
gives the kurtosis. (splitt_mean,
splitt_var,splitt_skeness and splitt_kurtosis are all
vectors.)
Invalid arguments will result in return value NaN, with a warning.
Functions
-
splitt_kurtosis(): Kurtosis for the split-t distribution. -
splitt_skewness(): Skewness for the split-t distribution. -
splitt_var(): Variance for the split-t distribution.
Author(s)
Feng Li, Jiayue Zeng
References
Li, F., Villani, M., & Kohn, R. (2010). Flexible modeling of conditional distributions using smooth mixtures of asymmetric student t densities. Journal of Statistical Planning & Inference, 140(12), 3638-3654.
See Also
dsplitt(), psplitt(),
qsplitt() and rsplitt() for the split-t
distribution.
Examples
mu <- c(0,1,2)
df <- rep(10,3)
phi <- c(0.5,1,2)
lmd <- c(1,2,3)
mean0 <- splitt_mean(mu, df, phi, lmd)
var0 <- splitt_var(df, phi, lmd)
skewness0 <- splitt_skewness(df, phi, lmd)
kurtosis0 <- splitt_kurtosis(df, phi, lmd)