[r-cran-mnp] 28/51: Import Upstream version 2.4-1

Andreas Tille tille at debian.org
Fri Sep 8 14:14:47 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 4bd7022648a2c533dcc37720e9a2a013a1cd8e26
Author: Andreas Tille <tille at debian.org>
Date:   Fri Sep 8 15:54:53 2017 +0200

    Import Upstream version 2.4-1
---
 DESCRIPTION        |  8 ++++----
 R/predict.mnp.R    | 29 +++++++++++++++++------------
 man/mnp.Rd         |  2 +-
 man/predict.mnp.Rd | 47 +++++++++++++++++++++++++++++++----------------
 src/rand.c         |  6 ------
 src/rand.h         |  6 ------
 src/subroutines.c  |  6 ------
 src/subroutines.h  |  6 ------
 8 files changed, 53 insertions(+), 57 deletions(-)

diff --git a/DESCRIPTION b/DESCRIPTION
index f730a4b..05ef015 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -1,11 +1,11 @@
 Package: MNP
-Version: 2.3-9
-Date: 2006-9-21
+Version: 2.4-1
+Date: 2006-10-05
 Title: R Package for Fitting the Multinomial Probit Model
 Author: Kosuke Imai <kimai at princeton.edu>, 
         David A. van Dyk <dvd at uci.edu>. 
 Maintainer: Kosuke Imai <kimai at princeton.edu>
-Depends: R (>= 2.1), MASS
+Depends: R (>= 2.1), MASS, utils
 Description: MNP is a publicly available R package that fits the Bayesian
   multinomial probit model via Markov chain Monte Carlo. The
   multinomial probit model is often used to analyze the discrete
@@ -24,4 +24,4 @@ LazyLoad: yes
 LazyData: yes
 License: GPL (version 2 or later)
 URL: http://imai.princeton.edu/research/MNP.html
