/* Logistic Copula in Extreme Value Family */ /* C(u,v)=exp(-((-ln(u))^theta+(-ln(v))^theta)^(1/theta)) */ /* Solve q=exp(-((-ln(u))^theta+(-ln(v))^theta)^(1/theta)) */ /* .*(-1/theta).*((-ln(u))^theta+(-ln(v))^theta)^(1/theta-1) */ /* .*theta.*(-ln(u))^(theta-1).*(-1/u) (=Cu) */ /* in terms of v numerically. This is very slow. */ new; cls; theta=3; n=1000; U=Cevlg(theta,n); library pgraph; graphset; _plctrl=-1; xy(U[.,1],U[.,2]); proc Cevlg(theta,n); local u,q,v; if theta<1; errorlog "ERROR: Parameter theta must be theta>=1"; retp("."); endif; u=rndu(n,1); q=rndu(n,1); v=calcv(u,q,theta); retp(u~v); endp; proc calcv(u,q,theta); 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)); vstar[i]=v[minindc(x)]; v=seqa(vstar[i]-0.00005,0.00000001,10000); x=abs(q[i]-Cu(u[i],v,theta)); 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)); 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)=exp(-((-ln(u))^theta+(-ln(v))^theta)^(1/theta)) .*(-1/theta).*((-ln(u))^theta+(-ln(v))^theta)^(1/theta-1) .*theta.*(-ln(u))^(theta-1).*(-1/u);