[r-cran-zelig] 03/102: Import Upstream version 2.0-13

Andreas Tille tille at debian.org
Sun Jan 8 16:58:08 UTC 2017


This is an automated email from the git hooks/post-receive script.

tille pushed a commit to branch master
in repository r-cran-zelig.

commit a689949d0718c18e35756e8173d1cdf9242d25f0
Author: Andreas Tille <tille at debian.org>
Date:   Sun Jan 8 09:38:57 2017 +0100

    Import Upstream version 2.0-13
---
 DESCRIPTION         |  6 ++---
 R/dims.R            |  6 +++++
 R/plot.zelig.beta.R | 12 +++++++++
 R/print.relogit.R   | 44 ++++++++++++++++----------------
 R/rocplot.R         | 48 ++++++++++++++++++++---------------
 README              | 10 ++++++++
 man/dims.Rd         | 41 ++++++++++++++++++++++++++++++
 man/rocplot.Rd      | 72 +++++++++++++++++++++++++++++++----------------------
 8 files changed, 165 insertions(+), 74 deletions(-)

diff --git a/DESCRIPTION b/DESCRIPTION
index 4fb69fe..a6b3f6d 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -1,6 +1,6 @@
 Package: Zelig
-Version: 2.0-11
-Date: 2005-01-14
+Version: 2.0-13
+Date: 2005-03-11
 Title: Zelig: Everyone's Statistical Software
 Author: Kosuke Imai <kimai at Princeton.Edu>,
         Gary King <king at harvard.edu>,
@@ -22,4 +22,4 @@ Description: Zelig is an easy-to-use program that can estimate, and
         translates them into quantities of direct interest.
 License: GPL version 2 or newer
 URL: http://gking.harvard.edu/zelig
