vinecopulas.vinecopula ====================== .. py:module:: vinecopulas.vinecopula .. autoapi-nested-parse:: Created on Thu Feb 22 16:40:09 2024 Attributes ---------- .. autoapisummary:: vinecopulas.vinecopula.copulas Functions --------- .. autoapisummary:: vinecopulas.vinecopula.fit_vinecop vinecopulas.vinecopula.density_vinecop vinecopulas.vinecopula.fit_vinecopstructure vinecopulas.vinecopula.sample_vinecop vinecopulas.vinecopula.sample_vinecopconditional vinecopulas.vinecopula.samplingorder vinecopulas.vinecopula.samplingmatrix vinecopulas.vinecopula.fit_conditionalvine vinecopulas.vinecopula.plotvine Module Contents --------------- .. py:data:: copulas .. py:function:: fit_vinecop(u1, copsi, vine='R', printing=True) 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 `__). .. py:function:: density_vinecop(u, M, P, C) 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 .. py:function:: fit_vinecopstructure(u1, copsi, a) 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 `__). .. py:function:: sample_vinecop(a, p, c, s) 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). .. py:function:: sample_vinecopconditional(a, p, c, s, Xc) 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). .. py:function:: samplingorder(a) 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 .. py:function:: samplingmatrix(a, c, p, sorder) 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 `__). .. py:function:: fit_conditionalvine(u1, vint, copsi, vine='R', condition=1, printing=True) 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 `__). .. py:function:: plotvine(a, plottitle=None, variables=None, savepath=None) 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*