[r-cran-mcmcpack] 13/90: Imported Upstream version 0.7-2

Andreas Tille tille at debian.org
Fri Dec 16 09:07:34 UTC 2016


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

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

commit 01ed8004e01075552278e5dc68489908aa151123
Author: Andreas Tille <tille at debian.org>
Date:   Fri Dec 16 08:07:05 2016 +0100

    Imported Upstream version 0.7-2
---
 DESCRIPTION         |  6 +++---
 HISTORY             | 12 ++++++++++++
 NAMESPACE           |  1 +
 R/hidden.R          | 14 +++++++-------
 src/MCMCSVDreg.cc   | 37 +++++++++++++++++++++++++++++++++++--
 src/MCMCirtKdRob.cc | 28 ++++++++++++++++++----------
 6 files changed, 76 insertions(+), 22 deletions(-)

diff --git a/DESCRIPTION b/DESCRIPTION
index 7b33dbc..7c7f3c7 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -1,6 +1,6 @@
 Package: MCMCpack
-Version: 0.7-1
-Date: 2006-1-28
+Version: 0.7-2
+Date: 2006-5-29
 Title: Markov chain Monte Carlo (MCMC) Package
 Author: Andrew D. Martin <admartin at wustl.edu>, and
   Kevin M. Quinn <kevin_quinn at harvard.edu>
@@ -17,4 +17,4 @@ Description: This package contains functions to perform Bayesian
   sampling algorithm, and tools for visualization.
 License: GPL version 2
 URL: http://mcmcpack.wustl.edu
-Packaged: Sat Jan 28 09:00:50 2006; adm
+Packaged: Mon May 29 13:11:44 2006; adm
diff --git a/HISTORY b/HISTORY
index be2eaa7..437b51c 100644
--- a/HISTORY
+++ b/HISTORY
@@ -2,6 +2,18 @@
 // Changes and Bug Fixes
 //
 
+0.7-1 to 0.7-2
+  * added procrustes() to NAMESPACE so that it can be seen (function and 
+    documentation already there).
+  * fixed the prior in the full conditional for theta_i in MCMCirtKdRob. 
+    Previously was uniform on the unit circle which was not consistent with
+    the documentation and could cause problems given how the starting values
+    were chosen. 	
+  * fixed prior for lambda_j in MCMCirtKdRob (similar to point above)	
+  * fixed the the calculation of the full conditional for gamma[i] in 
+    MCMCSVDreg()
+  * Fixed a bug in MCMCbetabinomial() [thanks to John Wood].
+
 0.6-6 to 0.7-1
   * Added robust k-dimensional IRT model MCMCirtKdRob().
   * Added SVD regression MCMCSVDreg().
diff --git a/NAMESPACE b/NAMESPACE
index 33acf6c..8d7c36d 100644
--- a/NAMESPACE
+++ b/NAMESPACE
@@ -34,6 +34,7 @@ export(
        MCMCSVDreg,
        MCMCtobit,
        PostProbMod,
+       procrustes,
        rdirichlet,
        read.Scythe,
        rinvgamma,
diff --git a/R/hidden.R b/R/hidden.R
index 1a262a2..b7602f5 100644
--- a/R/hidden.R
+++ b/R/hidden.R
@@ -102,17 +102,17 @@
     return(0)
   }
 
