vinecopulas.vinecopula

Created on Thu Feb 22 16:40:09 2024

Attributes

copulas

Functions

fit_vinecop(u1, copsi[, vine, printing])

Fit a regular vine copula to data.

density_vinecop(u, M, P, C)

Computes the density function of a vine copula.

fit_vinecopstructure(u1, copsi, a)

Fit a regular vine copula to data based on a known vine structure matrix.

sample_vinecop(a, p, c, s)

Generate random samples from an R-vine.

sample_vinecopconditional(a, p, c, s, Xc)

Generate conditional samples from an R-vine based on a provided sampling order

samplingorder(a)

Provides all the different sampling orders that are possible for the fitted vine-copula.

samplingmatrix(a, c, p, sorder)

Provides the triangular matrices for which the samples can be generated based on the specific sampling order.

fit_conditionalvine(u1, vint, copsi[, vine, ...])

Fit a regular vine copula which allows for a conditional sample of a variable of interest.

plotvine(a[, plottitle, variables, savepath])

Plots the vine structure

Module Contents

vinecopulas.vinecopula.copulas[source]
vinecopulas.vinecopula.fit_vinecop(u1, copsi, vine='R', printing=True)[source]

Fit a regular vine copula to data.

Arguments:

u1 : the data, provided as a numpy array where each column contains a separate variable (eg. u1,u2,…,un), which have already been transferred to standard uniform margins (0<= u <= 1)

copsi : A list of integers referring to the copulae of interest for which the fit has to be evaluated in the vine copula. eg. a list of [1, 10] refers to the Gaussian and Frank copula (see Table 1).

vine : The type of vine copula that needs to be fit, either ‘R’, ‘D’, or ‘C’

printing: True if the fitted copula should be printed and False if not

Returns:

a : The vine tree structure provided as a triangular matrix, composed of integers. The integer refers to different variables depending on which column the variable was in u1, where the first column is 0 and the second column is 1, etc.

p : Parameters of the bivariate copulae provided as a triangular matrix.

c : The types of the bivariate copulae provided as a triangular matrix, composed of integers referring to the copulae with the best fit. eg. a 1 refers to the gaussian copula (see Table 1).

vinecopulas.vinecopula.density_vinecop(u, M, P, C)[source]

Computes the density function of a vine copula.

Arguments:

u : A 2-d numpy array containing the samples for which the PDF will be calculated.

M : The vine tree structure provided as a triangular matrix, composed of integers. The integer refers to different variables depending on which column the variable was in u1, where the first column is 0 and the second column is 1, etc.

P : Parameters of the bivariate copulae provided as a triangular matrix.

C : The types of the bivariate copulae provided as a triangular matrix, composed of integers referring to the copulae with the best fit. eg. a 1 refers to the gaussian copula (see Table 1).

Returns:

F : A 1-d numpy array containing the probability density function of the vine copula

vinecopulas.vinecopula.fit_vinecopstructure(u1, copsi, a)[source]

Fit a regular vine copula to data based on a known vine structure matrix.

Arguments:

u1 : the data, provided as a numpy array where each column contains a seperate variable (eg. u1,u2,…,un), which have already been transferred to standard uniform margins (0<= u <= 1)

copsi : A list of integers referring to the copulae of interest for which the fit has to be evauluated in the vine copula. eg. a list of [1, 10] refers to the Gaussian and Frank copula (see Table 1).

a : The vine tree structure provided as a triangular matrix, composed of integers. The integer refers to different variables depending on which column the variable was in u1, where the first column is 0 and the second column is 1, etc.

Returns:

p : Parameters of the bivariate copulae provided as a triangular matrix.

c : The types of the bivariate copulae provided as a triangular matrix, composed of integers referring to the copulae with the best fit. eg. a 1 refers to the gaussian copula (see Table 1).

vinecopulas.vinecopula.sample_vinecop(a, p, c, s)[source]

Generate random samples from an R-vine.

Arguments:

a : The vine tree structure provided as a triangular matrix, composed of integers. The integer refers to different variables depending on which column the variable was in u1, where the first column is 0 and the second column is 1, etc.

p : Parameters of the bivariate copulae provided as a triangular matrix.

c : The types of the bivariate copulae provided as a triangular matrix, composed of integers referring to the copulae with the best fit. eg. a 1 refers to the gaussian copula (see Table 1).

s : number of samples to generate, provided as a positive scalar integer.

Returns:

X2 : the randomly sampled data data, provided as a numpy array where each column contains samples of a seperate variable (eg. u1,u2,…,un).

