Package 'csn'

Title: Closed Skew-Normal Distribution
Description: Provides functions for computing the density and the log-likelihood function of closed-skew normal variates, and for generating random vectors sampled from this distribution. See Gonzalez-Farias, G., Dominguez-Molina, J., and Gupta, A. (2004). The closed skew normal distribution, Skew-elliptical distributions and their applications: a journey beyond normality, Chapman and Hall/CRC, Boca Raton, FL, pp. 25-42.
Authors: Dmitry Pavlyuk, Eugene Girtcius
Maintainer: Dmitry Pavlyuk <[email protected]>
License: GPL-2
Version: 1.1.3
Built: 2024-12-01 07:58:46 UTC
Source: CRAN

Help Index


The probability density function

Description

The probability density function of the closed-skew normal distribution

Usage

dcsn(x, mu, sigma, gamma, nu, delta)

Arguments

x

this is either a vector of length n or a matrix with n columns, where n=ncol(sigma), giving the coordinates of the point(s) where the density must be evaluated

mu

a numeric vector representing the location parameter of the distribution; it must be of length n, as defined above

sigma

a positive definite matrix representing the scale parameter of the distribution; a vector of length 1 is also allowed

gamma

a matrix representing the skewness parameter of the distribution; a vector of length 1 is also allowed

nu

a numeric vector allows for closure with conditional densities; it must be of length q, as defined above

delta

a positive definite matrix allows for closure with the marginal densities; a vector of length 1 is also allowed

Details

Function dcsn makes use of pmvnorm and dmvnorm from package mvtnorm

Value

dcsn returns a vector of density values

See Also

pmvnorm, dmvnorm

Examples

x1 <- seq(4.5,11,length=100)
x2 <- cbind(seq(3,9,length=100),seq(7,13,length=100))
mu <- c(5,7)
sigma <- matrix(c(1,0.2,0.2,4),2)
gamma <- matrix(c(4,0,0,5),2)
nu <- c(-2,6)
delta <- matrix(c(1,0,0,1),2)
f1 <- dcsn(x1,5,9,1,0,0.05)
f2 <- dcsn(x2, mu, sigma, gamma, nu, delta)

The log-likelihood function

Description

The log-likelihood function of the closed-skew normal distribution

Usage

loglcsn(x, mu, sigma, gamma, nu, delta)

Arguments

x

this is either a vector of length n or a matrix with n columns, where n=ncol(sigma), giving the coordinates of the point(s) where the density must be evaluated

mu

a numeric vector representing the location parameter of the distribution; it must be of length n, as defined above

sigma

a positive definite matrix representing the scale parameter of the distribution; a vector of length 1 is also allowed

gamma

a matrix representing the skewness parameter of the distribution; a vector of length 1 is also allowed

nu

a numeric vector allows for closure with conditional densities; it must be of length q, as defined above

delta

a positive definite matrix allows for closure with the marginal densities; a vector of length 1 is also allowed

Details

Function loglcsn makes use of pmvnorm and dmvnorm from package mvtnorm

Value

loglcsn returns a sum of log-transformed density values

See Also

pmvnorm, dmvnorm

Examples

x <- cbind(seq(3,9,length=100),seq(7,13,length=100))
mu <- c(5,7)
sigma <- matrix(c(1,0.2,0.2,4),2)
gamma <- matrix(c(4,0,0,5),2)
nu <- c(-2,6)
delta <- matrix(c(1,0,0,1),2)
L <- loglcsn(x, mu, sigma, gamma, nu, delta)

The cumulative distribution function

Description

The cumulative distribution function of the closed-skew normal distribution

Usage

pcsn(x, mu, sigma, gamma, nu, delta)

Arguments

x

this is either a vector of length n or a matrix with n columns, where n=ncol(sigma), giving the coordinates of the point(s) where the cdf must be evaluated

mu

a numeric vector representing the location parameter of the distribution; it must be of length n, as defined above

sigma

a positive definite matrix representing the scale parameter of the distribution; a vector of length 1 is also allowed

gamma

a matrix representing the skewness parameter of the distribution; a vector of length 1 is also allowed

nu

a numeric vector allows for closure with conditional densities; it must be of length q, as defined above

delta

a positive definite matrix allows for closure with the marginal densities; a vector of length 1 is also allowed

Details

Function pcsn makes use of pmvnorm from package mvtnorm

Value

pcsn returns a vector of cdf values

See Also

pmvnorm

Examples

x1 <- seq(4,6,by = 0.1)
x2 <- x1+sin(x1)
x3 <- x1-cos(x1)
x <- cbind(x1,x2,x3)
mu <- c(1,2,3)
sigma <- matrix(c(2,-1,0,-1,2,-1,0,-1,2),3)
gamma <- matrix(c(0,1,0,2,2,3),2,3)
nu <- c(1,3)
delta <- matrix(c(1,1,1,2),2)
pcsn(6,5,9,1,0,0.05)
pcsn(c(3,4,5),mu,sigma,gamma,nu,delta)
pcsn(x,mu,sigma,gamma,nu,delta)

Random number generation

Description

Random number generation of the closed-skew normal distribution

Usage

rcsn(k, mu = rep(0, n), sigma, gamma, nu = rep(0, q), delta)

Arguments

k

the number of random numbers to be generated

mu

a numeric vector representing the location parameter of the distribution; it must be of length n, as defined above

sigma

a positive definite matrix representing the scale parameter of the distribution; a vector of length 1 is also allowed

gamma

a matrix representing the skewness parameter of the distribution; a vector of length 1 is also allowed

nu

a numeric vector allows for closure with conditional densities; it must be of length q, as defined above

delta

a positive definite matrix allows for closure with the marginal densities; a vector of length 1 is also allowed

Details

Function rcsn makes use of rmvnorm from package mvtnorm;

Value

rcsn returns a matrix of k rows of random vectors

See Also

rmvnorm

Examples

mu <- c(1,2,3)
sigma <- matrix(c(2,-1,0,-1,2,-1,0,-1,2),3)
gamma <- matrix(c(0,1,0,2,2,3),2,3)
nu <- c(1,3)
delta <- matrix(c(1,1,1,2),2)
x1 <- rcsn(100, mu, sigma, gamma, nu, delta)
x2 <- rcsn(100,5,9,1,0,0.05)