Skip to content

Commit

Permalink
Fixed problem with erfc() function in C++ code---added C++11 to Syste…
Browse files Browse the repository at this point in the history
…mRequirements. Also, re-rendered all the vignettes successfully.
  • Loading branch information
pcarbo committed Oct 8, 2017
1 parent a4b12ee commit 5719dc1
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 28 deletions.
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Package: mashr
Type: Package
Encoding: UTF-8
Title: Multivariate Adaptive Shrinkage
Version: 0.2-0
Version: 0.2-1
Date: 2017-10-07
Author: Matthew Stephens, Sarah Urbut, Gao Wang, Peter Carbonetto
Maintainer: Matthew Stephens <mstephens@uchicago.edu>
Expand All @@ -11,6 +11,7 @@ URL: http://github.com/stephenslab/mashr
BugReports: http://github.com/stephenslab/mashr/issues
License: BSD_3_clause + file LICENSE
LazyData: true
SystemRequirements: C++11
Depends: R (>= 3.3.0),
ashr (>= 2.1-19)
Imports:
Expand Down
10 changes: 5 additions & 5 deletions docs/intro_mash.html
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,9 @@ <h1>Step 3: fit the model</h1>
<pre><code># - Computing 2000 x 151 likelihood matrix.
# - Likelihood calculations took 0.04 seconds.
# - Fitting model with 151 mixture components.
# - Model fitting took 0.34 seconds.
# - Model fitting took 0.33 seconds.
# - Computing posterior matrices.
# - Computation allocated took 0.01 seconds.</code></pre>
# - Computation allocated took 0.02 seconds.</code></pre>
<p>This can take a little time. What this does is to fit a mixture model to the data, estimating the mixture proportions. Specifically the model is that the true effects follow a mixture of multivariate normal distributions: <span class="math inline">\(B \sim \sum_k \sum_l \pi_{kl} N(0, \omega_l U_k)\)</span> where the <span class="math inline">\(\omega_l\)</span> are scaling factors set by the “grid” parameter in <code>mash</code> and the <span class="math inline">\(U_k\)</span> are the covariance matrices (here specified by <code>U.c</code>).</p>
<div id="step-4-extract-posterior-summaries" class="section level2">
<h2>Step 4: Extract Posterior Summaries</h2>
Expand Down Expand Up @@ -272,10 +272,10 @@ <h2>Session information.</h2>
# [1] stats graphics grDevices utils datasets methods base
#
# other attached packages:
# [1] mashr_0.1-24 ashr_2.1-26 rmarkdown_1.6
# [1] mashr_0.2-0 ashr_2.1-26 rmarkdown_1.6
#
# loaded via a namespace (and not attached):
# [1] Rcpp_0.12.12 knitr_1.16 magrittr_1.5
# [1] Rcpp_0.12.12 knitr_1.17 magrittr_1.5
# [4] REBayes_0.85 MASS_7.3-47 doParallel_1.0.10
# [7] pscl_1.4.9 SQUAREM_2016.8-2 lattice_0.20-35
# [10] foreach_1.4.3 plyr_1.8.4 stringr_1.2.0
Expand All @@ -284,7 +284,7 @@ <h2>Session information.</h2>
# [19] assertthat_0.2.0 yaml_2.1.14 rprojroot_1.2
# [22] digest_0.6.12 Matrix_1.2-10 codetools_0.2-15
# [25] evaluate_0.10.1 stringi_1.1.5 compiler_3.4.1
# [28] Rmosek_7.1.3 backports_1.1.0 mvtnorm_1.0-6
# [28] Rmosek_8.0.69 backports_1.1.0 mvtnorm_1.0-6
# [31] truncnorm_1.0-7</code></pre>
</div>
</div>
Expand Down
16 changes: 8 additions & 8 deletions docs/intro_mash_dd.html
Original file line number Diff line number Diff line change
Expand Up @@ -187,27 +187,27 @@ <h2>Run mash</h2>
<pre><code># - Computing 2000 x 91 likelihood matrix.
# - Likelihood calculations took 0.03 seconds.
# - Fitting model with 91 mixture components.
# - Model fitting took 0.18 seconds.
# - Model fitting took 0.13 seconds.
# - Computing posterior matrices.
# - Computation allocated took 0.00 seconds.</code></pre>
# - Computation allocated took 0.01 seconds.</code></pre>
<pre class="r"><code>print(get_loglik(m.ed),digits = 10)</code></pre>
<pre><code># [1] -16155.73391</code></pre>
<p>From the fit we see that the fit using the data-driven covariances is not as good as when we used the canonical covariances (which was -16120.32; from <a href="intro_mash.html">the introductory vignette</a>). This is expected for this simulation because the simulation actually used the canonical covariances!</p>
<p>In general we recommend running <code>mash</code> with both data-driven and canonical covariances. You could do this by combining the data-driven and canonical covariances as in this (unrun) code:</p>
<pre class="r"><code>U.c = cov_canonical(data)
m = mash(data, c(U.c,U.ed))</code></pre>
<pre><code># - Computing 2000 x 241 likelihood matrix.
# - Likelihood calculations took 0.14 seconds.
# - Likelihood calculations took 0.11 seconds.
# - Fitting model with 241 mixture components.</code></pre>
<pre><code># Warning in REBayes::KWDual(A, rep(1, k), normalize(w), control = control): estimated mixing distribution has some negative values:
# consider reducing rtol</code></pre>
<pre><code># Warning in mixIP(matrix_lik = structure(c(0.493081683750309,
# 0.849522254927991, : Optimization step yields mixture weights that are
# either too small, or negative; weights have been corrected and renormalized
# after the optimization.</code></pre>
<pre><code># - Model fitting took 0.68 seconds.
<pre><code># - Model fitting took 0.45 seconds.
# - Computing posterior matrices.
# - Computation allocated took 0.04 seconds.</code></pre>
# - Computation allocated took 0.07 seconds.</code></pre>
<p>For an example with simulations that do not follow the standard canonical matrices see <a href="simulate_noncanon.html">here</a>.</p>
</div>
<div id="session-information." class="section level2">
Expand All @@ -228,10 +228,10 @@ <h2>Session information.</h2>
# [1] stats graphics grDevices utils datasets methods base
#
# other attached packages:
# [1] mashr_0.1-24 ashr_2.1-26 rmarkdown_1.6
# [1] mashr_0.2-0 ashr_2.1-26 rmarkdown_1.6
#
# loaded via a namespace (and not attached):
# [1] Rcpp_0.12.12 knitr_1.16
# [1] Rcpp_0.12.12 knitr_1.17
# [3] magrittr_1.5 REBayes_0.85
# [5] MASS_7.3-47 doParallel_1.0.10
# [7] pscl_1.4.9 SQUAREM_2016.8-2
Expand All @@ -245,7 +245,7 @@ <h2>Session information.</h2>
# [23] digest_0.6.12 Matrix_1.2-10
# [25] codetools_0.2-15 evaluate_0.10.1
# [27] stringi_1.1.5 compiler_3.4.1
# [29] Rmosek_7.1.3 backports_1.1.0
# [29] Rmosek_8.0.69 backports_1.1.0
# [31] mvtnorm_1.0-6 truncnorm_1.0-7</code></pre>
</div>

