psp <- simCOP(n=50, cop=PSP, ploton=FALSE, points=FALSE) *150;
# Pretend psp is real data, the use of *150 is to clearly get the
# probabilities from simCOP into some other arbitrary unit system.
# The sort=FALSE is critical in the following two calls
fakeU <- pp(psp[,1], sort=FALSE); # Weibull plotting position i/(n+1)
fakeV <- pp(psp[,2], sort=FALSE); # Weibull plotting position i/(n+1)
uv <- data.frame(U=fakeU, V=fakeV); # our U-statistics
# these next two values should be REAL close with n=1000
print(EMPIRcop(0.4,0.6,para=uv));
print(PSP(0.4,0.6));
level.curvesCOP(cop=PSP); # parametric, fast, BLACK CURVES
# The level curves of the empirical copula consume lots of CPU.
# The next operation is slow, so change delu to a larger value
# from the default (0.02) works ok for a "modern" computer.
# RED CURVES
level.curvesCOP(cop=EMPIRcop, para=uv, delu=0.02, col=2, ploton=FALSE)
diagCOP(cop=EMPIRcop, para=uv)
# Experimental for author
# From R Graphics by Murrell (2005, p.112)
"trans3d" <- function(x,y,z, pmat) {
tmat <- cbind(x,y,z,1) return(tmat[,1:2] / tmat[,4])
}
the.grid <- EMPIRgrid(para=uv)
the.diag <- diagCOP(cop=EMPIRcop, para=uv, ploton=FALSE, lines=FALSE)
the.persp <- persp(the.grid$z, theta=-25, phi=20,
xlab="U VARIABLE", ylab="V VARIABLE", zlab="COPULA C(u,v)")
the.trace <- trans3d(the.diag$t, the.diag$t, the.diag$diagcop, the.persp)
lines(the.trace, lwd=2, col=2)
the.persp <- persp(x=the.grid$x, y=the.grid$y, z=the.grid$z,
theta=-25, phi=20,
xlab="U VARIABLE", ylab="V VARIABLE", zlab="COPULA C(u,v)")
the.trace <- trans3d(the.diag$t, the.diag$t, the.diag$diagcop, the.persp)
lines(the.trace, lwd=2, col=2)
Run the code above in your browser using DataLab