/* Yashin-Iachine Copula ( C(u,v)=(u.*v)^(1-theta).*(u^(-k)+v^(-k)-1)^(-theta/k) ) */ /* Solve q=(1-theta)*(u.*v)^(-theta).*v.*(u^(-k)+v^(-k)-1)^(-theta/k) */ /* -theta/k*(u^(-k)+v^(-k)-1)^(-theta/k-1)*(-k).*u^(-k-1).*(u.*v)^(1-theta) */ /* in terms of v numerically. This is very slow. */ new; cls; theta=0.9; k=2; n=1000; U=Cyi(theta,k,n); library pgraph; graphset; _plctrl=-1; xy(U[.,1],U[.,2]); proc Cyi(theta,k,n); local u,q,v; if theta<0 or theta>1; errorlog "ERROR: Parameter theta must be 0<=theta<=1."; retp("."); endif; if k<=0; errorlog "ERROR: Parameter k must be positive."; retp("."); endif; u=rndu(n,1); q=rndu(n,1); v=calcv(u,q,theta,k); retp(u~v); endp; proc calcv(u,q,theta,k); local vstar,vstarstar,i,v,x; vstar=zeros(rows(q),1); i=1; do while i<=rows(q); v=seqa(0.0001,0.0001,10000); x=abs(q[i]-Cu(u[i],v,theta,k)); vstar[i]=v[minindc(x)]; v=seqa(vstar[i]-0.00005,0.00000001,10000); x=abs(q[i]-Cu(u[i],v,theta,k)); vstarstar=v[minindc(x)]; if vstarstar==vstar[i]-0.00005; v=seqa(0.00000001,0.00000001,10000); x=abs(q[i]-Cu(u[i],v,theta,k)); vstar[i]=v[minindc(x)]; else; vstar[i]=vstarstar; endif; if vstarstar>1; vstar[i]=1; endif; i=i+1; endo; retp(vstar); endp; fn Cu(u,v,theta,k)=(1-theta)*(u.*v)^(-theta).*v.*(u^(-k)+v^(-k)-1)^(-theta/k) -theta/k*(u^(-k)+v^(-k)-1)^(-theta/k-1)*(-k).*u^(-k-1).*(u.*v)^(1-theta);