vinecopulas.vinecopula.sample_vinecopconditional(a, p, c, s, Xc)[source]

Generate conditional samples from an R-vine based on a provided sampling order

Arguments:

a : The vine tree structure provided as a triangular matrix, composed of integers. The integer refers to different variables depending on which column the variable was in u1, where the first column is 0 and the second column is 1, etc.

p : Parameters of the bivariate copulae provided as a triangular matrix.

c : The types of the bivariate copulae provided as a triangular matrix, composed of integers referring to the copulae with the best fit. eg. a 1 refers to the gaussian copula (see Table 1).

s : number of samples to generate, provided as a positive scalar integer.

XC: the values of the variables on which the conditional sample has to generated, provided as a 1d array that contains the the values ordered in terms of the sampling order.

Returns:

X2 : the randomly sampled data data, provided as a numpy array where each column contains samples of a seperate variable (eg. u1,u2,…,un).

vinecopulas.vinecopula.samplingorder(a)[source]

Provides all the different sampling orders that are possible for the fitted vine-copula.

Arguments:

a : The vine tree structure provided as a triangular matrix, composed of integers. The integer refers to different variables depending on which column the variable was in u1, where the first column is 0 and the second column is 1, etc.

p : Parameters of the bivariate copulae provided as a triangular matrix.

c : The types of the bivariate copulae provided as a triangular matrix, composed of integers referring to the copulae with the best fit. eg. a 1 refers to the gaussian copula (see…refer to where this information would be)

Returns:

sortingorder : A list of the different sampling orders available for the fitted vine-copula

vinecopulas.vinecopula.samplingmatrix(a, c, p, sorder)[source]

Provides the triangular matrices for which the samples can be generated based on the specific sampling order.

Arguments:

a : The vine tree structure provided as a triangular matrix, composed of integers. The integer rffers to different variables depending on which column the variable was in u1, where the first column is 0 and the second column is 1, etc.

p : Parameters of the bivariate copulae provided as a triangular matrix.

c : The types of the bivariate copulae provided as a triangular matrix, composed of integers referring to the copulae with the best fit. eg. a 1 refers to the gaussian copula (see Table 1).

sorder : A list containing the specific sampling order of interest

Returns:

ai : The vine tree structure, based on the sampling order, provided as a triangular matrix, composed of integers. The integer refers to different variables depending on which column the variable was in u1, where the first column is 0 and the second column is 1, etc.

pi : Parameters of the bivariate copulae, based on the sampling order, provided as a triangular matrix.

ci : The types of the bivariate copulae, based on the sampling order, provided as a triangular matrix, composed of integers referring to the copulae with the best fit. eg. a 1 refers to the gaussian copula (see Table 1).

vinecopulas.vinecopula.fit_conditionalvine(u1, vint, copsi, vine='R', condition=1, printing=True)[source]

Fit a regular vine copula which allows for a conditional sample of a variable of interest.

Arguments:

u1 : the data, provided as a numpy array where each column contains a seperate variable (eg. u1,u2,…,un), which have already been transferred to standard uniform margins (0<= u <= 1)

vint : the variables of interest, provided as an integere or list that refers to the variables column numbers in u1, where the first column is 0 and the second column is 1, etc.

copsi : A list of integers referring to the copulae of interest for which the fit has to be evauluated in the vine copula. eg. a list of [1, 10] refers to the Gaussian and Frank copula (see Table 1).

vine : The type of vine copula that needs to be fit, either ‘R’, ‘D’, or ‘C’

condition : condition = 1 indicates that vint needs to be the conditionalized variables (at the end of the sampling order), condition = 2 indicates that vint need to be the conditioning variables (at the start of the sampling order)

printing: True if the fitted copula should be printed and False if not

Returns:

a : The vine tree structure provided as a triangular matrix, composed of integers. The integer refers to different variables depending on which column the variable was in u1, where the first column is 0 and the second column is 1, etc.

p : Parameters of the bivariate copulae provided as a triangular matrix.

c : The types of the bivariate copulae provided as a triangular matrix, composed of integers referring to the copulae with the best fit. eg. a 1 refers to the gaussian copula (see Table 1).

vinecopulas.vinecopula.plotvine(a, plottitle=None, variables=None, savepath=None)[source]

Plots the vine structure

Arguments:

a : The vine tree structure provided as a triangular matrix, composed of integers. The integer refers to different variables depending on which column the variable was in u1, where the first column is 0 and the second column is 1, etc.

pltotitle : title of the plot

savepath : path to save the plot

Returns:

plot