基于copula理论的金融时间序列模型在股票中的应用

 2021-12-28 20:32:53

论文总字数:12564字

这里给出的是论文的主要程序

数据预处理:

ss1=s1(1:2021,:);

ss2=s2(1:2021,:);

bb=zeros(200,1);

bb1=zeros(200,1);

t=1;

t1=1;

for k=1:1:2021

if ss1(k)==0

bb(t)=k;

t=t 1;

end

if ss2(k)==0

bb1(t1)=k;

t1=t1 1;

end

end

ss1([bb(1:t-1,:);bb1(1:t1-1)])=[];

ss2([bb(1:t-1,:);bb1(1:t1-1)])=[];

a1=ss1(501:2012,:);

a2=ss2(501:2012,:);

收益率计算:

%用来将收盘价转化为收益率

global h1 b1;

b1=zeros(1511,1);

aa1=flipud(a1);%用来将矩阵a上下颠倒

for k=1:1:1511

b1(k)=100*(log(aa1(k 1))-log(aa1(k)));

end

ssigma1=median(abs(b1-median(b1)))/0.6745;

h1=1.06*ssigma1*1511^(-1/5);

%用来将收盘价转化为收益率

global h b;

b=zeros(1511,1);

aa2=flipud(a2);%用来将矩阵a上下颠倒

for k=1:1:1511

b(k)=100*(log(aa2(k 1))-log(aa2(k)));

end

ssigma=median(abs(b-median(b)))/0.6745;

h=1.06*ssigma*1511^(-1/5);

GARCH类模型参数估计:

Spec = garchset('P', 1, 'Q', 1,'distribution','t');

[Coeff,Errors,LLF,Innovations,Sigmas,Summary] = garchfit(Spec,b1);

%garchdisp(Coeff,Errors);

%garchplot(Innovations,Sigmas);

middle=sqrt(Coeff.DoF./(Coeff.DoF-2))./Sigmas.*Innovations;

final=tcdf(middle,Coeff.DoF);

Spec = garchset('P', 1, 'Q', 1,'distribution','t');

[Coeff1,Errors1,LLF1,Innovations1,Sigmas1,Summary1] = garchfit(Spec,b);

%garchdisp(Coeff1,Errors1);

%garchplot(Innovations1,Sigmas1);

mmiddle=sqrt( Coeff1.DoF/(Coeff1.DoF-2))./Sigmas1.*Innovations1;

mfinal=tcdf(mmiddle, Coeff1.DoF );

各种Copula模型的参数估计:

Gumbel Copula

function fun=fun(x)

global b b1;

fun=0;

for i=1:1:1511

fun=fun log(exp(-(((-log(b(i))).^(1./x)) ((-log(b1(i))).^(1./x))).^x).*(log(b(i)).*log(b1(i))).^(1./x-1)./(b(i).*b1(i).*(((-log(b(i))).^(1./x)) ((-log(b1(i))).^(1./x))).^(2-x)).*((((-log(b(i))).^(1./x)) ((-log(b1(i))).^(1./x))).^(x) 1./x-1));

end

Clayton Copula

function fun=fun(x)

global b b1;

fun=0;

for i=1:1:1511

fun=fun log((1 x).*(b(i).*b1(i)).^(-x-1).*(b(i).^(-x) b1(i).^(-x)-1).^(-2-1./x));

end

Frank Copula

function fun=fun(x)

global b b1;

fun=0;

for i=1:1:1511

fun=fun log(-x.*(exp(-x)-1).*exp(-x.*(b(i) b1(i)))./((exp(-x)-1) (exp(-x.*b(i))-1).*(exp(-x.*b1(i))-1)).^2);

end

Gaussian Copula

function fun=fun(x)

global b b1;

fun=0;

for i=1:1:1511

X=norminv(b(i),0,1);

Y=norminv(b1(i),0,1);

