vinecopulas.bivariate ===================== .. py:module:: vinecopulas.bivariate .. autoapi-nested-parse:: Created on Thu Feb 22 16:39:03 2024 Attributes ---------- .. autoapisummary:: vinecopulas.bivariate.copulas Functions --------- .. autoapisummary:: vinecopulas.bivariate.fit vinecopulas.bivariate.bestcop vinecopulas.bivariate.random vinecopulas.bivariate.randomconditional vinecopulas.bivariate.CDF vinecopulas.bivariate.PDF vinecopulas.bivariate.hfunc vinecopulas.bivariate.hfuncinverse vinecopulas.bivariate.neg_likelihood Module Contents --------------- .. py:data:: copulas .. py:function:: fit(cop, u) Fits a specific copula to data. Arguments: *cop* : An integer referring to the copula of choice. eg. a 1 refers to the gaussian copula (see `Table 1 `__). *u* : A 2-d numpy array containing the samples for which the copulae will be fit. Column 1 contains variable u1, and column 2 contains variable u2. Returns: *par* : The correlation parameters of the copula, provided as a scalar value for copulas with one parameter and as a list for copulas with more parameters (see `Table 1 `__). .. py:function:: bestcop(cops, u) Fits the best copula to data based on a selected list of copulas to fit to using the AIC. Arguments: *cops* : A list of integers referring to the copulae of interest for which the fit has to be evaluated. eg. a list of [1, 10] refers to the Gaussian and Frank copula (see `Table 1 `__). *u* : A 2-d numpy array containing the samples for which the copulae will be fit and evaluated. Column 1 contains variable u1, and column 2 contains variable u2. Returns: *cop* : An integer referring to the copula with the best fit. eg. a 1 refers to the gaussian copula (see `Table 1 `__). *par* : The correlation parameters of the copula with the best fit, provided as a scalar value for copulas with one parameter and as a list for copulas with more parameters (see `Table 1 `__). *aic* : The Akaike information criterion of the copula with the best fit. .. py:function:: random(cop, par, n) Generates random numbers from a chosen copula with specific parameters. Arguments: *cop* : An integer referring to the copula of choice. eg. a 1 refers to the gaussian copula (see `Table 1 `__). *par* : The correlation parameters of the copula, provided as a scalar value for copulas with one parameter and as a list for copulas with more parameters (see `Table 1 `__). *n* : Number of random samples to return, specified a positive integer. Returns: *u* : A 2-d numpy array containing random samples with n amount of rows. Column 1 contains variable u1, and column 2 contains variable u2. .. py:function:: randomconditional(cop, ui, par, n, un=1) Generates conditional random numbers from a chosen copula with specific parameters. Arguments: *cop* : An integer referring to the copula of choice. eg. a 1 refers to the gaussian copula (see `Table 1 `__) *ui* : A 1-d numpy array containing the samples of variable u1, if evaluated with respect to u1, or u2 if evaluated with respect to u2 on which conditional samples should be computed *par* : The correlation parameters of the copula, provided as a scalar value for copulas with one parameter and as a list for copulas with more parameters (see `Table 1 `__) *n*: number of samples to draw *un* : indicated with respect to which variable the conditional samples have to be drawn. if un = 1, conditional samples of u2 will be drawn based on u1, if un = 2, conditional samples of u1 will be drawn based on u2. Returns: *uii* : A 1-d numpy array containing the inverse h-function of the copula evaluated with respect to u1 or u2. .. py:function:: CDF(cop, u, par) Computes the cumulative distribution function. Arguments: *cop* : An integer referring to the copula of choice. eg. a 1 refers to the gaussian copula (see `Table 1 `__). *u* : A 2-d numpy array containing the samples for which the CDF will be calculated. Column 1 contains variable u1, and column 2 contains variable u2. *par* : The correlation parameters of the copula, provided as a scalar value for copulas with one parameter and as a list for copulas with more parameters (see `Table 1 `__). Returns: *p* : A 1-d numpy array containing the cumulative distribution function of the copula evaluated at u1 and u2. .. py:function:: PDF(cop, u, par) Computes the probability density function. Arguments: *cop* : An integer referring to the copula of choice. eg. a 1 refers to the gaussian copula (see `Table 1 `__). *u* : A 2-d numpy array containing the samples for which the PDF will be calculated. Column 1 contains variable u1, and column 2 contains variable u2. *par* : The correlation parameters of the copula, provided as a scalar value for copulas with one parameter and as a list for copulas with more parameters (see `Table 1 `__). Returns: *y* : A 1-d numpy array containing the probability density function of the copula evaluated at u1 and u2. .. py:function:: hfunc(cop, u1, u2, par, un=1) Computes the h-function (conditional CDF) of a copula with respect to variable u1 or u2. Arguments: *cop* : An integer referring to the copula of choice. eg. a 1 refers to the gaussian copula (see `Table 1 `__) *u1* : A 1-d numpy array containing the samples of variable u1 *u2* : A 1-d numpy array containing the samples of variable u2 *par* : The correlation parameters of the copula, provided as a scalar value for copulas with one parameter and as a list for copulas with more parameters (see `Table 1 `__). *un* : indicated with respect to which variable the h-function has to be calculated. if un = 1, the h-function is calculated with respect to u1 (c(u2|u1)), if un = 2, the h-function is calculated with respect to u2 (c(u1|u2)). Returns: *y* : A 1-d numpy array containing the h-function of the copula evaluated with respect to u1 or u2. .. py:function:: hfuncinverse(cop, ui, y, par, un=1) Computes the inverse h-function (inverse conditional CDF) of a copula with respect to variable u1 or u2. Arguments: *cop* : An integer referring to the copula of choice. eg. a 1 refers to the gaussian copula (see `Table 1 `__). *ui* : A 1-d numpy array containing the samples of variable u1, if evaluated with respect to u1, or u2 if evaluated with respect to u2. *y* : A 1-d numpy array containing the h-function of the copula evaluated with respect to u1 or u2. *par* : The correlation parameters of the copula, provided as a scalar value for copulas with one parameter and as a list for copulas with more parameters (see `Table 1 `__). *un* : indicated with respect to which variable the h-function has to be calculated. if un = 1, the h-function is calculated with respect to u1 (c(u2|u1)), if un = 2, the h-function is calculated with respect to u2 (c(u1|u2)). Returns: *uii* : A 1-d numpy array containing the inverse h-function of the copula evaluated with respect to u1 or u2. .. py:function:: neg_likelihood(par, cop, u) Computes the negative likelihood function. Arguments: *cop* : An integer referring to the copula of choice. eg. a 1 refers to the gaussian copula (see `Table 1 `__). *u* : A 2-d numpy array containing the samples for which the CDF will be calculated. Column 1 contains variable u1, and column 2 contains variable u2. *par* : The correlation parameters of the copula, provided as a scalar value for copulas with one parameter and as a list for copulas with more parameters (see `Table 1 `__). Returns: *l* : The negative likelihood as a scalar value.