-Packaged: Fri Jan 14 15:04:05 2005; king
+Packaged: Fri Mar 11 11:04:06 2005; king
diff --git a/R/dims.R b/R/dims.R
new file mode 100644
index 0000000..6cbae0a
--- /dev/null
+++ b/R/dims.R
@@ -0,0 +1,6 @@
+dims <- function(x) {
+  if (is.vector(x)) 
+    return(length(x))
+  else
+    return(dim(x))
+}
diff --git a/R/plot.zelig.beta.R b/R/plot.zelig.beta.R
new file mode 100644
index 0000000..a392bd4
--- /dev/null
+++ b/R/plot.zelig.beta.R
@@ -0,0 +1,12 @@
+plot.zelig.beta <- function(x, xlab = "", user.par = FALSE, alt.col = "red", ...){
+  k <- length(x$qi)
+  op <- par(no.readonly = TRUE)
+  if (!user.par) 
+    par(mar = c(4,4,2,1), tcl = -0.25, mgp = c(2, 0.6, 0))
+  par(mfrow = c(k, 1))
+  for (i in 1:k) {
+    qi <- as.vector(x$qi[[i]])
+    plot(density(qi), main = x$qi.name[[i]], xlab = xlab, ...)
+  }
+  par(op)
+}
diff --git a/R/print.relogit.R b/R/print.relogit.R
index d6b7944..433e233 100644
--- a/R/print.relogit.R
+++ b/R/print.relogit.R
@@ -1,26 +1,28 @@
-print.relogit <-function (x, digits = max(3, getOption("digits") - 3),
+print.relogit <- function(x, digits = max(3, getOption("digits") - 3),
                           ...) {
   if (is.null(x$call$bias.correct))
     x$call$bias.correct <- TRUE
   cat("\nCall: ", deparse(x$call), "\n\n")
-    cat("Coefficients")
-    if (is.character(co <- x$contrasts)) 
-      cat("  [contrasts: ", apply(cbind(names(co), co), 
-                                  1, paste, collapse = "="), "]")
-    cat(":\n")
-    print.default(format(x$coefficients, digits = digits), 
-                  print.gap = 2, quote = FALSE)
-    if (!is.null(x$call$tau)) {
-      cat("\nIntercepts with prior correction for: \n")
-      print.default(x$correct, digits = digits,
-                    print.gap = 1, quote = FALSE)
-    }
-    cat("\nDegrees of Freedom:", x$df.null, "Total (i.e. Null); ", 
-        x$df.residual, "Residual\n")
-    cat("Null Deviance:\t   ", format(signif(x$null.deviance, 
-        digits)), "\nResidual Deviance:", format(signif(x$deviance, 
-        digits)), "\tAIC:", format(signif(x$aic, digits)), "\n")
-    if (x$call$bias.correct)
-      cat("Rare events bias correction performed.") 
-    invisible(x)
+  cat("Coefficients")
+  if (is.character(co <- x$contrasts)) 
+    cat("  [contrasts: ", apply(cbind(names(co), co), 
+                                1, paste, collapse = "="), "]")
+  cat(":\n")
+  print.default(format(x$coefficients, digits = digits), 
+                print.gap = 2, quote = FALSE)
+  if (!is.null(x$call$tau)) {
+    cat("\nIntercepts with prior correction for: \n")
+    print.default(x$correct, digits = digits,
+                  print.gap = 1, quote = FALSE)
+  }
+  cat("\nDegrees of Freedom:", x$df.null, "Total (i.e. Null); ", 
+      x$df.residual, "Residual\n")
+  cat("Null Deviance:\t   ", format(signif(x$null.deviance, 
+                                           digits)),
+      "\nResidual Deviance:", format(signif(x$deviance, 
+                                            digits)),
+      "\tAIC:", format(signif(x$aic, digits)), "\n")
+  if (x$call$bias.correct)
+    cat("Rare events bias correction performed.\n") 
+  invisible(x)
 }
diff --git a/R/rocplot.R b/R/rocplot.R
index 57b3418..14e0a45 100644
--- a/R/rocplot.R
+++ b/R/rocplot.R
@@ -3,22 +3,36 @@ rocplot <- function(y1, y2, fitted1, fitted2,
                     lty2="dashed", lwd1=par("lwd"), lwd2=par("lwd"),
                     col1=par("col"), col2=par("col"), main="ROC Curve",
                     xlab = "Proportion of 1's Correctly Predicted",
-                    ylab="Proportion of 0's Correctly Predicted", ...) {
-  op <- par(no.readonly = TRUE)
-  par(mar = c(4,4,2,1), tcl = -0.25, mgp = c(2, 0.6, 0))
-  ones <- zeros <- matrix(NA, nrow = length(cutoff), ncol = 2)
+                    ylab="Proportion of 0's Correctly Predicted", plot = TRUE, ...) {
+  roc1 <- roc2 <- matrix(NA, nrow = length(cutoff), ncol = 2)
+  colnames(roc1) <- colnames(roc2) <- c("ones", "zeros")
   for (i in 1:length(cutoff)) {
-    ones[i,1] <- mean(fitted1[y1==1] >= cutoff[i]) 
-    ones[i,2] <- mean(fitted2[y2==1] >= cutoff[i])
-    zeros[i,1] <- mean(fitted1[y1==0] < cutoff[i])
-    zeros[i,2] <- mean(fitted2[y2==0] < cutoff[i])
+    roc1[i,1] <- mean(fitted1[y1==1] >= cutoff[i]) 
+    roc2[i,1] <- mean(fitted2[y2==1] >= cutoff[i])
+    roc1[i,2] <- mean(fitted1[y1==0] < cutoff[i])
+    roc2[i,2] <- mean(fitted2[y2==0] < cutoff[i])
+  }
+  if (plot) {
+    op <- par(no.readonly = TRUE)
+    par(mar = c(4,4,2,1), tcl = -0.25, mgp = c(2, 0.6, 0))
+    plot(0:1, 0:1, type = "n", xaxs = "i", yaxs = "i",
+         main=main, xlab=xlab, ylab=ylab, ...)
+    lines(roc1, lty = lty1, lwd = lwd1, col=col1)
+    lines(roc2, lty = lty2, lwd = lwd2, col=col2)
+    abline(1, -1, lty = "dotted")
+    par(op)
+  }
+  else {
+    area1 <- area2 <- array()
+    for (i in 2:length(cutoff)) {
+      area1[i-1] <- (roc1[i,2] - roc1[(i-1),2]) * roc1[i,1] 
+      area2[i-1] <- (roc2[i,2] - roc2[(i-1),2]) * roc2[i,1] 
+    }
+    return(list(roc1 = roc1, 
+                roc2 = roc2,
+                area1 = sum(na.omit(area1)),
+                area2 = sum(na.omit(area2))))
   }
-  plot(0:1, 0:1, type = "n", xaxs = "i", yaxs = "i",
-       main=main, xlab=xlab, ylab=ylab, ...)
-  lines(cbind(ones[,1], zeros[,1]), lty = lty1, lwd = lwd1, col=col1)
-  lines(cbind(ones[,2], zeros[,2]), lty = lty2, lwd = lwd2, col=col2)
-  abline(1, -1, lty = "dotted")
-  par(op)
 }
 
 
@@ -30,9 +44,3 @@ rocplot <- function(y1, y2, fitted1, fitted2,
 
 
 
-
-
-
-
-
-
diff --git a/README b/README
index c7a3e98..9fe82d9 100644
--- a/README
+++ b/README
@@ -1,3 +1,13 @@
+2.0-13 (March 11, 2005): Stable release for R 1.9.1-2.0.1.  Fixed bugs in 
+  NAMESPACE and rocplot.Rd. 
+
+2.0-12 (February 20, 2005): Stable release for R 1.9.1-2.0.1.  Added plot 
+  = TRUE option to rocplot().  
+
+2.0-11 (January 14, 2005): Stable release for R 1.9.1-2.0.1.  Changed 
+  class name for subsettted models from "multiple" to "strata", and 
+  modified affected functions.
+
 2.0-10 (January 4, 2005): Stable release for R 1.9.1 and R 2.0.0.  Fixed 
   bug in simulation procedure for ordinal logit.  (Reported by Ian Yohai.)
 
diff --git a/man/dims.Rd b/man/dims.Rd
new file mode 100644
index 0000000..5a68f2e
--- /dev/null
+++ b/man/dims.Rd
@@ -0,0 +1,41 @@
+\name{dims}
+
+\alias{dims}
+
+\title{Return Dimensions of Vectors, Arrays, and Data Frames}
+
+\description{
+  Retrieve or set the dimensions of a vector, array, or data frame.  
+}
+
+\usage{
+dims(x)
+dims(x) <- value
+}
+
+\arguments{
+  \item{x}{An R object.  For example, a vector, matrix, array, or data 
+frame.}
+  \item{value}{For the default method, either \code{NULL} or a numeric 
+vector coerced to integer (by truncation).}
+}
+
+\value{
+  The function \code{dims} performs exactly the same as \code{dim}, and 
+additionally returns the \code{length} of vectors (treating them as 
+one-dimensional arrays).}
+
+\seealso{\code{dim}, \code{length}}
+
+\author{ Olivia Lau <\email{olau at fas.harvard.edu}>
+}
+
+\examples{
+a <- 1:12
+dims(a)
+
+a <- matrix(1, nrow = 4, ncol = 9)
+dims(a)
+}
+
+\keyword{file}
diff --git a/man/rocplot.Rd b/man/rocplot.Rd
index 0f03e49..ddafe80 100644
--- a/man/rocplot.Rd
+++ b/man/rocplot.Rd
@@ -7,57 +7,69 @@
 
 \title{Receiver Operator Characteristic Plots}
 
-\description{
-The \code{rocplot} command generates a receiver operator
-characteristic plot to compare the in-sample (default) or
-out-of-sample fit for two logit or probit regressions.  
-}
+\description{ The \code{rocplot} command generates a receiver operator
+characteristic plot to compare the in-sample (default) or out-of-sample
+fit for two logit or probit regressions.  }
 
 \usage{
 rocplot(y1, y2, fitted1, fitted2, cutoff = seq(from=0, to=1, length=100), 
         lty1 = "solid", lty2 = "dashed", lwd1 = par("lwd"), lwd2 = par("lwd"),
-        col1 = par("col"), col2 = par("col"), main, xlab, ylab, ...)
+        col1 = par("col"), col2 = par("col"), main, xlab, ylab,
+        plot = TRUE, ...)
 }
 
 \arguments{
-\item{y1}{Response variable for the first model.  }
-\item{y2}{Response variable for the second model. }
+\item{y1}{Response variable for the first model.}
+\item{y2}{Response variable for the second model.}
 \item{fitted1}{Fitted values for the first model.  These values
-  may represent either the in-sample or out-of-sample fitted values. }
-\item{fitted2}{Fitted values for the second model. } 
+  may represent either the in-sample or out-of-sample fitted values.}
+\item{fitted2}{Fitted values for the second model.} 
 \item{cutoff}{A vector of cut-off values between 0 and 1, at
   which to evaluate the proportion of 0s and 1s correctly predicted by
   the first and second model.  By default, this is 100 increments
-  between 0 and 1, inclusive.  }
-\item{lty1, lty2}{The line type for the first model ({\tt
-    lty1}) and the second model (\code{lty2}), defaulting to solid and
-  dashed, respectively.    }
-\item{lwd1, lwd2}{The width of the line for the first
-  model (\code{lwd1}) and the second model (\code{lwd2}), defaulting to
-  1 for both.  }
+  between 0 and 1, inclusive.}
+\item{lty1, lty2}{The line type for the first model (\code{lty1}) and
+  the second model (\code{lty2}), defaulting to solid and dashed,
+  respectively.}
+\item{lwd1, lwd2}{The width of the line for the first model
+  (\code{lwd1}) and the second model (\code{lwd2}), defaulting to 1 for both.}
 \item{col1, col2}{The colors of the line for the first
   model (\code{col1}) and the second model (\code{col2}), defaulting to
-  black for both. }
-\item{main}{a title for the plot.  Defaults to "Roc Curve".}
-\item{xlab}{a label for the x-axis.  Defaults to "Proportion of 1's 
-Correctly Predicted".}
-\item{ylab}{a label for the y-axis.  Defaults to Proportion of 0's 
-Correctly Predicted".}
+  black for both.}
+\item{main}{a title for the plot.  Defaults to \code{ROC Curve}.}
+\item{xlab}{a label for the x-axis.  Defaults to \code{Proportion of 1's 
+    Correctly Predicted}.}
+\item{ylab}{a label for the y-axis.  Defaults to \code{Proportion of 0's 
+    Correctly Predicted}.}
+\item{plot}{defaults to \code{TRUE}, which generates a plot to the
+  selected device.  If \code{FALSE}, returns a list of
+items (see below).} 
 \item{\dots}{Additional parameters passed to plot, including
   \code{xlab}, \code{ylab}, and \code{main}.  }
 }
 
