pcondrvine: Conditional Distribution in a Regular Vine

Description Usage Arguments Details Value Examples

View source: R/pcondrvine.R

Description

Evaluates the conditional distribution of a variable in a regular vine out of all specified variables. As of now, will likely only work if the vine is regular, and truncated in the traditional sense.

Usage

1
pcondrvine(dat, rv, var, condset, maxint = 2, verbose = FALSE)

Arguments

dat

vector or matrix of uniform observations (columns are variables).

rv

Regular vine object.

var

Integer; the variable you wish to condition on (i.e. the column number of dat, also present in rv).

condset

Vector of the conditioning variables (integers). Optional; leave blank to condition var on all other variables in rv.

maxint

Integer; maximum dimension of integration to tolerate. Put Inf if you don't want an upper limit.

verbose

Logical; should the function output how it goes about finding the conditional distribution?

Details

To compute the conditional distribution, the vine is subsetted to the selected variables if possible. Then, if the conditioned variable is a leaf, the conditional distributon is directly computed. If it's not a leaf, the conditional distribution is computed by integrating the density.

If the subsetted vine does not exist, then the vine will be subsetted "as much as possible", and the remaining variables that cannot be removed will be integrated out to find the joint density of the selected variables, from which the conditional cdf will be found.

Value

A vector of length = the number of observations in dat, representing the evaluated conditional distribution of variable var given the other variables in condset.

If integration beyond maxint dimensions is required to obtain the quantities, then an error is thrown.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
## D-Vine example
G <- AtoG(CopulaModel::Dvinearray(5))[1:3, ]
rv <- rvine(G, "bvncop", makeuppertri(c(1:7/10), 2, 5, byRow = FALSE))
dat <- rrvine(10, rv)

## Compute 5|1:4. There's an algorithm for that.
pcondrvine(dat, rv, var=5, verbose=T)

## Compute 5|4. pcondrvine just uses 'pcondcop()'.
pcondrvine(dat, rv, var=5, condset=4, verbose=T)

## Compute 5|2:3. Two integrals takes ~13 min if maxint > 1.
pcondrvine(dat, rv, var=5, condset=c(2,3), maxint=1, verbose=T)

## Compute 4|(1,2,3,5). No algorithm for that.
pcondrvine(dat, rv, var=4, verbose=T)
pcondrvine(dat, rv, var=4, maxint=0, verbose=T) # No int. tolerance

vincenzocoia/copsupp documentation built on Aug. 23, 2020, 7:37 a.m.