This is an automated email from the git hooks/post-receive script. tille pushed a commit to branch master in repository r-cran-ellipse.
commit fa0bf4d2ec559323487a3712a7a3af155689a9e6 Author: Andreas Tille <[email protected]> Date: Fri Sep 29 14:23:33 2017 +0200 New upstream version 0.3-8 --- DESCRIPTION | 23 ++++++++++ MD5 | 25 ++++++++++ NAMESPACE | 10 ++++ R/ellipse.R | 2 + R/ellipse.arima0.R | 6 +++ R/ellipse.default.R | 25 ++++++++++ R/ellipse.glm.R | 11 +++++ R/ellipse.lm.R | 8 ++++ R/ellipse.nls.R | 8 ++++ R/ellipse.profile.R | 74 ++++++++++++++++++++++++++++++ R/ellipse.profile.glm.R | 9 ++++ R/ellipse.profile.nls.R | 6 +++ R/pairs.profile.R | 111 +++++++++++++++++++++++++++++++++++++++++++++ R/plotcorr.R | 102 +++++++++++++++++++++++++++++++++++++++++ README | 29 ++++++++++++ debian/changelog | 5 -- debian/compat | 1 - debian/control | 23 ---------- debian/copyright | 31 ------------- debian/rules | 3 -- debian/source/format | 1 - debian/upstream/metadata | 10 ---- debian/watch | 2 - man/ellipse-package.Rd | 46 +++++++++++++++++++ man/ellipse.Rd | 78 +++++++++++++++++++++++++++++++ man/ellipse.arima0.Rd | 51 +++++++++++++++++++++ man/ellipse.glm.Rd | 67 +++++++++++++++++++++++++++ man/ellipse.lm.Rd | 51 +++++++++++++++++++++ man/ellipse.nls.Rd | 54 ++++++++++++++++++++++ man/ellipse.profile.Rd | 70 ++++++++++++++++++++++++++++ man/ellipse.profile.glm.Rd | 82 +++++++++++++++++++++++++++++++++ man/ellipse.profile.nls.Rd | 66 +++++++++++++++++++++++++++ man/pairs.profile.Rd | 74 ++++++++++++++++++++++++++++++ man/plotcorr.Rd | 81 +++++++++++++++++++++++++++++++++ 34 files changed, 1169 insertions(+), 76 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION new file mode 100644 index 0000000..d457e87 --- /dev/null +++ b/DESCRIPTION @@ -0,0 +1,23 @@ +Package: ellipse +Version: 0.3-8 +Date: 2013-04-13 +Title: Functions for drawing ellipses and ellipse-like confidence + regions +Author: Duncan Murdoch <[email protected]> and E. D. Chow (porting + to R by Jesus M. Frias Celayeta <[email protected]>) +Maintainer: Duncan Murdoch <[email protected]> +Description: This package contains various routines for drawing + ellipses and ellipse-like confidence regions, implementing the + plots described in Murdoch and Chow (1996), A graphical display + of large correlation matrices, The American Statistician 50, + 178-180. There are also routines implementing the profile plots + described in Bates and Watts (1988), Nonlinear Regression + Analysis and its Applications. +Depends: R (>= 2.0.0),graphics,stats +Suggests: MASS +LazyLoad: yes +License: GPL (>= 2) +Packaged: 2013-04-13 14:23:12 UTC; murdoch +NeedsCompilation: no +Repository: CRAN +Date/Publication: 2013-04-13 18:32:27 diff --git a/MD5 b/MD5 new file mode 100644 index 0000000..34ed9cf --- /dev/null +++ b/MD5 @@ -0,0 +1,25 @@ +5cb6594dd0fec32696b1c795ff04253a *DESCRIPTION +c0f8e06aa745d323551c9c17bc5080c4 *NAMESPACE +73fea51373da9bbc4ff85c413745b526 *R/ellipse.R +4be8275a614fcb4065c37b8762941247 *R/ellipse.arima0.R +caee0c1cfc23e089ee9ba8f4b4798039 *R/ellipse.default.R +3c552169931b0006165ac5b1ae888eb3 *R/ellipse.glm.R +f3a81546119e55c3f45191add9fea049 *R/ellipse.lm.R +84a3d7dd1aa99c82424453da914feaaa *R/ellipse.nls.R +1f6cc6a9602728096e1a5c17db75a3d1 *R/ellipse.profile.R +179ff82c9db9ac24d7c28250d7dbd4ac *R/ellipse.profile.glm.R +e9db7c17f6821149220b411bfd6441a6 *R/ellipse.profile.nls.R +84c9bed516bd61a0b4d5a0a6aadda792 *R/pairs.profile.R +f410502cb27f5f2cfaee61bcf133abe3 *R/plotcorr.R +99f607a6fdc968d3ac4feeda1f11bbd7 *README +c72cbb10c7117b72c4661f1e985e20e4 *man/ellipse-package.Rd +a20be12fc0bc7bd5f179a90dcacfa291 *man/ellipse.Rd +2a7bc110f3041d43ddd9ae601bf81912 *man/ellipse.arima0.Rd +13796f5667a8b5b3c3eda8778ec508b1 *man/ellipse.glm.Rd +8de4342bb0e4fd05f84cd2f244d3a58a *man/ellipse.lm.Rd +a44b6aebadb5c6335f6e711b23152475 *man/ellipse.nls.Rd +0f2ec2da5cb8932fd631826ca008e366 *man/ellipse.profile.Rd +7c26b34627f1934d7b601edc1fa43b79 *man/ellipse.profile.glm.Rd +a23b5bebb2dc3e1e01018fa9721db2f8 *man/ellipse.profile.nls.Rd +966139fb90ef34fc4cf99889dde5005d *man/pairs.profile.Rd +a5e1d2e0c9bdebccc53aa17b95d7f4a4 *man/plotcorr.Rd diff --git a/NAMESPACE b/NAMESPACE new file mode 100644 index 0000000..c5d227f --- /dev/null +++ b/NAMESPACE @@ -0,0 +1,10 @@ +export(ellipse,plotcorr) +S3method(ellipse,arima0) +S3method(ellipse,default) +S3method(ellipse,glm) +S3method(ellipse,lm) +S3method(ellipse,nls) +S3method(ellipse,profile) +S3method(ellipse,profile.glm) +S3method(ellipse,profile.nls) +S3method(pairs,profile) diff --git a/R/ellipse.R b/R/ellipse.R new file mode 100644 index 0000000..23e32be --- /dev/null +++ b/R/ellipse.R @@ -0,0 +1,2 @@ +"ellipse" <-function (x, ...) + UseMethod("ellipse") diff --git a/R/ellipse.arima0.R b/R/ellipse.arima0.R new file mode 100644 index 0000000..fc616c6 --- /dev/null +++ b/R/ellipse.arima0.R @@ -0,0 +1,6 @@ +ellipse.arima0<- + function(x, which = c(1, 2), level = 0.95, t = sqrt(qchisq(level, 2)), ...) +{ + ellipse.default(x$var.coef[which, which], centre = x$coef[which], t = t, ...) +} + diff --git a/R/ellipse.default.R b/R/ellipse.default.R new file mode 100644 index 0000000..972068a --- /dev/null +++ b/R/ellipse.default.R @@ -0,0 +1,25 @@ +"ellipse.default" <- + function (x, scale = c(1, 1), centre = c(0, 0), level = 0.95, + t = sqrt(qchisq(level, 2)), which = c(1, 2), npoints = 100, ...) +{ + names <- c("x", "y") + if (is.matrix(x)) { + xind <- which[1] + yind <- which[2] + r <- x[xind, yind] + if (missing(scale)) { + scale <- sqrt(c(x[xind, xind], x[yind, yind])) + if (scale[1] > 0) r <- r/scale[1] + if (scale[2] > 0) r <- r/scale[2] + } + if (!is.null(dimnames(x)[[1]])) + names <- dimnames(x)[[1]][c(xind, yind)] + } + else r <- x + r <- min(max(r,-1),1) # clamp to -1..1, in case of rounding errors + d <- acos(r) + a <- seq(0, 2 * pi, len = npoints) + matrix(c(t * scale[1] * cos(a + d/2) + centre[1], t * scale[2] * + cos(a - d/2) + centre[2]), npoints, 2, dimnames = list(NULL, + names)) +} diff --git a/R/ellipse.glm.R b/R/ellipse.glm.R new file mode 100644 index 0000000..653d423 --- /dev/null +++ b/R/ellipse.glm.R @@ -0,0 +1,11 @@ +"ellipse.glm" <- + function (x, which = c(1, 2), level = 0.95, t, npoints = 100, dispersion, ...) +{ + s <- summary(x) + est.disp <- missing(dispersion) & !(x$family$family %in% c('poisson','binomial')) + if (missing(dispersion)) dispersion <- s$dispersion + if (missing(t)) t <- ifelse(est.disp,sqrt(2 * qf(level, 2, s$df[2])), + sqrt(qchisq(level, 2))) + ellipse.default(dispersion * s$cov.unscaled[which, which], + centre = x$coefficients[which], t = t, npoints = npoints, ...) +} diff --git a/R/ellipse.lm.R b/R/ellipse.lm.R new file mode 100644 index 0000000..d9e8ed2 --- /dev/null +++ b/R/ellipse.lm.R @@ -0,0 +1,8 @@ +"ellipse.lm" <- + function (x, which = c(1, 2), level = 0.95, t = sqrt(2 * qf(level, + 2, x$df.residual)), ...) +{ + s <- summary(x) + ellipse.default(s$sigma^2 * s$cov.unscaled[which, which], + centre = x$coefficients[which], t = t, ...) +} diff --git a/R/ellipse.nls.R b/R/ellipse.nls.R new file mode 100644 index 0000000..dc68cba --- /dev/null +++ b/R/ellipse.nls.R @@ -0,0 +1,8 @@ +"ellipse.nls" <- + function (x, which = c(1, 2), level = 0.95, t = sqrt(2 * qf(level, + 2, s$df[2])), ...) +{ + s <- summary(x) + ellipse.default(s$sigma^2 * s$cov.unscaled[which, which], + centre = x$m$getPars()[which], t = t, ...) +} diff --git a/R/ellipse.profile.R b/R/ellipse.profile.R new file mode 100644 index 0000000..1b3f4aa --- /dev/null +++ b/R/ellipse.profile.R @@ -0,0 +1,74 @@ +"ellipse.profile" <- + function (x, which = c(1, 2), level = 0.95, t = sqrt(qchisq(level, + 2)), npoints = 100, ...) +{ + aa <- x[[which[1]]][[2]][, which[1]] + ar <- x[[which[1]]][[2]][, which[2]] + ra <- x[[which[2]]][[2]][, which[1]] + rr <- x[[which[2]]][[2]][, which[2]] + atau <- x[[which[1]]][[1]] + rtau <- x[[which[2]]][[1]] + arange <- range(c(aa, ra)) + rrange <- range(c(ar, rr)) + atau <- atau/t + rtau <- rtau/t + getad <- function(tau1, tau2) { + if (abs(tau1) > 1) + tau1 <- tau1/abs(tau1) + if (abs(tau2) > 1) + tau2 <- tau2/abs(tau2) + acos1 <- acos(tau1) + acos2 <- acos(tau2) + d <- abs(acos1 - acos2) + a <- (acos1 + acos2)/2 + if (acos1 < acos2) + a <- -a + c(a, d) + } + myapprox <- function(x, y, where) { + good <- is.finite(x) & is.finite(y) + x <- x[good] + y <- y[good] + if (length(x) > 1) { + result <- approx(x[good], y[good], where)$y + bad <- is.na(result) + if (any(bad)) { + for (i in 1:length(result)) { + if (bad[i]) { + if (where[i] > x[length(x)]) { + x1 <- x[length(x) - 1] + y1 <- y[length(x) - 1] + x2 <- x[length(x)] + y2 <- y[length(x)] + } + else if (where[i] < x[1]) { + x1 <- x[1] + y1 <- y[1] + x2 <- x[2] + y2 <- y[2] + } + else stop("Unexpected NA") + result[i] <- y1 + (where[i] - x1)/(x2 - x1) * + (y2 - y1) + } + } + } + } + else result <- rep(y, length(where)) + result + } + ad <- matrix(NA, nrow = 5, ncol = 2) + ad[1, ] <- getad(1, myapprox(rr, rtau, myapprox(aa, ar, myapprox(atau, aa, 1)))) + ad[2, ] <- getad(myapprox(aa, atau, myapprox(rr, ra, myapprox(rtau, rr, 1))), 1) + ad[3, ] <- getad(-1, myapprox(rr, rtau, myapprox(aa, ar, myapprox(atau, aa, -1)))) + ad[4, ] <- getad(myapprox(aa, atau, myapprox(rr, ra, myapprox(rtau, rr, -1))), -1) + i <- order(ad[1:4, 1]) + ad[1:4, ] <- ad[i, ] + ad[5, 1] <- ad[1, 1] + 2 * pi + ad[5, 2] <- ad[1, 2] + ad <- ad[!duplicated(ad[, 1]), ] + adv <- spline(ad, n = npoints, method= "periodic") + avals <- adv$x + dvals <- adv$y + matrix(c(myapprox(atau, aa, cos(avals + dvals/2)), myapprox(rtau, rr, cos(avals - dvals/2))), length(avals), 2, dimnames = list(NULL, names(x[which]))) +} diff --git a/R/ellipse.profile.glm.R b/R/ellipse.profile.glm.R new file mode 100644 index 0000000..6e77d8a --- /dev/null +++ b/R/ellipse.profile.glm.R @@ -0,0 +1,9 @@ +"ellipse.profile.glm" <- + function (x, which = c(1, 2), level = 0.95, t, npoints = 100, dispersion, ...) +{ + if (missing(dispersion)) dispersion <- ifelse(attr(x,"original.fit")$family$family %in% c('poisson','binomial'), + 1, NA) + if (missing(t)) t <- ifelse(is.na(dispersion),sqrt(2 * qf(level, 2, attr(x,"summary")$df[2])), + sqrt(qchisq(level, 2)*dispersion/attr(x,"summary")$dispersion)) + ellipse.profile(x, which = which, level = level, t = t, npoints = npoints) +} diff --git a/R/ellipse.profile.nls.R b/R/ellipse.profile.nls.R new file mode 100644 index 0000000..ecb67a6 --- /dev/null +++ b/R/ellipse.profile.nls.R @@ -0,0 +1,6 @@ +"ellipse.profile.nls" <- + function (x, which = c(1, 2), level = 0.95, t = sqrt(2 * qf(level, 2, attr(x, + "summary")$df[2])), npoints = 100, ...) +{ + ellipse.profile(x, which = which, level = level, t = t, npoints = npoints) +} diff --git a/R/pairs.profile.R b/R/pairs.profile.R new file mode 100644 index 0000000..fef18e3 --- /dev/null +++ b/R/pairs.profile.R @@ -0,0 +1,111 @@ +"pairs.profile" <- + function (x, labels = c(names(x), "Profile tau"), panel = lines, + invert = TRUE, plot.tau = TRUE, plot.trace = TRUE, plot.sketch = TRUE, + plot.ellipse = FALSE, level = 0.95, ...) +{ + doaxis <- function(which, dolabel = TRUE) axis(which, labels = dolabel) # outer = TRUE, line = -0.5, labels = dolabel) + setup <- function(x, y, ...) plot(range(x[!is.na(x)]), + range(y[!is.na(y)]), type = "n", axes = FALSE, ...) + if (is.character(panel)) + panel <- get(panel, mode = "function") + n <- length(x) + if (plot.tau) + n <- n + 1 + oldpar <- par("oma", "mar", "cex", "tck", "mgp", "mex", + "mfrow") + oldcex <- par("cex") + CEX <- oldcex * max(7.7/(2 * n + 3), 0.6) + par(mfrow = c(n, n), mgp = c(2, 0.8, 0), oma = rep(3, 4), + mar = rep(0.5, 4), tck = -0.03/n) + on.exit({ + par(oldpar) + }) + par(cex = CEX) + if (length(labels) < n) + labels <- paste(deparse(substitute(x)), "[,", 1:n, "]", + sep = "") + if (par("pty") == "s") { + dif <- diff(par("fin"))/2 + if (dif > 0) + par(omi = c(dif * n, 0, dif * n, 0) + par("omi")) + else par(omi = c(0, (-dif) * n, 0, (-dif) * n) + par("omi")) + } + alltau <- unlist(lapply(x, function(x) x[[1]]), use.names = FALSE) + order <- if (invert) + 1:n + else n:1 + for (i in order) { + for (j in 1:n) { + if (i <= length(x)) { + icomp <- x[[i]] + ipars <- as.matrix(icomp[[2]]) + } + if (j <= length(x)) { + jcomp <- x[[j]] + jpars <- as.matrix(jcomp[[2]]) + } + xx1 <- NA + xx2 <- NA + yy1 <- NA + yy2 <- NA + if (i <= length(x)) { + yy1 <- ipars[, i] + if (j <= length(x)) { + xx1 <- ipars[, j] + xx2 <- jpars[, j] + yy2 <- jpars[, i] + } + else { + xx1 <- icomp[[1]] + } + } + else { + yy1 <- jcomp[[1]] + if (j <= length(x)) { + xx1 <- jpars[, j] + } + } + xx <- c(xx1, NA, xx2) + yy <- c(yy1, NA, yy2) + if (i <= length(x)) { + if (j <= length(x)) + setup(xx, yy, ...) + else setup(alltau, yy, ...) + } + else { + if (j <= length(x)) + setup(xx, alltau, ...) + else setup(alltau, alltau) + } + box() + if (i == 1) + doaxis(3, j%%2 == 0) + if (i == n) + doaxis(1, j%%2 == 1) + if (j == 1) + doaxis(2, i%%2 == 0) + if (j == n) + doaxis(4, i%%2 == 1) + if (i != j) { + if ((i <= length(x)) && (j <= length(x))) { + if (plot.trace) + panel(xx, yy, ...) + if (plot.sketch) + for (l in level) panel(ellipse(x, which = c(j, + i), level = l), ...) + if (plot.ellipse && !is.null(fit <- attr(x, + "original.fit"))) + for (l in level) panel(ellipse(fit, which = c(j, + i), level = l), ...) + } + else if (plot.tau) + panel(xx, yy, ...) + } + else { + par(usr = c(0, 1, 0, 1)) + text(0.5, 0.5, labels[i], cex = 1.5 * CEX) + } + } + } + invisible() +} diff --git a/R/plotcorr.R b/R/plotcorr.R new file mode 100644 index 0000000..594b4af --- /dev/null +++ b/R/plotcorr.R @@ -0,0 +1,102 @@ +"plotcorr" <- + function (corr, outline = TRUE, col = 'grey', numbers = FALSE, type = c("full","lower","upper"), + diag = (type == "full"), bty = "n", axes = FALSE, xlab = "", ylab = "", asp = 1, + cex.lab = par("cex.lab"), cex = 0.75*par("cex"), mar = 0.1 + c(2,2,4,2), ...) +{ + savepar <- par(pty = "s", mar = mar) + on.exit(par(savepar)) + + if (is.null(corr)) return(invisible()) + if ((!is.matrix(corr)) || (round(min(corr, na.rm = TRUE), 6) < -1) + || (round(max(corr, na.rm = TRUE), 6) > 1)) + stop("Need a correlation matrix") + + plot.new() + par(new = TRUE) + + rowdim <- dim(corr)[1] + coldim <- dim(corr)[2] + + rowlabs <- dimnames(corr)[[1]] + collabs <- dimnames(corr)[[2]] + if (is.null(rowlabs)) rowlabs <- 1:rowdim + if (is.null(collabs)) collabs <- 1:coldim + rowlabs <- as.character(rowlabs) + collabs <- as.character(collabs) + + col <- rep(col, length = length(corr)) + dim(col) <- dim(corr) + + type <- match.arg(type) + + cols <- 1:coldim + rows <- 1:rowdim + + xshift <- 0 + yshift <- 0 + + if (!diag) { + if (type == "upper") { + cols <- 2:coldim + rows <- 1:(rowdim - 1) + xshift <- 1 + } else if (type == "lower") { + cols <- 1:(coldim-1) + rows <- 2:rowdim + yshift <- -1 + } + } + + maxdim <- max(length(rows), length(cols)) + + plt <- par('plt') + xlabwidth <- max(strwidth(rowlabs[rows],units='figure',cex=cex.lab))/(plt[2]-plt[1]) + xlabwidth <- xlabwidth*maxdim/(1-xlabwidth) + ylabwidth <- max(strwidth(collabs[cols],units='figure',cex=cex.lab))/(plt[4]-plt[3]) + ylabwidth <- ylabwidth*maxdim/(1-ylabwidth) + + plot(c(-xlabwidth-0.5, maxdim + 0.5), c(0.5, maxdim + 1 + ylabwidth), + type = "n", bty = bty, axes = axes, xlab = "", ylab = "", asp = asp, + cex.lab = cex.lab, ...) + text(rep(0, length(rows)), length(rows):1, labels = rowlabs[rows], adj = 1, cex = cex.lab) + text(cols-xshift, rep(length(rows) + 1, length(cols)), labels = collabs[cols], + srt = 90, adj = 0, cex = cex.lab) + mtext(xlab,1,0) + mtext(ylab,2,0) + mat <- diag(c(1, 1)) + plotcorrInternal <- function() + { + if (i == j && !diag) return() + if (!numbers) { + mat[1, 2] <- corr[i, j] + mat[2, 1] <- mat[1, 2] + ell <- ellipse(mat, t = 0.43) + ell[, 1] <- ell[, 1] + j - xshift + ell[, 2] <- ell[, 2] + length(rows) + 1 - i - yshift + polygon(ell, col = col[i, j]) + if (outline) lines(ell) + } else { + text(j + 0.3 - xshift, length(rows) + 1 - i - yshift, round(10 * corr[i, j], 0), + adj = 1, cex = cex) + } + } + for (i in 1:dim(corr)[1]) { + for (j in 1:dim(corr)[2]) { + if (type == "full") { + plotcorrInternal() + } else if (type == "lower" && (i >= j)) { + plotcorrInternal() + } else if (type == "upper" && (i <= j)) { + plotcorrInternal() + } + } + } + invisible() +} + + + + + + + diff --git a/README b/README new file mode 100644 index 0000000..77c1030 --- /dev/null +++ b/README @@ -0,0 +1,29 @@ +This package contains ellipse drawing routines designed for pairwise +confidence regions, including distorted ellipses for nonlinear +regression regions. It also includes a routine "plotcorr" for +plotting correlation matrices using ellipses. + +The examples require the MASS, nls and ts packages. + +Release History: + +0.2.12 (Jan 2004) - Bug fix for missing values in plotcorr, doc error + +0.2.14 (Aug 2004) - Allowed separate colors for each ellipse in plotcorr + and fixed some .Rd errors. + +0.2.15 (May 2005) - Allowed plotcorr to plot just upper or lower triangle + of matrix. + +0.3.1 (June 2005) - Added NAMESPACE, package overview topic + +0.3.2 (Feb 2006) - Remove deprecated install.R + +0.3.3 (Nov 2006) - Nicer colors in plotcorr() example (from Gregor Gorjanc) + +0.3.4 (Nov 2006) - Update to strict test compliance + +0.3.5 (Sep 2007) - License clarification + +0.3.6 (Apr 2009) - Bug fix: ... was not being passed from methods to + ellipse.default(). \ No newline at end of file diff --git a/debian/changelog b/debian/changelog deleted file mode 100644 index 86febc7..0000000 --- a/debian/changelog +++ /dev/null @@ -1,5 +0,0 @@ -r-cran-ellipse (0.3-8-1) unstable; urgency=low - - * Initial release (closes: #829219) - - -- Andreas Tille <[email protected]> Fri, 01 Jul 2016 17:03:20 +0200 diff --git a/debian/compat b/debian/compat deleted file mode 100644 index ec63514..0000000 --- a/debian/compat +++ /dev/null @@ -1 +0,0 @@ -9 diff --git a/debian/control b/debian/control deleted file mode 100644 index e82e31e..0000000 --- a/debian/control +++ /dev/null @@ -1,23 +0,0 @@ -Source: r-cran-ellipse -Maintainer: Debian Med Packaging Team <[email protected]> -Uploaders: Andreas Tille <[email protected]> -Section: gnu-r -Priority: optional -Build-Depends: debhelper (>= 9), - cdbs, - r-base-dev -Standards-Version: 3.9.8 -Vcs-Browser: https://anonscm.debian.org/viewvc/debian-med/trunk/packages/R/r-cran-ellipse/trunk/ -Vcs-Svn: svn://anonscm.debian.org/debian-med/trunk/packages/R/r-cran-ellipse/trunk/ -Homepage: https://cran.r-project.org/web/packages/ellipse - -Package: r-cran-ellipse -Architecture: all -Depends: ${misc:Depends}, - ${R:Depends} -Description: GNU R functions for drawing ellipses and ellipse-like confidence regions - This package contains various routines for drawing ellipses and ellipse- - like confidence regions, implementing the plots described in Murdoch and - Chow (1996). There are also routines implementing the profile plots - described in Bates and Watts (1988), Nonlinear Regression Analysis and - its Applications. diff --git a/debian/copyright b/debian/copyright deleted file mode 100644 index 3810827..0000000 --- a/debian/copyright +++ /dev/null @@ -1,31 +0,0 @@ -Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ -Upstream-Name: ellipse -Upstream-Contact: Duncan Murdoch <[email protected]> -Source: https://cran.r-project.org/web/packages/ellipse - -Files: * -Copyright: 2010-2013 Duncan Murdoch <[email protected]>, E. D. Chow - porting to R by Jesus M. Frias Celayeta -License: GPL-2+ - -Files: debian/* -Copyright: 2016 Andreas Tille <[email protected]> -License: GPL-2+ - -License: GPL-2+ - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - . - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - . - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - . - On Debian systems, the complete text of the GNU General Public - License can be found in `/usr/share/common-licenses/GPL-2'. diff --git a/debian/rules b/debian/rules deleted file mode 100755 index 2fbba2d..0000000 --- a/debian/rules +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/make -f - -include /usr/share/R/debian/r-cran.mk diff --git a/debian/source/format b/debian/source/format deleted file mode 100644 index 163aaf8..0000000 --- a/debian/source/format +++ /dev/null @@ -1 +0,0 @@ -3.0 (quilt) diff --git a/debian/upstream/metadata b/debian/upstream/metadata deleted file mode 100644 index d8680ef..0000000 --- a/debian/upstream/metadata +++ /dev/null @@ -1,10 +0,0 @@ -Reference: - Author: D. J. Murdocha and E. D. Chowa - Title: A Graphical Display of Large Correlation Matrices - Journal: The American Statistician - Year: 1996 - Volume: 50 - Number: 2 - Pages: 178-180 - DOI: 10.1080/00031305.1996.10474371 - URL: http://www.tandfonline.com/doi/abs/10.1080/00031305.1996.10474371 diff --git a/debian/watch b/debian/watch deleted file mode 100644 index 6466b24..0000000 --- a/debian/watch +++ /dev/null @@ -1,2 +0,0 @@ -version=3 -http://cran.r-project.org/src/contrib/ellipse_([-\d.]*)\.tar\.gz diff --git a/man/ellipse-package.Rd b/man/ellipse-package.Rd new file mode 100644 index 0000000..9ee92ae --- /dev/null +++ b/man/ellipse-package.Rd @@ -0,0 +1,46 @@ +\name{ellipse-package} +\alias{ellipse-package} +\docType{package} +\title{ +Functions for drawing ellipses and ellipse-like confidence +regions +} +\description{ +This package contains various routines for drawing +ellipses and ellipse-like confidence regions, implementing the +plots described in Murdoch and Chow (1996). + +There are also routines implementing +the profile plots described in Bates and Watts (1988). +} +\details{ +There are three groups of routines in the ellipse package. The first +consists of those involved with \code{\link{plotcorr}}, which implements the plots +described in Murdoch and Chow (1996). These display correlations using +ellipses, whose shape is that of the contours of a bivariate normal +distribution with matching correlation. + +The second group implements a version of the profile plots described in +Bates and Watts (1988); see \code{\link{ellipse.profile}} and \code{\link{pairs.profile}}. + +The last group provide the basis for the others, drawing ellipses based on +various S objects, including scalar correlations, covariance matrices +\code{\link{arima}}, \code{\link{lm}}, and \code{\link{nls}} fits: see \code{\link{ellipse}}. + +} +\author{ +Duncan Murdoch <[email protected]> and E. D. Chow (porting +to R by Jesus M. Frias Celayeta <[email protected]>) + +Maintainer: Duncan Murdoch <[email protected]> +} +\references{ +Bates, D.M. and Watts, D.G. (1988). +Nonlinear Regression Analysis and its Applications. Wiley. + +Murdoch, D.J. and Chow, E.D. (1996). A graphical +display of large correlation matrices. The American +Statistician 50, 178-180. +} +\keyword{ package } +\keyword{ dplot } diff --git a/man/ellipse.Rd b/man/ellipse.Rd new file mode 100644 index 0000000..b0b26f8 --- /dev/null +++ b/man/ellipse.Rd @@ -0,0 +1,78 @@ +\name{ellipse} +\alias{ellipse} +\alias{ellipse.default} +\title{ +Make an ellipse +} +\description{ +A generic function returning an ellipse or other outline of a confidence region +for two parameters. +} +\usage{ +ellipse(x, \dots) +\method{ellipse}{default}(x, scale = c(1, 1), centre = c(0, 0), level = 0.95, + t = sqrt(qchisq(level, 2)), which = c(1, 2), npoints = 100, \dots) +} +\arguments{ +\item{x}{ +An object. In the default method the parameter \code{x} should be a correlation between -1 and 1 or a +square positive definite matrix at least 2x2 +in size. It will be treated as the correlation or covariance +of a multivariate normal distribution. +} +\item{\dots}{ +Descendant methods may require additional parameters. +} +\item{scale}{ +If \code{x} is a correlation matrix, then the standard deviations of each +parameter can be given in the scale parameter. This defaults to \code{c(1, 1)}, +so no rescaling will be done. +} +\item{centre}{ +The centre of the ellipse will be at this position. +} +\item{level}{ +The confidence level of a pairwise confidence region. The default is +0.95, for a 95\% region. This is used to control the size of the ellipse +being plotted. A vector of levels may be used. +} +\item{t}{ +The size of the ellipse may also be controlled by specifying the value +of a t-statistic on its boundary. This defaults to the appropriate +value for the confidence region. +} +\item{which}{ +This parameter selects which pair of variables from the matrix will be +plotted. The default is the first 2. +} +\item{npoints}{ +The number of points used in the ellipse. Default is 100. +} +} +\value{ +An \code{npoints} x \code{2} matrix is returned with columns named according to the +row names of the matrix \code{x} (default \code{'x'} and \code{'y'}), suitable +for plotting. +} +\details{ +The default method uses the +\code{(cos(theta + d/2), cos(theta - d/2))} parametrization of an ellipse, where +\code{cos(d)} is the correlation of the parameters. +} +\seealso{ +\code{\link{ellipse.lm}}, \code{\link{ellipse.nls}}, +\code{\link{ellipse.profile}}, \code{\link{ellipse.profile.nls}}, +\code{\link{ellipse.arima0}}, +\code{\link{plotcorr}} +} +\references{ +Murdoch, D.J. and Chow, E.D. (1996). A graphical display of large +correlation matrices. The American Statistician 50, 178-180. +} +\examples{ +# Plot an ellipse corresponding to a 95\% probability region for a +# bivariate normal distribution with mean 0, unit variances and +# correlation 0.8. +plot(ellipse(0.8), type = 'l') +} +\keyword{dplot} diff --git a/man/ellipse.arima0.Rd b/man/ellipse.arima0.Rd new file mode 100644 index 0000000..98ddbab --- /dev/null +++ b/man/ellipse.arima0.Rd @@ -0,0 +1,51 @@ +\name{ellipse.arima0} +\alias{ellipse.arima0} +\title{ +Outline an approximate pairwise confidence region +} +\description{ +This function produces the ellipsoidal outline of an approximate +pairwise confidence region for an ARIMA model fit. +} +\usage{ +\method{ellipse}{arima0}(x, which = c(1, 2), level = 0.95, t = sqrt(qchisq(level, 2)), \dots) +} +\arguments{ +\item{x}{ +The first argument should be an \code{arima0} object, usually resulting from a call +to \code{arima0()}. +} +\item{which}{ +Which selects the pair of parameters to be plotted. The default is the +first two. +} +\item{level}{ +The confidence level of the region. Default 95\%. +} +\item{t}{ +The t statistic on the boundary of the ellipse. +} +\item{\dots}{ +Other \code{ellipse.default} parameters may also be used. +}} +\value{ +A matrix with columns \code{x} and \code{y} to outline the confidence region. +} +\details{ +The \code{summary} function is used to obtain the approximate covariance matrix of the +fitted parameters. +} +\seealso{ +\code{\link{ellipse}} +} +\examples{ +data(USAccDeaths) +fit <- arima0(USAccDeaths, order = c(0, 1, 1), seasonal = list(order = c(0, 1, 1))) +# Plot the approximate 95\% confidence region for the first two parameters +# of the model +plot(ellipse(fit), type = 'l') +points(fit$coef[1], fit$coef[2]) +} +\keyword{dplot} +\keyword{ts} + diff --git a/man/ellipse.glm.Rd b/man/ellipse.glm.Rd new file mode 100644 index 0000000..b5420f5 --- /dev/null +++ b/man/ellipse.glm.Rd @@ -0,0 +1,67 @@ +\name{ellipse.glm} +\alias{ellipse.glm} +\title{ +Outline an approximate pairwise confidence region +} +\description{ +This function produces the ellipsoidal outline of an approximate +pairwise confidence region for a generalized linear model fit. +} +\usage{ +\method{ellipse}{glm}(x, which = c(1, 2), level = 0.95, t, npoints = 100, + dispersion, \dots) +} +\arguments{ +\item{x}{ +The first argument should be a \code{glm} object, usually resulting from a call +to \code{glm()}. +} +\item{which}{ +Which selects the pair of parameters to be plotted. The default is the +first two. +} +\item{level}{ +The confidence level of the region. Default 95\%. +} +\item{t}{ +The t statistic on the boundary of the ellipse. For Binomial or Poisson +families, \code{sqrt(qchisq(level, 2))} is used; for other distributions, +\code{sqrt(2*qf(level, 2, df))} where \code{df} is the residual degrees of freedom. +} +\item{npoints}{ +How many points to return in the ellipse. +} +\item{dispersion}{ +The value of dispersion to use. If specified, it is treated as fixed, +and the chi-square limits for \code{t} are used. If missing, it is +taken from \code{summary(x)}. +} +\item{\dots}{ +Other \code{ellipse.default} parameters may also be used. +}} +\value{ +A matrix with columns named according to which to outline the confidence region. +} +\details{ +The summary function is used to obtain the approximate covariance matrix of the +fitted parameters, the dispersion estimate, and the degrees of freedom. +} +\seealso{ +\code{\link{ellipse.default}} +} +\examples{ +## Dobson (1990) Page 93: Randomized Controlled Trial : + + counts <- c(18,17,15,20,10,20,25,13,12) + outcome <- gl(3,1,9) + treatment <- gl(3,3) + glm.D93 <- glm(counts ~ outcome + treatment, family=poisson()) + +# Plot an approximate 95 \% confidence region for the two Outcome parameters + + plot(ellipse(glm.D93, which = c(2,3)), type = 'l') + points(glm.D93$coefficients[2], glm.D93$coefficients[3]) +} +\keyword{dplot} +\keyword{regression} + diff --git a/man/ellipse.lm.Rd b/man/ellipse.lm.Rd new file mode 100644 index 0000000..7a97563 --- /dev/null +++ b/man/ellipse.lm.Rd @@ -0,0 +1,51 @@ +\name{ellipse.lm} +\alias{ellipse.lm} +\title{ +Outline a pairwise confidence region for a linear model fit. +} +\description{ +This function produces the ellipsoidal outline of a pairwise confidence +region for a linear model fit. +} +\usage{ +\method{ellipse}{lm}(x, which = c(1, 2), level = 0.95, + t = sqrt(2 * qf(level, 2, x$df.residual)), \dots) +} +\arguments{ +\item{x}{ +The first argument should be an \code{lm} object, usually resulting from a call +to \code{lm()}. +} +\item{which}{ +Which selects the pair of parameters to be plotted. The default is the +first two. +} +\item{level}{ +The confidence level of the region. Default 95\%. +} +\item{t}{ +The t statistic on the boundary of the ellipse. +} +\item{\dots}{ +Other \code{ellipse.default} parameters may also be used. +}} +\value{ +A matrix with columns \code{x} and \code{y} to outline the confidence region. +} +\details{ +The summary function is used to obtain the covariance matrix of the +fitted parameters. +} +\seealso{ +\code{\link{ellipse.default}} +} +\examples{ +# Plot the estimate and joint 90\% confidence region for the displacement and cylinder +# count linear coefficients in the mtcars dataset +data(mtcars) +fit <- lm(mpg ~ disp + cyl , mtcars) +plot(ellipse(fit, which = c('disp', 'cyl'), level = 0.90), type = 'l') +points(fit$coefficients['disp'], fit$coefficients['cyl']) +} +\keyword{dplot} +\keyword{regression} diff --git a/man/ellipse.nls.Rd b/man/ellipse.nls.Rd new file mode 100644 index 0000000..a706005 --- /dev/null +++ b/man/ellipse.nls.Rd @@ -0,0 +1,54 @@ +\name{ellipse.nls} +\alias{ellipse.nls} +\title{ +Outline an approximate pairwise confidence region +} +\description{ +This function produces the ellipsoidal outline of an approximate +pairwise confidence region for a nonlinear model fit. +} +\usage{ +\method{ellipse}{nls}(x, which = c(1, 2), level = 0.95, + t = sqrt(2 * qf(level, 2, s$df[2])), \dots) +} +\arguments{ +\item{x}{ +The first argument should be an \code{nls} object, usually resulting from a call +to \code{nls()}. +} +\item{which}{ +Which selects the pair of parameters to be plotted. The default is the +first two. +} +\item{level}{ +The confidence level of the region. Default 95\%. +} +\item{t}{ +The t statistic on the boundary of the ellipse. +} +\item{\dots}{ +Other \code{ellipse.default} parameters may also be used. +}} +\value{ +A matrix with columns \code{x} and \code{y} to outline the confidence region. +} +\details{ +The summary function is used to obtain the approximate covariance matrix of the +fitted parameters. +} +\seealso{ +\code{\link{ellipse.default}}, \code{\link{ellipse.profile}} +} +\examples{ +# Plot an approximate 95\% confidence region for the weight and displacement +# parameters in the Michaelis Menten model +data(Puromycin) +fit <- nls(rate ~ Vm*conc/(K + conc), data = Puromycin, subset = state=="treated", + start = list(K = 0.05, Vm = 200)) +plot(ellipse(fit,which=c('Vm','K')), type = 'l') +params <- fit$m$getPars() +points(params['Vm'],params['K']) +} +\keyword{dplot} +\keyword{nonlinear} + diff --git a/man/ellipse.profile.Rd b/man/ellipse.profile.Rd new file mode 100644 index 0000000..fa95eec --- /dev/null +++ b/man/ellipse.profile.Rd @@ -0,0 +1,70 @@ +\name{ellipse.profile} +\alias{ellipse.profile} +\title{ +Pairwise profile sketch +} +\description{ +This routine approximates a contour of a function based on the profile +of that function. +} +\usage{ +\method{ellipse}{profile}(x, which = c(1, 2), level = 0.95, t = sqrt(qchisq(level, 2)), + npoints = 100, \dots) +} +\arguments{ +\item{x}{ +An object of class \code{\link{profile}}, e.g. from +\link[MASS:confint]{profile.glm} in the MASS package. +} +\item{which}{ +Which pair of parameters to use. +} +\item{level}{ +The \code{ellipse.profile} function defaults assume that the profiled +function is -2 times the log likelihood of a regular model. +With this assumption the \code{level} argument +specifies the confidence level for an asymptotic confidence region. +} +\item{t}{ +The square root of the value to be contoured. +} +\item{npoints}{ +How many points to use in the ellipse. +} +\item{\dots}{ +Extra arguments are not used. +} +} +\value{ +An \code{npoints} x \code{2} matrix with columns having the chosen parameter names, +which approximates a contour of the function that was profiled. +} +\details{ +This function uses the 4 point approximation to the contour as described +in Appendix 6 of Bates and Watts (1988). It produces the exact contour for +quadratic surfaces, and good approximations for mild deviations from +quadratic. If the surface is multimodal, the algorithm is likely to +produce nonsense. +} +\references{ +Bates and Watts (1988) Nonlinear Regression Analysis \& its Applications +} +\seealso{ +\code{\link{profile}}, \code{\link{ellipse.nls}} +} +\examples{ +# Plot an approximate 95\% confidence region for the Puromycin +# parameters Vm and K, and overlay the ellipsoidal region + +data(Puromycin) +Purboth <- nls(formula = rate ~ ((Vm + delV * (state == "treated")) + * conc)/(K + conc), data = Puromycin, + start = list(Vm = 160, delV = 40, K = 0.05)) +Pur.prof <- profile(Purboth) +plot(ellipse(Pur.prof, which = c('Vm', 'K')), type = 'l') +lines(ellipse(Purboth, which = c('Vm', 'K')), lty = 2) +params <- Purboth$m$getPars() +points(params['Vm'],params['K']) +} +\keyword{dplot} +\keyword{models} diff --git a/man/ellipse.profile.glm.Rd b/man/ellipse.profile.glm.Rd new file mode 100644 index 0000000..b51659f --- /dev/null +++ b/man/ellipse.profile.glm.Rd @@ -0,0 +1,82 @@ +\name{ellipse.profile.glm} +\alias{ellipse.profile.glm} +\title{ +Pairwise profile sketch for GLM profiles +} +\description{ +This routine approximates a pairwise confidence region for a glm +model. +} +\usage{ +\method{ellipse}{profile.glm}(x, which = c(1, 2), level = 0.95, t, + npoints = 100, dispersion, \dots) +} +\arguments{ +\item{x}{ +An object of class \code{\link[MASS]{profile.glm}}. +} +\item{which}{ +Which pair of parameters to use. +} +\item{level}{ +The \code{level} argument +specifies the confidence level for an asymptotic confidence region. +} +\item{t}{ +The square root of the value to be contoured. By default, this is \code{qchisq(level, 2)} +for models with fixed dispersion (i.e. binomial and Poisson), and \code{2 * qf(level, 2, df)} for other models, +where \code{df} is the residual degrees of freedom. +} +\item{npoints}{ +How many points to use in the ellipse. +} +\item{dispersion}{ +If specified, fixed dispersion is assumed, otherwise the dispersion is taken from the model. +} +\item{\dots}{ +Extra parameters which are not used (for compatibility with the generic). +} +} +\value{ +An \code{npoints} x \code{2} matrix with columns having the chosen parameter names, +which approximates a contour of the function that was profiled. +} +\details{ +This function uses the 4 point approximation to the contour as described +in Appendix 6 of Bates and Watts (1988). It produces the exact contour for +quadratic surfaces, and good approximations for mild deviations from +quadratic. If the surface is multimodal, the algorithm is likely to +produce nonsense. +} +\references{ +Bates and Watts (1988) Nonlinear Regression Analysis \& its Applications +} +\seealso{ +\code{\link{profile}}, \code{\link{glm}}, \code{\link{ellipse.glm}} +} +\examples{ +## MASS has a pairs.profile function that conflicts with ours, so +## do a little trickery here + noMASS <- is.na(match('package:MASS', search())) + if (noMASS) require(MASS) + +## Dobson (1990) Page 93: Randomized Controlled Trial : + + counts <- c(18,17,15,20,10,20,25,13,12) + outcome <- gl(3,1,9) + treatment <- gl(3,3) + glm.D93 <- glm(counts ~ outcome + treatment, family=poisson()) + +## Plot an approximate 95\% confidence region for the two outcome variables + prof.D93 <- profile(glm.D93) + plot(ellipse(prof.D93, which = 2:3), type = 'l') + lines(ellipse(glm.D93, which = 2:3), lty = 2) + params <- glm.D93$coefficients + points(params[2],params[3]) + +## Clean up our trickery + if (noMASS) detach('package:MASS') + +} +\keyword{dplot} +\keyword{models} diff --git a/man/ellipse.profile.nls.Rd b/man/ellipse.profile.nls.Rd new file mode 100644 index 0000000..132c6b0 --- /dev/null +++ b/man/ellipse.profile.nls.Rd @@ -0,0 +1,66 @@ +\name{ellipse.profile.nls} +\alias{ellipse.profile.nls} +\title{ +Pairwise profile sketch +} +\description{ +This routine approximates a pairwise confidence region for a nonlinear regression +model. +} +\usage{ +\method{ellipse}{profile.nls}(x, which = c(1, 2), level = 0.95, t = sqrt(2 * qf(level, 2, attr(x, "summary")$df[2])), + npoints = 100, \dots) +} +\arguments{ +\item{x}{ +An object of class \code{\link{profile.nls}}. +} +\item{which}{ +Which pair of parameters to use. +} +\item{level}{ +The \code{level} argument +specifies the confidence level for an asymptotic confidence region. +} +\item{t}{ +The square root of the value to be contoured. +} +\item{npoints}{ +How many points to use in the ellipse. +} +\item{\dots}{ +Extra parameters which are not used (for compatibility with the generic). +} +} +\value{ +An \code{npoints} x \code{2} matrix with columns having the chosen parameter names, +which approximates a contour of the function that was profiled. +} +\details{ +This function uses the 4 point approximation to the contour as described +in Appendix 6 of Bates and Watts (1988). It produces the exact contour for +quadratic surfaces, and good approximations for mild deviations from +quadratic. If the surface is multimodal, the algorithm is likely to +produce nonsense. +} +\references{ +Bates and Watts (1988) Nonlinear Regression Analysis \& its Applications +} +\seealso{ +\code{\link{profile}}, \code{\link{ellipse.nls}} +} +\examples{ +# Plot an approximate 95\% confidence region for the Puromycin +# parameters Vm and K, and overlay the ellipsoidal region +data(Puromycin) +Purboth <- nls(formula = rate ~ ((Vm + delV * (state == "treated")) + * conc)/(K + conc), data = Puromycin, + start = list(Vm = 160, delV = 40, K = 0.05)) +Pur.prof <- profile(Purboth) +plot(ellipse(Pur.prof, which = c('Vm', 'K')), type = 'l') +lines(ellipse(Purboth, which = c('Vm', 'K')), lty = 2) +params <- Purboth$m$getPars() +points(params['Vm'],params['K']) +} +\keyword{dplot} +\keyword{models} diff --git a/man/pairs.profile.Rd b/man/pairs.profile.Rd new file mode 100644 index 0000000..77ecb00 --- /dev/null +++ b/man/pairs.profile.Rd @@ -0,0 +1,74 @@ +\name{pairs.profile} +\alias{pairs.profile} +\title{ +Profile pairs +} +\description{ +This function produces pairwise plots of profile traces, profile +sketches, and ellipse approximations to confidence intervals. +} +\usage{ +\method{pairs}{profile}(x, labels = c(names(x), "Profile tau"), panel = lines, invert = TRUE, + plot.tau = TRUE, plot.trace = TRUE, plot.sketch = TRUE, + plot.ellipse = FALSE, level = 0.95, \dots) +} +\arguments{ +\item{x}{ +An object of class \code{profile}, generally the result of the \code{profile()} +function. +} +\item{labels}{ +The labels to use for each variable. These default to the variable +names. +} +\item{panel}{ +The function to use to draw the sketch in each panel. +} +\item{invert}{ +Whether to swap the axes so things look better. +} +\item{plot.tau}{ +Whether to do the profile tau (profile t) plots. +} +\item{plot.trace}{ +Whether to do the profile trace plots. +} +\item{plot.sketch}{ +Whether to do the profile sketch plots. +} +\item{plot.ellipse}{ +Whether to do the ellipse approximations. +} +\item{level}{ +The nominal confidence level for the profile sketches and ellipses. +} +\item{\dots}{ +Other plotting parameters. +}} +\section{Side Effects}{ +Produces a plot on the current device for each pair of variables in the +profile object. +} +\details{ +This function implements the plots used in Bates and Watts (1988) for +nonlinear regression diagnostics. +} +\references{ +Bates and Watts (1988), Nonlinear Regression Analysis \& its +Applications. +} +\seealso{ +\code{\link{profile}}, \code{\link{ellipse.profile}}, \code{\link{ellipse.nls}} +} +\examples{ + # Plot everything for the Puromycin data + data(Puromycin) + Purboth <- nls(formula = rate ~ ((Vm + delV * (state == "treated")) + * conc)/(K + conc), data = Puromycin, + start = list(Vm = 160, delV = 40, K = 0.05)) + Pur.prof <- profile(Purboth) + pairs(Pur.prof, plot.ellipse = TRUE) +} +\keyword{dplot} +\keyword{regression} +\keyword{nonlinear} diff --git a/man/plotcorr.Rd b/man/plotcorr.Rd new file mode 100644 index 0000000..147a728 --- /dev/null +++ b/man/plotcorr.Rd @@ -0,0 +1,81 @@ +\name{plotcorr} +\alias{plotcorr} +\title{ +Plot correlation matrix ellipses +} +\description{ +This function plots a correlation matrix using ellipse-shaped glyphs for +each entry. The ellipse represents a level curve of the density of a +bivariate normal with the matching correlation. +} +\usage{ +plotcorr(corr, outline = TRUE, col = 'grey', numbers = FALSE, type = c("full","lower","upper"), + diag = (type == "full"), bty = "n", axes = FALSE, xlab = "", ylab = "", asp = 1, + cex.lab = par("cex.lab"), cex = 0.75*par("cex"), mar = 0.1 + c(2,2,4,2), ...) +} +\arguments{ +\item{corr}{ +A matrix containing entries between \code{-1} and \code{1} to be plotted as +correlations. +} +\item{outline}{ +Whether the ellipses should be outlined in the default colour. +} +\item{col}{ +Which colour(s) to use to fill the ellipses. +} +\item{numbers}{ +Whether to plot numerical correlations in place of ellipses. If +numbers is \code{TRUE}, then the correlations will be rounded to a single decimal +place and placed on the plot. +} +\item{type}{Character. Plot \code{"full"} matrix or just \code{"upper"} or + \code{"lower"} triangular part of it.} +\item{diag}{Logical. Plot diagonal elements or not. } +\item{bty, axes, xlab, ylab, asp, mar, cex.lab, ...}{Graphical parameters +which will be passed to \code{\link{plot}} when plotting.} +\item{cex}{Graphical parameter +which will be passed to \code{\link{text}} when plotting.} +} +\details{ +The ellipses being plotted will be tangent to a unit character square, +with the shape chosen to match the required correlation. If \code{numbers = FALSE}, +the \code{col} vector will be recycled to colour each of the ellipses; if +\code{TRUE}, it will be ignored. +} +\references{ +Murdoch, D.J. and Chow, E.D. (1996). A graphical display of large +correlation matrices. The American Statistician 50, 178-180. +} +\seealso{ +\code{\link{ellipse}} +} +\author{Duncan Murdoch; Gregor Gorjanc suggested the \code{type} and \code{diag} +options.} +\examples{ +save.par <- par(ask = interactive()) + +# Plot the correlation matrix for the mtcars data full model fit +data(mtcars) +fit <- lm(mpg ~ ., mtcars) +plotcorr(summary(fit, correlation = TRUE)$correlation) + +# Plot a second figure with numbers in place of the +# ellipses +plotcorr(summary(fit, correlation = TRUE)$correlation, numbers = TRUE) + +# Colour the ellipses to emphasize the differences. The color range +# is based on RColorBrewer's Reds and Blues (suggested by Gregor Gorjanc) + +corr.mtcars <- cor(mtcars) +ord <- order(corr.mtcars[1,]) +xc <- corr.mtcars[ord, ord] +colors <- c("#A50F15","#DE2D26","#FB6A4A","#FCAE91","#FEE5D9","white", + "#EFF3FF","#BDD7E7","#6BAED6","#3182BD","#08519C") +plotcorr(xc, col=colors[5*xc + 6]) + +plotcorr(xc, col=colors[5*xc + 6], type = "upper") +plotcorr(xc, col=colors[5*xc + 6], type = "lower", diag = TRUE) +par(save.par) +} +\keyword{hplot} -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-med/r-cran-ellipse.git _______________________________________________ debian-med-commit mailing list [email protected] http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/debian-med-commit