-Packaged: Thu Sep 21 09:48:21 2006; kimai
+Packaged: Thu Oct  5 19:22:35 2006; kimai
diff --git a/R/predict.mnp.R b/R/predict.mnp.R
index 1508a26..227d055 100644
--- a/R/predict.mnp.R
+++ b/R/predict.mnp.R
@@ -1,4 +1,4 @@
-predict.mnp <- function(object, newdata = NULL, newdraw = NULL,
+predict.mnp <- function(object, newdata = NULL, newdraw = NULL, moredraw = 1,
                         type = c("prob", "choice", "order", "latent"),
                         verbose = FALSE, ...){
 
@@ -45,15 +45,15 @@ predict.mnp <- function(object, newdata = NULL, newdraw = NULL,
     alt <- c(object$base, alt[1:(length(alt)-1)])
   
   ## computing W
-  W <- array(NA, dim=c(p-1, n.obs, n.draws), dimnames=c(alt[2:p],
-                                               NULL, 1:n.draws))
+  W <- array(NA, dim=c(p-1, n.obs, n.draws, moredraw),
+             dimnames=c(alt[2:p], NULL, 1:n.draws, 1:moredraw))
   tmp <- floor(n.draws/10)
   inc <- 1
   Sigma <- cov.mnp(object)
   for (i in 1:n.draws) {
     for (j in 1:n.obs) 
-      W[,j,i] <- matrix(x[j,], ncol=n.cov) %*% matrix(coef[i,]) +
-        mvrnorm(1, mu = rep(0, p-1), Sigma = Sigma[,,i])
+      W[,j,i,] <- matrix(x[j,], ncol=n.cov) %*% matrix(coef[i,]) +
+        mvrnorm(moredraw, mu = rep(0, p-1), Sigma = Sigma[,,i])
     if (i == inc*tmp & verbose) {
       cat("", inc*10, "percent done.\n")
       inc <- inc + 1
@@ -66,12 +66,16 @@ predict.mnp <- function(object, newdata = NULL, newdraw = NULL,
     ans$w <- NULL
 
   ## computing Y
-  Y <- matrix(NA, nrow = n.obs, ncol = n.draws, dimnames=list(NULL, 1:n.draws))
-  O <- array(NA, dim=c(p, n.obs, n.draws), dimnames=list(alt, NULL, 1:n.draws))
+  Y <- array(NA, dim = c(n.obs, n.draws, moredraw),
+             dimnames=list(NULL, 1:n.draws, 1:moredraw))
+  O <- array(NA, dim=c(p, n.obs, n.draws, 1:moredraw),
+             dimnames=list(alt, NULL, 1:n.draws, 1:moredraw))
   for (i in 1:n.obs) 
     for (j in 1:n.draws) {
-      Y[i,j] <- alt[match(max(c(0, W[,i,j])), c(0,W[,i,j]))]
-      O[,i,j] <- rank(c(0, -W[,i,j]))
+      for (k in 1:moredraw) {
+        Y[i,j,k] <- alt[match(max(c(0, W[,i,j,k])), c(0,W[,i,j,k]))]
+        O[,i,j,k] <- rank(c(0, -W[,i,j,k]))
+      }
     }
   if ("choice" %in% type)
     ans$y <- Y
@@ -84,10 +88,11 @@ predict.mnp <- function(object, newdata = NULL, newdraw = NULL,
 
   ## computing P
   if ("prob" %in% type) {
-    P <- matrix(NA, nrow = n.obs, ncol = p)
-    colnames(P) <- alt
+    P <- array(NA, dim = c(n.obs, p, moredraw),
+               dimnames = c(NULL, alt, 1:moredraw))
     for (i in 1:p)
-      P[,i] <- apply(Y==alt[i], 1, mean) 
+      for (j in 1:moredraw)
+        P[,i,j] <- apply(Y[,,j,drop=FALSE]==alt[i], 1, mean) 
     ans$p <- P
   }
   else
diff --git a/man/mnp.Rd b/man/mnp.Rd
index 113edbd..a9457e6 100644
--- a/man/mnp.Rd
+++ b/man/mnp.Rd
@@ -172,7 +172,7 @@ res2 <- mnp(cbind(LDP, NFP, SKG, JCP) ~ gender + education + age, data = japan,
 ## summarize the results
 summary(res2)
 ## calculate the predicted probabilities for the 10th observation
-predict(res2, newdata = japan[10,], type = "prob")
+predict(res2, newdata = japan[10,], type = "prob", verbose = TRUE)
 }
 
 \value{
diff --git a/man/predict.mnp.Rd b/man/predict.mnp.Rd
index 0018dcd..58ad032 100644
--- a/man/predict.mnp.Rd
+++ b/man/predict.mnp.Rd
@@ -10,7 +10,7 @@
 }
 
 \usage{
-  \method{predict}{mnp}(object, newdata = NULL, newdraw = NULL,
+  \method{predict}{mnp}(object, newdata = NULL, newdraw = NULL, moredraw = 1,
           type = c("prob", "choice", "order", "latent"), verbose = FALSE, ...)
 }
 
@@ -26,6 +26,13 @@
     posterior predictions. The default is the original MCMC draws stored
     in \code{object}.
   }
+  \item{moredraw}{The number of additional draws of latent variables for
+    each of MCMC draws. Given a particular MCMC draw of coefficients and
+    covariance matrix, the specified number of latent variables will be
+    sampled from the multivariate normal distribution.  This will be
+    particularly useful calculating the uncertainty of predicted
+    probabilities. The default is \code{1}.
+  }
   \item{type}{The type of posterior predictions required. There are
     four options:
     \code{type = "prob"} returns the predictive probabilities of being
@@ -68,30 +75,38 @@
 \value{
   \code{predict.mnp} yields a list containing at least one of the
   following elements:
-  \item{o}{A three dimensional array of the Monte Carlo sample from the
+  \item{o}{A four dimensional array of the Monte Carlo sample from the
     posterior predictive distribution of the ordered preferences. The
     first dimension corresponds to the alternatives in the choice set,
     the second dimension corresponds to the rows of \code{newdata} (or
-    the original data set if \code{newdata} is left unspecified), and
-    the third dimension indexes the Monte Carlo sample.}
-  \item{p}{A matrix of the posterior predictive probabilities for each
-  alternative in the choice set being most preferred. The
-  rows correspond to the rows of \code{newdata} (or the original data
-  set if \code{newdata} is left unspecified) and the columns correspond
-  to the alternatives in the choice set.
+    the original data set if \code{newdata} is left unspecified), 
+    the third dimension indexes the Monte Carlo sample, and the fourth
+    dimension is the number of additional draws given by
+    \code{moredraw}.}
+  \item{p}{A four dimensional array of the posterior predictive
+    probabilities for each alternative in the choice set being most
+    preferred. The first demension corresponds to the rows of
+    \code{newdata} (or the original data set if \code{newdata} is left
+    unspecified), the second dimension corresponds
+    to the alternatives in the choice set, and the third diemsion
+    represents the number of additional draws given by \code{moredraw}.
   }
-  \item{y}{A matrix of the Monte Carlo sample from the posterior predictive
-   distribution of the most preferred choice. The rows
-   correspond to the rows of \code{newdata} (or the original data set if
-   \code{newdata} is left unspecified) and the columns index the Monte
-   Carlo sample.
+  \item{y}{A three dimensional array of the Monte Carlo sample from the
+    posterior predictive distribution of the most preferred choice. The
+    first dimension correspond to the rows of \code{newdata} (or the
+    original data set if \code{newdata} is left unspecified), the
+    second dimension indexes the Monte Carlo sample, and the third
+    dimension represents the number of additional draws given by
+    \code{moredraw}.  
   }
-  \item{w}{A three dimensional array of the Monte Carlo sample from the 
+  \item{w}{A four dimensional array of the Monte Carlo sample from the
     posterior predictive distribution of the latent
     variable. The first dimension corresponds to the alternatives in the
      choice set, the second dimension corresponds to the rows of
      \code{newdata} (or the original data set if \code{newdata} is left
-     unspecified), and the third dimension indexes the Monte Carlo sample.
+     unspecified), the third dimension indexes the Monte Carlo sample,
+     and the four dimension represents the number of additional draws
+     given by \code{moredraw}.
   }
 }
 
diff --git a/src/rand.c b/src/rand.c
index 103dd75..e61bf39 100644
--- a/src/rand.c
+++ b/src/rand.c
@@ -1,9 +1,3 @@
-/******************************************************************
-  This file is a part of MNP: R Package for Estimating the 
-  Multinomial Probit Models by Kosuke Imai, Jordan R. Vance, and 
-  David A. van Dyk.
-  Copyright: GPL version 2 or later.
-*******************************************************************/
 
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/src/rand.h b/src/rand.h
index b8d793e..b7d9de7 100644
--- a/src/rand.h
+++ b/src/rand.h
@@ -1,9 +1,3 @@
-/******************************************************************
-  This file is a part of MNP: R Package for Estimating the 
-  Multinomial Probit Models by Kosuke Imai, Jordan R. Vance, and 
-  David A. van Dyk.
-  Copyright: GPL version 2 or later.
-*******************************************************************/
 
 double TruncNorm(double lb, double ub, double mu, double var, int invcdf);
 void rMVN(double *Sample, double *mean, double **inv_Var, int size);
diff --git a/src/subroutines.c b/src/subroutines.c
index 79abd4f..e6294cd 100644
--- a/src/subroutines.c
+++ b/src/subroutines.c
@@ -1,9 +1,3 @@
-/******************************************************************
-  This file is a part of MNP: R Package for Estimating the 
-  Multinomial Probit Models by Kosuke Imai, Jordan R. Vance, and 
-  David A. van Dyk.
-  Copyright: GPL version 2 or later.
-*******************************************************************/
 
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/src/subroutines.h b/src/subroutines.h
index f48513d..75a2e5d 100644
--- a/src/subroutines.h
+++ b/src/subroutines.h
@@ -1,9 +1,3 @@
-/******************************************************************
-  This file is a part of MNP: R Package for Estimating the 
-  Multinomial Probit Models by Kosuke Imai, Jordan R. Vance, and 
-  David A. van Dyk.
-  Copyright: GPL version 2 or later.
-*******************************************************************/
 
 void SWP( double **X, int k, int size);
 void dinv(double **X, int size, double **X_inv);

-- 
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