dkdecvine: Working with a 'kdecvine' object

Description Usage Arguments Value Author(s) See Also Examples

Description

A C-vine density estimate (stored in a kdecvine object) can be evaluated on arbitrary points with dkecvine.

Usage

1
dkdecvine(x, object, copula_data = FALSE)

Arguments

x

m x 2 matrix of evaluation points (should be in (0,1) if copula_data = TRUE).

object

kdecvine object.

copula_data

if TRUE, returns the copula density only.

Value

A numeric vector of the density.

Author(s)

Thibault Vatter

See Also

kdecvine, dkdevine

Examples

 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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
set.seed(0)

# Quantiles of interest
alpha <- c(0.1,0.5,0.9)

## The predictors
p <- 10
n <- 1e3
X <- matrix(2 * runif(n * p) - 1, n, p)
colnames(X) <- paste0("X", 1:p)

## mean and variance shifts
Y1 <- rnorm(n) + exp(X[,1])
Y2 <- rnorm(n) * (1 + exp(X[,1]))

## For the evaluation of the results
ticks = 1e2
X.test = matrix(0, ticks, p)
X.test[,1] = seq(-0.9, 0.9, length.out = ticks)
colnames(X.test) <- paste0("X", 1:p)

## The truth
truth1 <- cbind(qnorm(0.1) + exp(X.test[,1]),
                exp(X.test[,1]),
                qnorm(0.9) + exp(X.test[,1]))
truth2 <- cbind(qnorm(0.1) * (1 + exp(X.test[,1])),
                0,
                qnorm(0.9) * (1 + exp(X.test[,1])))

## range for the margin estimates
xmin <- c(-Inf,rep(-1, p))
xmax <- c(Inf,rep(1, p))

## Can we identify the right structure?
rvr1 <- kdecvine(x = X, y = Y1, xmin = xmin, xmax = xmax,
                 test.level = 0.05, trunc.level = 1, treecrit = "hoeffd")
rvr2 <- kdecvine(x = X, y = Y2, xmin = xmin, xmax = xmax,
                 test.level = 0.05, trunc.level = 1, treecrit = "hoeffd")

## Quantile regression results
rq1 <- predict(rvr1, X.test, "quantile", tau = c(0.1, 0.5, 0.9))
rq2 <- predict(rvr2, X.test, "quantile", tau = c(0.1, 0.5, 0.9))

## Plot the results
par(mfrow = c(1,2))
plot(X[,1], Y1, xlab = "X1", ylab = "Y1")
matlines(X.test[,1], truth1, col = "green", lty = c(2,1,2), lwd = 2)
matlines(X.test[,1], rq1, col = "red", lty = c(2,1,2), lwd = 2)
legend("topleft", legend = c("data", "truth", "estimate"),
       col = c(1, "green", "red"),
       pch = c(1, rep(NA,2)),
       lty = c(0, rep(1,2)),
       cex = 0.7)
plot(X[,1], Y2, xlab = "X1", ylab = "Y2")
matlines(X.test[,1], truth2, col = "green", lty = c(2,1,2), lwd = 2)
matlines(X.test[,1], rq2, col = "red", lty = c(2,1,2), lwd = 2)

tvatter/eecop documentation built on May 28, 2019, 7:52 a.m.