fun=fun log((1-x.^2).^(-0.5).*exp((2.*x.*X.*Y-x.^2.*(X.^2 Y.^2))./(2.*(1-x.^2))));

End

RS-Copula

function fun=fun(x)

global b b1;

fun=0;

for i=1:1:1511

if b(i)lt;0.2amp;b1(i)lt;0.2

fun=fun log((1 x(1)).*(b(i).*b1(i)).^(-x(1)-1).*(b(i).^(-x(1)) b1(i).^(-x(1))-1).^(-2-1./x(1)));

elseif b(i)gt;0.8amp;b1(i)gt;0.8

fun=fun log(exp(-(((-log(b(i))).^(1./x(2))) ((-log(b1(i))).^(1./x(2)))).^x(2)).*(log(b(i)).*log(b1(i))).^(1./x(2)-1)./(b(i).*b1(i).*(((-log(b(i))).^(1./x(2))) ((-log(b1(i))).^(1./x(2)))).^(2-x(2))).*((((-log(b(i))).^(1./x(2))) ((-log(b1(i))).^(1./x(2)))).^(x(2)) 1./x(2)-1));

else

X=norminv(b(i),0,1);

Y=norminv(b1(i),0,1);

fun=fun log((1-x(3).^2).^(-0.5).*exp((2.*x(3).*X.*Y-x(3).^2.*(X.^2 Y.^2))./(2.*(1-x(3).^2))));

end

end

时变Clayton Copula

function fun=fun(x)

global b b1;

alter=@(t)(1 exp(-t)).^(-1);

a=zeros(1511,1);

a(10)=1;

canshu=zeros(1511,1);

for i=11:1:1511

sum=0;

for k=1:1:10

sum=sum abs(b(i-k)-b1(i-k));

end

a(i)=alter(x(1) x(2).*a(i-1) x(3)./10.*sum);

canshu(i)=-log(2)./log(a(i));

end

fun=0;

for i=11:1:1511

fun=fun log((1 canshu(i)).*(b(i).*b1(i)).^(-canshu(i)-1).*(b(i).^(-canshu(i)) b1(i).^(-canshu(i))-1).^(-2-1./canshu(i)));

end

时变Gumbel Copula

function fun=fun(x)

global b b1;

alter=@(t)(1 exp(-t)).^(-1);

a=zeros(1511,1);

a(10)=1;

canshu=zeros(1511,1);

for i=11:1:1511

sum=0;

for k=1:1:10

sum=sum abs(b(i-k)-b1(i-k));

end

a(i)=alter(x(1) x(2).*a(i-1) x(3)./10.*sum);

canshu(i)=log(2-a(i))./log(2);

end

fun=0;

for i=11:1:1511

fun=fun log(exp(-(((-log(b(i))).^(1./canshu(i))) ((-log(b1(i))).^(1./canshu(i)))).^canshu(i)).*(log(b(i)).*log(b1(i))).^(1./canshu(i)-1)./(b(i).*b1(i).*(((-log(b(i))).^(1./canshu(i))) ((-log(b1(i))).^(1./canshu(i)))).^(2-canshu(i))).*((((-log(b(i))).^(1./canshu(i))) ((-log(b1(i))).^(1./canshu(i)))).^(canshu(i)) 1./canshu(i)-1));

end

时变正态Copula

function fun=fun(x)

global b b1;

alter=@(t)(1-exp(-t))./(1 exp(-t));

a=zeros(1511,1);

a(10)=1;

canshu=zeros(1511,1);

for i=11:1:1511

sum=0;

for k=1:1:10

X=norminv(b(i-k),0,1);

Y=norminv(b1(i-k),0,1);

sum=sum X.*Y;

end

a(i)=alter(x(1) x(2).*a(i-1) x(3)./10.*sum);

剩余内容已隐藏,请支付后下载全文,论文总字数:12564字

您需要先支付 80元 才能查看全部内容!立即支付

该课题毕业论文、开题报告、外文翻译、程序设计、图纸设计等资料可联系客服协助查找;