############################## # load new function plotCDF3 # ############################## plotCDF3 <- function (mle, surv = FALSE, bound, col=terrain.colors(20), front="fill", back="fill", smooth=FALSE, edges=FALSE, theta=-130, phi=20, xlim=NULL, ylim=NULL, xlab="x", ylab="y", zlab="CDF", main="") { p <- mle$p rects <- mle$rects m <- length(p) ncol <- length(col) if (!is.vector(p)) stop("invalid argument 'p'") if (sum(p) > 1 + 1e-05 | sum(p) < 1 - 1e-05) warning("sum(p) is not equal to 1") if (!is.matrix(rects) | ncol(rects) != 4) { stop("invalid argument 'rects': it must be a matrix with 4 columns") } if (sum(rects[, 1] > rects[, 2]) + sum(rects[, 3] > rects[, 4]) >= 1) { stop("invalid argument 'rects': each row x1,x2,y1,y2 must satisfy \nx1<=x2 and y1<=y2") } if (length(p) != nrow(rects)) stop("length(p) must equal nrow(rects)") if (ncol < 2) stop("length(col) must be >=2") if (!is.logical(edges)) stop("edges must be logical") if (bound == "u") { x <- rects[, 1] y <- rects[, 3] } if (bound == "l") { x <- rects[, 2] y <- rects[, 4] } xord <- order(x) x <- x[xord] y <- y[xord] p <- p[xord] yord <- order(y) CDF <- matrix(0, nrow = m, ncol = m+1) for (i in 1:m){ CDF[, i+1] <- CDF[, i] + p[i] * c(rep(0, yord[i]-1), rep(1, m - yord[i] + 1)) } CDF <- rbind(rep(0,m+1), CDF) CDF <- matrix(rep(CDF, each=2),nrow=2*(m+1),byrow=F) CDF <- matrix(rep(t(CDF), each=2), nrow=2*(m+1), byrow=T) if (!is.null(xlim)){ if ((xlim[1]>min(x)) | (xlim[2]min(y)) | (ylim[2]