[r-cran-mnp] 43/51: Import Upstream version 2.6-1
Andreas Tille
tille at debian.org
Fri Sep 8 14:14:48 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 64cc64a082bdb4f8765b56a9d01d13ee8b721580
Author: Andreas Tille <tille at debian.org>
Date: Fri Sep 8 15:55:01 2017 +0200
Import Upstream version 2.6-1
---
DESCRIPTION | 50 +++++++++++++++++++++++++++-----------------------
MNP.pdf | Bin 0 -> 3487459 bytes
R/mnp.R | 21 ++++++++++++++-------
man/mnp.Rd | 34 +++++++++++++++++++++-------------
src/MNP.c | 10 +++++++++-
5 files changed, 71 insertions(+), 44 deletions(-)
diff --git a/DESCRIPTION b/DESCRIPTION
index 09f5cfa..96a3beb 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -1,30 +1,34 @@
Package: MNP
-Version: 2.5-6
-Date: 2008-03-24
+Version: 2.6-1
+Date: 2009-09-23
Title: R Package for Fitting the Multinomial Probit Model
-Author: Kosuke Imai <kimai at princeton.edu>,
- David A. van Dyk <dvd at uci.edu>.
+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, 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
- choices made by individuals recorded in survey data. Examples where
- the multinomial probit model may be useful include the analysis of
- product choice by consumers in market research and the analysis of
- candidate or party choice by voters in electoral studies. The MNP
- software can also fit the model with different choice sets for each
- individual, and complete or partial individual choice orderings of
- the available alternatives from the choice set. The estimation
- is based on the efficient marginal data augmentation algorithm that
- is developed by Imai and van Dyk (2005). ``A Bayesian Analysis of
- the Multinomial Probit Model Using the Data Augmentation,'' Journal
- of Econometrics, Vol. 124, No. 2 (February), pp. 311-334. Detailed
- examples are given in Imai and van Dyk (2005). ``MNP: R Package for
- Fitting the Multinomial Probit Model.'' Journal of Statistical Software,
- Vol. 14, No. 3 (May), pp. 1-32.
+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 choices made by individuals recorded in survey data.
+ Examples where the multinomial probit model may be useful
+ include the analysis of product choice by consumers in market
+ research and the analysis of candidate or party choice by
+ voters in electoral studies. The MNP software can also fit the
+ model with different choice sets for each individual, and
+ complete or partial individual choice orderings of the
+ available alternatives from the choice set. The estimation is
+ based on the efficient marginal data augmentation algorithm
+ that is developed by Imai and van Dyk (2005). ``A Bayesian
+ Analysis of the Multinomial Probit Model Using the Data
+ Augmentation,'' Journal of Econometrics, Vol. 124, No. 2
+ (February), pp. 311-334. Detailed examples are given in Imai
+ and van Dyk (2005). ``MNP: R Package for Fitting the
+ Multinomial Probit Model.'' Journal of Statistical Software,
+ Vol. 14, No. 3 (May), pp. 1-32.
LazyLoad: yes
LazyData: yes
License: GPL (>= 2)
-URL: http://imai.princeton.edu/research/MNP.html
-Packaged: Mon Mar 24 23:57:37 2008; kimai
+URL: http://imai.princeton.edu/software/MNP.html
+Packaged: 2009-09-24 02:29:56 UTC; kimai
+Repository: CRAN
+Date/Publication: 2009-09-24 06:31:42
diff --git a/MNP.pdf b/MNP.pdf
new file mode 100644
index 0000000..8ec049a
Binary files /dev/null and b/MNP.pdf differ
diff --git a/R/mnp.R b/R/mnp.R
index e17c1d2..545f12d 100644
--- a/R/mnp.R
+++ b/R/mnp.R
@@ -1,13 +1,13 @@
mnp <- function(formula, data = parent.frame(), choiceX = NULL,
cXnames = NULL, base = NULL, latent = FALSE,
- invcdf = FALSE, n.draws = 5000, p.var = "Inf",
+ invcdf = FALSE, trace = TRUE, n.draws = 5000, p.var = "Inf",
p.df = n.dim+1, p.scale = 1, coef.start = 0,
cov.start = 1, burnin = 0, thin = 0, verbose = FALSE) {
call <- match.call()
mf <- match.call(expand = FALSE)
mf$choiceX <- mf$cXnames <- mf$base <- mf$n.draws <- mf$latent <-
mf$p.var <- mf$p.df <- mf$p.scale <- mf$coef.start <- mf$invcdf <-
- mf$cov.start <- mf$verbose <- mf$burnin <- mf$thin <- NULL
+ mf$trace <- mf$cov.start <- mf$verbose <- mf$burnin <- mf$thin <- NULL
mf[[1]] <- as.name("model.frame")
mf$na.action <- 'na.pass'
mf <- eval.parent(mf)
@@ -29,6 +29,12 @@ mnp <- function(formula, data = parent.frame(), choiceX = NULL,
stop("The number of alternatives should be at least 3.")
if(verbose)
cat("The total number of alternatives is ", p, ".\n\n", sep="")
+ if(verbose) {
+ if (trace)
+ cat("The trace restriction is used instead of the diagonal restriction.\n\n")
+ else
+ cat("The diagonal restriction is used instead of the trace restriction.\n\n")
+ }
### obtaining X
tmp <- xmatrix.mnp(formula, data=eval.parent(data),
@@ -95,7 +101,7 @@ mnp <- function(formula, data = parent.frame(), choiceX = NULL,
stop("`p.scale' must be ", n.dim, " x ", n.dim, sep="")
if (sum(sign(eigen(p.scale)$values) < 1) > 0)
stop("`p.scale' must be positive definite.")
- else if (p.scale[1,1] != 1) {
+ else if ((trace == FALSE) & (p.scale[1,1] != 1)) {
p.scale[1,1] <- 1
warning("p.scale[1,1] will be set to 1.")
}
@@ -114,13 +120,14 @@ mnp <- function(formula, data = parent.frame(), choiceX = NULL,
n.cov, ".", sep=""))
if (!is.matrix(cov.start)) {
cov.start <- diag(n.dim)*cov.start
- cov.start[1,1] <- 1
+ if (!trace)
+ cov.start[1,1] <- 1
}
else if (ncol(cov.start) != n.dim || nrow(cov.start) != n.dim)
stop("The dimension of `cov.start' must be ", n.dim, " x ", n.dim, sep="")
else if (sum(sign(eigen(cov.start)$values) < 1) > 0)
stop("`cov.start' must be a positive definite matrix.")
- else if (cov.start[1,1] != 1) {
+ else if ((trace == FALSE) & (cov.start[1,1] != 1)) {
cov.start[1,1] <- 1
warning("cov.start[1,1] will be set to 1.")
}
@@ -148,7 +155,7 @@ mnp <- function(formula, data = parent.frame(), choiceX = NULL,
as.double(p.scale*p.alpha0), as.double(X), as.integer(Y),
as.double(coef.start), as.double(cov.start),
as.integer(p.imp), as.integer(invcdf),
- as.integer(burnin), as.integer(keep),
+ as.integer(burnin), as.integer(keep), as.integer(trace),
as.integer(verbose), as.integer(MoP), as.integer(latent),
pdStore = double(n.par*floor((n.draws-burnin)/keep)),
PACKAGE="MNP")$pdStore
@@ -169,7 +176,7 @@ mnp <- function(formula, data = parent.frame(), choiceX = NULL,
## returning the object
res <- list(param = param, x = X, y = Y, w = W, call = call, alt = lev,
- n.alt = p, base = base, invcdf = invcdf,
+ n.alt = p, base = base, invcdf = invcdf, trace = trace,
p.mean = if(p.imp) NULL else p.mean, p.var = p.var,
p.df = p.df, p.scale = p.scale, burnin = burnin, thin = thin)
class(res) <- "mnp"
diff --git a/man/mnp.Rd b/man/mnp.Rd
index 82dacca..9c0026a 100644
--- a/man/mnp.Rd
+++ b/man/mnp.Rd
@@ -16,7 +16,7 @@
\usage{
mnp(formula, data = parent.frame(), choiceX = NULL, cXnames = NULL,
- base = NULL, latent = FALSE, invcdf = FALSE, n.draws = 5000,
+ base = NULL, latent = FALSE, invcdf = FALSE, trace = TRUE, n.draws = 5000,
p.var = "Inf", p.df = n.dim+1, p.scale = 1, coef.start = 0,
cov.start = 1, burnin = 0, thin = 0, verbose = FALSE)
}
@@ -53,6 +53,12 @@ mnp(formula, data = parent.frame(), choiceX = NULL, cXnames = NULL,
used for truncated normal sampling. If \code{FALSE}, then the
rejection sampling method is used. The default is \code{FALSE}.
}
+ \item{trace}{logical. If \code{TRUE}, then the trace of the variance
+ covariance matrix is set to a constant (here, it is equal to \code{n.dim})
+ instead of setting its first diagonal element to 1. The former avoids
+ the arbitrariness of fixing one particular diagonal element in order to achieve
+ identification (see Burgette and Nordheim, 2009).
+ }
\item{n.draws}{A positive integer. The number of MCMC draws. The
default is \code{5000}.
}
@@ -66,25 +72,22 @@ mnp(formula, data = parent.frame(), choiceX = NULL, cXnames = NULL,
degrees of freedom parameter for the covariance matrix. The default is
\code{n.dim+1}, which is equal to the total number of alternatives.
}
- \item{p.scale}{A positive definite matrix whose first diagonal element
- is set to \code{1}. The prior scale matrix for the covariance
- matrix. The first diagonal element is set to 1 if
- it is not equal to 1 already. A scalar input can be used to set the
+ \item{p.scale}{A positive definite matrix. When \code{trace = FALSE}, its first diagonal element
+ is set to \code{1} if it is not equal to 1 already. The prior scale matrix for the covariance
+ matrix. A scalar input can be used to set the
scale matrix to a diagonal matrix with diagonal elements equal to
- the scalar input value, except that the first diagonal element is
- set to one. The default is \code{1}.
+ the scalar input value. The default is \code{1}.
}
\item{coef.start}{A vector. The starting values for the coefficients.
A scalar input sets the starting values for all the coefficients
equal to that value. The default is \code{0}.
}
- \item{cov.start}{A positive definite matrix whose first diagonal
- element is set to \code{1}. The starting values for the covariance
- matrix. The first diagonal element is set to 1 if it is not
- equal to 1 already. A scalar input can be used to set the starting
+ \item{cov.start}{A positive definite matrix. When \code{trace = FALSE}, its first diagonal
+ element is set to \code{1} if it is not
+ equal to 1 already. The starting values for the covariance
+ matrix. A scalar input can be used to set the starting
value to a diagonal matrix with diagonal elements equal to the scalar
- input value, except that the first diagonal element is set to
- one. The default is \code{1}.
+ input value. The default is \code{1}.
}
\item{burnin}{A positive integer. The burnin interval for the Markov
chain; i.e., the number of initial Gibbs draws that should not be
@@ -212,6 +215,11 @@ pre2 <- predict(res2, newdata = japan[10,], type = "prob", n.draws = 100,
Imai, Kosuke and David A. van Dyk. (2005b) \dQuote{MNP: R Package for
Fitting the Multinomial Probit Models,} \emph{Journal of Statistical
Software}, Vol. 14, No. 3 (May), pp.1-32.
+
+ Burgette, L.F. and E.V. Nordheim. (2009). \dQuote{An alternate identifying
+ restriction for the Bayesian multinomial probit model,} \emph{Technical
+ report}, Department of Statistics, University of Wisconsin, Madison.
+
}
\author{
diff --git a/src/MNP.c b/src/MNP.c
index 6928776..b02e3f1 100644
--- a/src/MNP.c
+++ b/src/MNP.c
@@ -22,6 +22,7 @@ void cMNPgibbs(int *piNDim, int *piNCov, int *piNSamp, int *piNGen,
int *invcdf, /* use inverse cdf for TruncNorm? */
int *piBurnin, /* the number of burnin */
int *piKeep,
+ int *itrace,
int *verbose, /* 1 if extra print is needed */
int *piMoP, /* 1 if Multinomial ordered Probit */
int *latent, /* 1 if W is stored */
@@ -354,7 +355,14 @@ void cMNPgibbs(int *piNDim, int *piNCov, int *piNSamp, int *piNGen,
/* recompute some quantities using the updated alpha2 */
for(j=0;j<n_cov;j++) beta[j]/=sqrt(alpha2);
- alpha2=Sigma[0][0];
+ if (*itrace) {
+ alpha2=0;
+ for(k=0;k<n_dim; k++)
+ alpha2+=Sigma[k][k];
+ alpha2 = alpha2/n_dim;
+ } else {
+ alpha2=Sigma[0][0];
+ }
for(j=0;j<n_dim;j++)
for(k=0;k<n_dim;k++) {
Sigma[j][k]/=alpha2;
--
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