-# check inverse Gamma prior
-"check.ig.prior" <-
-   function(c0, d0) {
+# check beta prior
+"check.beta.prior" <-
+   function(alpha, beta) {
      
-    if(c0 <= 0) {
-      cat("Error: IG(c0/2,d0/2) prior c0 less than or equal to zero.\n")
+    if(alpha <= 0) {
+      cat("Error: Beta(alpha,beta) prior alpha less than or equal to zero.\n")
       stop("Please respecify and call ", calling.function(), " again.\n",
          call.=FALSE)
     }
-    if(d0 <= 0) {
-      cat("Error: IG(c0/2,d0/2) prior d0 less than or equal to zero.\n")
+    if(beta <= 0) {
+      cat("Error: Beta(alpha,beta) prior beta less than or equal to zero.\n")
        stop("Please respecify and call ", calling.function(), " again.\n",
         call.=FALSE)    
     }
diff --git a/src/MCMCSVDreg.cc b/src/MCMCSVDreg.cc
index bd77052..1531571 100644
--- a/src/MCMCSVDreg.cc
+++ b/src/MCMCSVDreg.cc
@@ -141,8 +141,41 @@ extern "C" {
       for (int i=0; i<n; ++i){
 	double mstar = (g0[i] + tau2[i]*gammahat[i]) / (1 + tau2[i]);
 	double vstar = (sigma2 * tau2[i]) / (dsquared[i] * (tau2[i] + 1));
-	double wstar = 1.0 - (1.0 - w0[i]) /  
-	  (1.0 - w0[i] + w0[i] * dnorm(0.0, mstar, std::sqrt(vstar))); 
+	//double wstar = 1.0 - (1.0 - w0[i]) /  
+	//  (1.0 - w0[i] + w0[i] * dnorm(0.0, mstar, std::sqrt(vstar))); 
+
+	Matrix<double> gammanoti = gamma;
+	gammanoti[i] = 0.0;
+
+	Matrix<double> residvec = y - FtD * gammanoti;
+	Matrix<double> margmeanvec = FtD(_,i) * g0[i];
+	Matrix<double> margVarmat = FtD(_,i) * t(FtD(_,i)) * 
+	  (sigma2 * tau2[i]) / (dsquared[i]) + eye<double>(n) * sigma2; 
+	
+	double logw0 = std::log(w0[i]);
+	double log1minusw0 = std::log(1.0 - w0[i]);
+	double logf0 = 0.0;
+	for (int j=0; j<n; ++j){
+	  logf0 += lndnorm(residvec[j], 0.0, std::sqrt(sigma2));
+	}
+	double logfnot0 = lndmvn(residvec, margmeanvec, margVarmat);
+	
+	double logdenom;
+	if ( (logw0 + logf0) > (log1minusw0 + logfnot0)){
+	  logdenom = logw0 + logf0 + std::log(1.0 + 
+					   std::exp(log1minusw0 - 
+						    logw0 + logfnot0 - 
+						    logf0));  
+	}
+	else{
+	  logdenom = log1minusw0 + logfnot0 + std::log(1.0 + 
+					   std::exp(logw0 - 
+						    log1minusw0 + logf0 - 
+						    logfnot0));  	  
+	}
+	double wstar = std::exp(logw0 + logf0 - logdenom);
+
+
 	if (stream->runif() < wstar){
 	  gamma[i] = 0.0;
 	}
diff --git a/src/MCMCirtKdRob.cc b/src/MCMCirtKdRob.cc
index 89fe595..946bf09 100644
--- a/src/MCMCirtKdRob.cc
+++ b/src/MCMCirtKdRob.cc
@@ -85,7 +85,7 @@ static double Lambda_logfcd(const double& lam_ij,
   
   // check to see if inequality constraint is satisfied and 
   // evaluate prior
-  /*  
+    
   double logprior = 0.0;  
   if (Lambda_ineq(rowindex,colindex) * lam_ij < 0){
     return log(0.0);
@@ -95,8 +95,9 @@ static double Lambda_logfcd(const double& lam_ij,
 			Lambda_prior_mean(rowindex,colindex), 
 			sqrt(1.0 / Lambda_prior_prec(rowindex,colindex)));
   } 
-  */
+  
   // prior is uniform on hypersphere with radius 10
+  /*
   if (Lambda_ineq(rowindex,colindex) * lam_ij < 0){
     return log(0.0);
   } 
@@ -113,7 +114,7 @@ static double Lambda_logfcd(const double& lam_ij,
     return log(0.0);
   }
   const double logprior = 0.0;
-
+  */
 
   // likelihood
   double loglike = 0.0;
@@ -162,14 +163,14 @@ static double theta_logfcd(const double& t_ij,
 			   const int& colindex){
  
   const int D = Lambda.cols();     
-  // evaluate prior
-  /*
+  // evaluate prior  
   if (theta_ineq(rowindex,colindex-1) * t_ij < 0){
     return log(0.0);
   } 
   const double logprior = lndnorm(t_ij, 0.0, 1.0); 
-  */
+  
   // prior is uniform on unit circle
+  /*
   if (theta_ineq(rowindex,colindex-1) * t_ij < 0){
     return log(0.0);
   } 
@@ -186,7 +187,7 @@ static double theta_logfcd(const double& t_ij,
     return log(0.0);
   }
   const double logprior = 1.0;
-
+  */
 
   // likelihood
   double loglike = 0.0;
@@ -823,10 +824,9 @@ extern "C"{
   int count = 0;  
   for (int iter=0; iter < tot_iter; ++iter){
 
-        
     double L, R, w, funval, z;
     int p;
-        
+
     // sample theta
     int param = 1;    
     SampleNoReplace(N, N, N_inds_perm, N_array, stream);   
@@ -848,11 +848,13 @@ extern "C"{
 				*k0, *k1, *c0, *d0,
 				*c1, *d1, i, j);
 	  z = funval - stream->rexp(1.0);
+
 	  if (*method_step == 1){
 	    StepOut(&theta_logfcd, X, Lambda, theta, delta0, delta1, 
 		    Lambda_prior_mean, Lambda_prior_prec, Lambda_ineq,
 		    theta_ineq, *k0, *k1, *c0, *d0, *c1, *d1, i, j, z, 
 		    w, p, stream, L, R, param);
+	    
 	    theta(i,j) = shrinkageStep(&theta_logfcd, X, Lambda, theta,
 				       delta0, delta1, Lambda_prior_mean, 
 				       Lambda_prior_prec, Lambda_ineq,
@@ -879,6 +881,7 @@ extern "C"{
     }
     
     
+
     // sample Lambda
     param = 0;
     SampleNoReplace(K, K, K_inds_perm, K_array, stream);   
@@ -927,6 +930,8 @@ extern "C"{
       }
     }
     
+
+    
     // sample delta0
     param = 2;
     w = *delta0_w;
@@ -963,6 +968,9 @@ extern "C"{
 				 *k0, *k1, *c0, *d0, *c1, *d1, 0, 0,
 				 z, w, stream, L, R, param);
     }
+
+
+
     // sample delta1
     param = 3;
     w = *delta1_w;
@@ -1029,7 +1037,7 @@ extern "C"{
     }
     
     // allow user interrupts
-    void R_CheckUserInterrupt(void);    
+    R_CheckUserInterrupt();    
   } // end MCMC loop
   
   delete stream; // clean up random number stream  

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



More information about the debian-science-commits mailing list