⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 copulastat.m

📁 copua是金融数学计算中的一类新模型。本代码提供了最常用的copula模型
💻 M
字号:
function tau = copulastat(type,param)
%COPULASTAT Kendall's rank correlation for a copula.
%   TAU = COPULAPARAM('Gaussian',RHO) returns Kendall's rank correlation
%   TAU corresponding to a Gaussian copula having linear correlation
%   parameter RHO.  If RHO is a scalar correlation coefficient, TAU is a
%   scalar correlation coefficient corresponding to a bivariate copula.  If
%   RHO is a P-by-P correlation matrix, TAU is a P-by-P correlation matrix
%   corresponding to a P-variate copula.
%
%   RHO = COPULAPARAM('t',TAU) returns Kendall's rank correlation TAU
%   corresponding to a t copula having linear correlation parameter RHO. If
%   RHO is a scalar correlation coefficient, TAU is a scalar correlation
%   coefficient corresponding to a bivariate copula.  If RHO is a P-by-P
%   correlation matrix, TAU is a P-by-P correlation matrix corresponding to
%   a P-variate copula.
%   
%   TAU = COPULASTAT(TYPE,ALPHA) returns Kendall's rank correlation TAU
%   corresponding to a bivariate Archimedean copula with parameter ALPHA.
%   TYPE is one of 'Clayton', 'Frank', or 'Gumbel'.
%
%   Example:
%      % Determine the theoretical rank correlation coefficient for a
%      % bivariate Gaussian copula with linear correlation parameter -0.7071
%      rho = -.7071
%      tau = copulastat('gaussian',rho)
%
%      % Generate dependent beta random values using that copula
%      u = copularnd('gaussian',rho,100)
%      b = betainv(u,2,2)
%
%      % Verify that those pairs have a sample rank correlation approximately
%      % equal to tau
%      tau_sample = kendall(b)

%   Written by Peter Perkins, The MathWorks, Inc.
%   Revision: 1.0  Date: 2003/09/05
%   This function is not supported by The MathWorks, Inc.
%
%   Requires MATLAB R13.

if nargin < 2
    error('Requires two input arguments.');
end

switch lower(type)
case {'gaussian' 't'}
    rho = param;
    if ((numel(rho) == 1) && (rho < -1 | 1 < rho)) || ((numel(rho) ~= 1) && ~iscor(rho))
        error('RHO must be a correlation coefficient between -1 and 1, or a positive semidefinite correlation matrix.');
    end
    tau = 2.*asin(rho)./pi;
    
case {'clayton' 'frank' 'gumbel'}
    alpha = param;
    if numel(alpha) ~= 1
        error('ALPHA must be a scalar.');
    end
    switch lower(type)
    case 'clayton'
        if alpha < 0
            error('ALPHA must be nonnegative for the Clayton copula.');
        end
        tau = alpha ./ (2 + alpha);
    case 'frank'
        if alpha ~= 0
            tau = 1 + 4 .* (debye1(alpha)-1) ./ alpha;
        else
            tau = 0;
        end
    case 'gumbel'
        if alpha < 1
            error('ALPHA must be greater than or equal to 1 for the Gumbel copula.');
        end
        tau = 1 - 1./alpha;
    end
    
otherwise
    error('Unrecognized copula type: ''%s''',type);
end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -