[r-cran-mnp] 06/51: Import Upstream version 2.2-1

Andreas Tille tille at debian.org
Fri Sep 8 14:14:44 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-mnp.

commit 03139736abe351bbb71bdb71a159f3f6d515e075
Author: Andreas Tille <tille at debian.org>
Date:   Fri Sep 8 15:54:42 2017 +0200

    Import Upstream version 2.2-1
---
 DESCRIPTION     |  6 +++---
 R/mnp.R         | 22 ++++++++++++++++++++--
 R/predict.mnp.R | 18 +++++++++++++-----
 R/ymatrix.mnp.R |  2 +-
 man/mnp.Rd      | 21 ++++++++++++++++-----
 5 files changed, 53 insertions(+), 16 deletions(-)

diff --git a/DESCRIPTION b/DESCRIPTION
index ca79af7..f717112 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -1,6 +1,6 @@
 Package: MNP
-Version: 2.1-2
-Date: 2005-03-22
+Version: 2.2-1
+Date: 2005-05-01
 Title: R Package for the Fitting the Multinomial Probit Model
 Author: Kosuke Imai <kimai at princeton.edu>, 
         David A. van Dyk <dvd at uci.edu>. 
@@ -22,4 +22,4 @@ Description: MNP is a publicly available R package that fits the Bayesian
   of Econometrics, Vol. 124, No. 2 (February), pp. 311-334.
 License: GPL (version 2 or later)
 URL: http://www.princeton.edu/~kimai/research/MNP.html
-Packaged: Tue Mar 22 19:38:10 2005; kimai
+Packaged: Sun May  1 21:44:10 2005; kimai
diff --git a/R/mnp.R b/R/mnp.R
index fb9da2b..f5bb133 100644
--- a/R/mnp.R
+++ b/R/mnp.R
@@ -38,10 +38,28 @@ mnp <- function(formula, data = parent.frame(), choiceX = NULL,
   X <- tmp$X
   coefnames <- tmp$coefnames
   n.cov <- ncol(X) / n.dim
+  
+  ## listwise deletion for X
+  na.ind <- apply(is.na(X), 1, sum)
+  if (ncol(Y) == 1)
+    na.ind <- na.ind + is.na(Y)
+  Y <- Y[na.ind==0,]
+  X <- X[na.ind==0,]
   n.obs <- nrow(X)
-  if (verbose)
+  
+  if (verbose) {
     cat("The dimension of beta is ", n.cov, ".\n\n", sep="")
-
+    cat("The number of observations is ", n.obs, ".\n\n", sep="")
+    if (sum(na.ind>0)>0) {
+      if (sum(na.ind>0)==1)
+        cat("The observation ", (1:length(na.ind))[na.ind>0], " is dropped due to missing values.\n\n", sep="")
+      else {
+        cat("The following ", sum(na.ind>0), " observations are dropped due to missing values:\n", sep="")
+        cat((1:length(na.ind))[na.ind>0], "\n\n")
+      }
+    }
+  } 
+  
   ## checking the prior for beta
   p.imp <- FALSE 
   if (p.var == Inf) {
diff --git a/R/predict.mnp.R b/R/predict.mnp.R
index 958b4a8..a2af611 100644
--- a/R/predict.mnp.R
+++ b/R/predict.mnp.R
@@ -25,13 +25,21 @@ predict.mnp <- function(object, newdata = NULL, newdraw = NULL,
                      cXnames = eval(call$cXnames),
                      base = object$base, n.dim = p-1,
                      lev = object$alt, MoP = is.matrix(object$y),
-                     verbose = FALSE, extra = FALSE)    
+                     verbose = FALSE, extra = FALSE)
+    if (nrow(x) > 1) 
+      x <- as.matrix(x[apply(is.na(x), 1, sum)==0,])
+    else if (sum(is.na(x))>0)
+      stop("Invalid input for `newdata'.")
   }
-
+  
   n.obs <- nrow(x)
-  if (verbose)
-    cat("There are", n.obs, "observations to predict. Please wait...\n")
-
+  if (verbose) {
+    if (n.obs == 1)
+      cat("There is one observation to predict. Please wait...\n")
+    else
+      cat("There are", n.obs, "observations to predict. Please wait...\n")
+  }
+  
   alt <- object$alt
   if (object$base != alt[1]) 
     alt <- c(object$base, alt[1:(length(alt)-1)])
diff --git a/R/ymatrix.mnp.R b/R/ymatrix.mnp.R
index 635b252..7c1e2f2 100644
--- a/R/ymatrix.mnp.R
+++ b/R/ymatrix.mnp.R
@@ -29,7 +29,7 @@ ymatrix.mnp <- function(data, base=NULL, extra=FALSE, verbose=verbose) {
       lev <- lev[counts > 0]
     }
     p <- length(lev)
-    Y <- unclass(Y) - 1
+    Y <- as.matrix(unclass(Y)) - 1
     MoP <- FALSE
   }
   if(extra)
diff --git a/man/mnp.Rd b/man/mnp.Rd
index 4f6de23..3edd1cf 100644
--- a/man/mnp.Rd
+++ b/man/mnp.Rd
@@ -11,7 +11,7 @@
   with different choice sets for each observation, and complete or
   partial ordering of all the available alternatives. The computation
   uses the efficient marginal data augmentation algorithm that is
-  developed by Imai and van Dyk (2005).  }
+  developed by Imai and van Dyk (2005a).  }
 
 \usage{
 mnp(formula, data = parent.frame(), choiceX = NULL, cXnames = NULL,
@@ -140,6 +140,12 @@ mnp(formula, data = parent.frame(), choiceX = NULL, cXnames = NULL,
 }
 
 \examples{
+###
+### NOTE: this example is not fully analyzed. In particular, the
+### convergence has not been assessed. A full analysis of these data
+### sets appear in Imai and van Dyk (2005b).
+###
+
 ## load the detergent data
 data(detergent)
 ## run the standard multinomial probit model with intercepts and the price
@@ -190,10 +196,15 @@ predict(res2, newdata = japan[10,], type = "prob")
 }
 
 \references{
-  Imai, Kosuke and David A. van Dyk. (2005) \dQuote{A Bayesian Analysis of the
-  Multinomial Probit Model Using the Marginal Data Augmentation,}
-  \emph{Journal of Econometrics}, Vol. 124, No. 2 (February),
-  pp.311-334.
+  Imai, Kosuke and David A. van Dyk. (2005a) \dQuote{A Bayesian Analysis
+    of the Multinomial Probit Model Using the Marginal Data
+    Augmentation,} \emph{Journal of Econometrics}, Vol. 124, No. 2
+  (February), pp.311-334.
+
+  Imai, Kosuke and David A. van Dyk. (2005b) \dQuote{MNP: R Package for
+    Fitting the Multinomial Probit Models,} \emph{Working Paper,
+    Department of Politics, Princeton University}, available at
+  \url{http://www.princeton.edu/~kimai/research/MNP.html} 
 }
 
 \author{

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



More information about the debian-science-commits mailing list