/* Farlie-Gumbel-Morgenstern Copula ( C(u,v)=u.*v.*(1+theta*(1-u).*(1-v)) ) */ /* Solve q=v.*(1+theta-2*theta*u-theta*v+2*theta*u.*v) (=Cu) in terms of v. */ /* (Latin Hypercube version) */ new; cls; theta=-0.99; nn=30; /* n=nn^2 */ U=Cfgm(theta,nn); library pgraph; graphset; _plctrl=-1; xy(U[.,1],U[.,2]); proc Cfgm(theta,nn); local dim,UU,u,q,a,b,c,v; if theta<=-1 or theta>=1; errorlog "ERROR: Parameter theta must be -10); /* check if U contains 0's */ U=(d*indexvec-d*(indexvec-1)).*rndu(nn^dim,dim)+d*(indexvec-1); endo; /* randomize the order as a row */ x=zeros(nn^dim,dim); i=1; do while i<=nn^dim-1; index=ceil((nn^dim-(i-1))*rndu(1,1)); x[i,.]=U[index,.]; if index==1; U=U[2:rows(U),.]; elseif index==rows(U); U=U[1:rows(U)-1,.]; else; U=U[1:(index-1) (index+1):rows(U),.]; endif; i=i+1; endo; x[nn^dim,.]=U; retp(x); endp;