Expand Down
14 changes: 7 additions & 7 deletions docs/simulate_noncanon.html
Original file line number Diff line number Diff line change
Expand Up @@ -160,30 +160,30 @@ <h2>Simple simulation</h2>
# - Computing 2000 x 151 likelihood matrix.
# - Likelihood calculations took 0.04 seconds.
# - Fitting model with 151 mixture components.
# - Model fitting took 0.29 seconds.
# - Model fitting took 0.26 seconds.
# - Computing posterior matrices.
# - Computation allocated took 0.00 seconds.
# - Computation allocated took 0.01 seconds.
m.ed = mash(data, U.ed)
# - Computing 2000 x 91 likelihood matrix.
# - Likelihood calculations took 0.02 seconds.
# - Fitting model with 91 mixture components.
# - Model fitting took 0.16 seconds.
# - Model fitting took 0.13 seconds.
# - Computing posterior matrices.
# - Computation allocated took 0.01 seconds.
m.c.ed = mash(data, c(U.c,U.ed))
# - Computing 2000 x 241 likelihood matrix.
# - Likelihood calculations took 0.06 seconds.
# - Fitting model with 241 mixture components.
# - Model fitting took 0.58 seconds.
# - Model fitting took 0.48 seconds.
# - Computing posterior matrices.
# - Computation allocated took 0.00 seconds.
# - Computation allocated took 0.01 seconds.
m.true = mash(data, U.true)
# - Computing 2000 x 31 likelihood matrix.
# - Likelihood calculations took 0.01 seconds.
# - Fitting model with 31 mixture components.
# - Model fitting took 0.06 seconds.
# - Model fitting took 0.05 seconds.
# - Computing posterior matrices.
# - Computation allocated took 0.00 seconds.
# - Computation allocated took 0.01 seconds.

print(get_loglik(m.c),digits = 10)
# [1] -16169.17212
Expand Down
2 changes: 1 addition & 1 deletion man/mash_compute_posterior_matrices.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions src/Makevars

This file was deleted.

3 changes: 0 additions & 3 deletions src/Makevars.win

This file was deleted.

3 changes: 3 additions & 0 deletions src/mash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
#include "mash.h"
// [[Rcpp::depends(RcppArmadillo)]]

// Enable C++11.
// [[Rcpp::plugins(cpp11)]]

// [[Rcpp::export]]
Rcpp::List calc_lik_rcpp(Rcpp::NumericMatrix b_mat,
Rcpp::NumericMatrix s_mat,
Expand Down

0 comments on commit 5719dc1

Please sign in to comment.