dHAC, pHAC, rHAC {HAC}R Documentation

pdf, cdf and random sampling

Description

dHAC and pHAC compute the values of the copula's density and cumulative distribution function respectively. rHAC samples from HAC.

Usage

dHAC(X, hac, eval = TRUE, margins = NULL, na.rm = FALSE, ...)
pHAC(X, hac, margins = NULL, na.rm = FALSE, ...)
rHAC(n, hac)

Arguments

X

a data matrix. The number of columns and the corresponding names have to coincide with the specifications of the copula model hac.

hac

an object of the class hac.

n

number of observations.

margins

specifies the margins. The data matrix X is assumed to contain the values of the marginal distributions by default, i.e. margins = NULL. If raw data are used, the margins can be determined nonparametrically, "edf", or in parametric way, e.g. "norm". See estimate.copula for a detailed explanation.

na.rm

boolean. If na.rm = TRUE, missing values, NA, contained in X are removed.

eval

boolean. If eval = FALSE, a non-evaluated function is returned. Note, that attr "gradient" of the returned function corresponds to the values density.

...

arguments to be passed to na.omit.

Details

Sampling schemes of hierarchical and densities of simple Archimedean copula are based on functions of the copula package.

Value

rHAC retruns a n \times d matrix, where d refers to the dimension of the HAC. dHAC and pHAC return vectors. The computation of the density might be time consuming for high-dimensions, since the density is defined as d-th derivative of the HAC with respect to its arguments u_1, \ldots, u_d.

References

Hofert, M. 2011, Efficiently Sampling Nested Archimedean Copulas, Computational Statistics & Data Analysis 55, 57-70.

Joe, H. 1997, Multivariate Models and Dependence Concepts, Chapman & Hall.

McNeil, A. J. 2008, Sampling Nested Archimedean Copulas, Journal of Statistical Computation and Simulation 78, 567-581.

Nelsen, R. B. 2006, An Introduction to Copulas, Spinger, 2nd Edition.

Okhrin, O. and Ristig, A. 2014, Hierarchical Archimedean Copulae: The ⁠HAC⁠ Package", Journal of Statistical Software, 58(4), 1-20, doi: 10.18637/jss.v058.i04.

Savu, C. and Trede, M. 2010, Hierarchies of Archimedean copulas, Quantitative Finance 10, 295-304.

See Also

estimate.copula, to.logLik

Examples

# AC example
# define the underlying model
model = hac(type = 4, tree = list("X1", "X2", 2))

# sample from model
sample = rHAC(100, model)

# returns the pdf/cdf at each vector of the sample
d.values = dHAC(sample, model)
p.values = pHAC(sample, model)

# HAC example
# the underlying model
y = c("X1", "X2", "X3")
theta = c(1.5, 3)
model = hac.full(type = 1, y, theta)

# define sample from copula model
sample = rHAC(100, model)

# returns the pdf/cdf at each point of the sample
d.values = dHAC(sample, model)
p.values = pHAC(sample, model)

# construct a hac-model
tree = list(list("X1", "X5", 3), list("X2", "X3", "X4", 4), 2)
model = hac(type = 1, tree = tree)

# sample from copula model
sample = rHAC(1000, model)

# check the accurancy of the estimation procedure
result1 = estimate.copula(sample)
result2 = estimate.copula(sample, epsilon = 0.2)

[Package HAC version 1.1-0 Index]