-\value{
-For two logit or probit models, \code{rocplot} returns an on-screen
-window with the desired ROC plot.  
+\value{ If \code{plot = TRUE}, \code{rocplot} generates an ROC plot for
+two logit or probit models.  If \code{plot = FALSE}, \code{rocplot}
+returns a list with the following elements: {
+  \item{roc1}{a matrix containing a vector of x-coordinates and
+    y-coordinates corresponding to the number of ones and zeros correctly
+    predicted for the first model.}
+  \item{roc2}{a matrix containing a vector of x-coordinates and
+    y-coordinates corresponding to the number of ones and zeros correctly
+    predicted for the second model.}
+  \item{area1}{the area under the first ROC curve, calculated using
+    Reimann sums.}
+  \item{area2}{the area under the second ROC curve, calculated using
+    Reimann sums.}
+} 
 }
 
-\example{
+\examples{
 data(turnout)
 z.out1 <- zelig(vote ~ race + educate + age, model = "logit", 
-                data = turnout)
+  data = turnout)
 z.out2 <- zelig(vote ~ race + educate, model = "logit", 
-                data = turnout)
+  data = turnout)
 rocplot(z.out1$y, z.out2$y, fitted(z.out1), fitted(z.out2))
 }
 
@@ -69,4 +81,4 @@ rocplot(z.out1$y, z.out2$y, fitted(z.out1), fitted(z.out2))
   <\email{king at harvard.edu}>; Olivia Lau <\email{olau at fas.harvard.edu}>
 }
 
-\keyword{aplot}
+\keyword{file}

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/r-cran-zelig.git



More information about the debian-science-commits mailing list