Commit d3ae885b authored by Andreas Tille's avatar Andreas Tille

New upstream version 0.9.12-4.1

parent 44347e67
Package: BayesFactor
Type: Package
Title: Computation of Bayes Factors for Common Designs
Version: 0.9.12-4
Date: 2018-05-06
Authors@R: c(person("Richard D.", "Morey", role = c("aut", "cre"), email =
"richarddmorey@gmail.com"), person("Jeffrey N.", "Rouder", role = "aut",
email = "rouderj@missouri.edu"), person("Tahira", "Jamil", role = "ctb",
email = "tahjamil@gmail.com"))
Version: 0.9.12-4.1
Date: 2018-05-08
Authors@R: c(person("Richard D.", "Morey", role = c("aut", "cre", "cph"), email = "richarddmorey@gmail.com"),
person("Jeffrey N.", "Rouder", role = "aut", email = "jrouder@uci.edu"),
person("Tahira", "Jamil", role = c("ctb","cph"), email = "tahjamil@gmail.com"),
person("Simon", "Urbanek", role = c("ctb", "cph"), email = "simon.urbanek@r-project.org"),
person("Karl", "Forner", role = c("ctb", "cph"), email = "karl.forner@gmail.com"),
person("Alexander", "Ly", role = c("ctb", "cph"), email = "Alexander.Ly.NL@gmail.com"))
Description: A suite of functions for computing
various Bayes factors for simple designs, including contingency tables,
one- and two-sample designs, one-way designs, general ANOVA designs, and
......@@ -24,10 +26,13 @@ LazyLoad: yes
LinkingTo: Rcpp (>= 0.11.2), RcppEigen (>= 0.3.2.2.0)
RoxygenNote: 6.0.1
NeedsCompilation: yes
Packaged: 2018-05-07 17:04:16 UTC; richard
Author: Richard D. Morey [aut, cre],
Packaged: 2018-05-08 10:22:00 UTC; richard
Author: Richard D. Morey [aut, cre, cph],
Jeffrey N. Rouder [aut],
Tahira Jamil [ctb]
Tahira Jamil [ctb, cph],
Simon Urbanek [ctb, cph],
Karl Forner [ctb, cph],
Alexander Ly [ctb, cph]
Maintainer: Richard D. Morey <richarddmorey@gmail.com>
Repository: CRAN
Date/Publication: 2018-05-07 20:51:29 UTC
Date/Publication: 2018-05-08 11:28:10 UTC
73403f5d2fdbab9304b938e778a8c32c *DESCRIPTION
697c86cec4893d0419f2b45c5cbbd12b *DESCRIPTION
95366d8415ab5bc2015b009e0fd2a932 *NAMESPACE
aafeccda09cb8629e09836c420d4ece3 *NEWS
fa8eac62b4bed07b1ddb9bff36b2afdb *R/BayesFactorPCL-package.R
cae93a6084aaac4587fa7196a4897913 *R/BayesFactorPCL-package.R
c07f5aa20300bf63952c1c2fc4e5fac2 *R/RcppExports.R
440b11c82aa5d6e6a426221b7435ff7c *R/aaClasses.R
8699eea296aefd7c890042d7e385e876 *R/aaGenerics.R
......@@ -13,7 +13,7 @@ dde5b596c6782568c436f0f1dc47b06e *R/base64.R
32ef3e5315e7f1ec1f4d2b292285eb60 *R/common.R
57ee5fb0c2644f81b44a22cd0bd7c8bf *R/contingency-utility.R
50cf75291caa64e26d8db561245c9340 *R/contingency.R
bc15d61e4d3df33d5b88c765231b2b89 *R/correlation-JASP.R
41a3f1f3b48d80ddc822d3e8e3f00c45 *R/correlation-JASP.R
de449f5e87d84c81e5849ce2c5b63bd7 *R/correlation-utility.R
510bc1a9ea7843caed39de5e479112c9 *R/correlationBF.R
5989fe681407b2aff91bbf43c30f756b *R/gaussApproxAOV.R
......@@ -56,19 +56,19 @@ cce3e64b98c058acf95f32ff45c104a8 *R/version.R
94e24dbb4ed809a1ac870cdb432ed510 *data/raceDolls.rda
1ccf4cdfbb6ee831b5c60dc2ca0d04ca *inst/doc/compare_lme4.R
664d69ff793b89ef5cb940b5c31a9d94 *inst/doc/compare_lme4.Rmd
f8dc33813441554d8f9cbeb4f673c9dc *inst/doc/compare_lme4.html
e7557d7d9e079b62c28ebecc3a44eb46 *inst/doc/compare_lme4.html
3444667beceae04bc51450d8537a4954 *inst/doc/index.R
ab8952192cc7b37a4343c4fedf54a791 *inst/doc/index.Rmd
7fbf239f48829fef418ac580858b3b34 *inst/doc/index.html
2d29f2810c40e744c87d3c326553efc7 *inst/doc/manual.R
a7b4cbadefef5294e9e4d273fbb280f4 *inst/doc/manual.Rmd
c6bba3e41bfb09386892689b1949cee1 *inst/doc/manual.html
a7f5b98c4de93712f1a54ea8ab343924 *inst/doc/manual.html
4152a2af90c99e372f47508e1ec3f6f4 *inst/doc/odds_probs.R
12a83925c5eb48221cea2851782311aa *inst/doc/odds_probs.Rmd
b9f761bbe6aacd6ea5cf7e2f806bad3b *inst/doc/odds_probs.html
b94bfba6d70d2efbb2b6fbabbdc54857 *inst/doc/odds_probs.html
58f497699627aeed95274ddbc16df40c *inst/doc/priors.R
00453f4aedb7029cdcb99427110a9d34 *inst/doc/priors.Rmd
07cccbe60ddc394f30a6a4bb6eef83e6 *inst/doc/priors.html
6d38988ef7e9644b0d0b155c267eb469 *inst/doc/priors.html
e9400e851188414778e46499702c6108 *inst/include/BayesFactor.h
bc49293e445773685371f62db735b84e *inst/include/BayesFactor_RcppExports.h
b668c9d076209546253781c4d10668de *inst/tests/test-anovaBF.R
......@@ -85,7 +85,7 @@ b8385f6b77a6cc5586bf20d291d8cc80 *man/BFBayesFactor-class.Rd
f0b76247ecba5ad3dff41cb8110c5fde *man/BFManual.Rd
4b64080b5990a403e688aec94ed7d596 *man/BFodds-class.Rd
9304ffca3dde3d69feaa44a40e1888d0 *man/BFprobability-class.Rd
7407c11a023f39814dd1ca36d46f4042 *man/BayesFactor-package.Rd
7e4fdfa7bb1a03a31e72a1f97ee49e3b *man/BayesFactor-package.Rd
44d8b51b16971e22a6b4fbc4ed9d1372 *man/anovaBF.Rd
96031aed3232a0c95b3f7e03c82cb447 *man/as.BFBayesFactor.Rd
b9af1dff97bc70504d84797e7d0e8bfd *man/as.BFprobability.Rd
......@@ -125,7 +125,7 @@ c88b84670252fa37824f50594416f2d8 *man/recompute-methods.Rd
7484c794e068f0f0b773d67328778336 *src/RcppCallback.cpp
402a02d08f1ec534e863d085e0a4d27e *src/RcppExports.cpp
cd40a4d89842450277508d0ae22d3933 *src/bfcommon.h
082e1a407af2df4c1f94cfafba234546 *src/corr.cpp
d14368c4a1e2cd464c68087174d0d2a3 *src/corr.cpp
6da84348ccc705c261aa769904cff53f *src/dinvgamma.cpp
b2f02e6281807c79291769241c346954 *src/genhypergeo_series_pos.cpp
d9e574331b181fd8193e4006ca4506eb *src/interruptable_progress_monitor.h
......
......@@ -8,7 +8,7 @@
#'regression, correlations, proportions, and contingency tables.
#'
#'\tabular{ll}{ Package: \tab BayesFactor\cr Type: \tab Package\cr Version: \tab
#'0.9.12-4\cr Date: \tab 2015-2-20\cr License: \tab GPL 2.0\cr LazyLoad: \tab
#'0.9.12-4.1\cr Date: \tab 2018-5-08\cr License: \tab GPL 2.0\cr LazyLoad: \tab
#'yes\cr } The following methods are currently implemented, with more to follow:
#'
#'general linear models (including linear mixed effects models): \code{\link{generalTestBF}}, \code{\link{lmBF}}
......@@ -28,6 +28,8 @@
#'
#'single proportions: \code{\link{proportionBF}};
#'
#'linear correlations: \code{\link{correlationBF}};
#'
#'Other useful functions: \code{\link{posterior}}, for sampling from posterior
#'distributions; \code{\link{recompute}}, for re-estimating a Bayes factor or
#'posterior distribution; \code{\link{compare}}, to compare two model
......
## The code in this file is from the JASP project
## (https://github.com/jasp-stats/jasp-desktop/blob/development/JASP-Engine/JASP/R/correlationbayesian.R)
## and written by Alexander Ly (Alexander.Ly.NL@gmail.com)
.bf10Exact <- function(n, r, kappa=1) {
# Ly et al 2015
# This is the exact result with symmetric beta prior on rho
......
......@@ -341,14 +341,14 @@ t.la = system.time(bfs.la &lt;- anovaBF(y ~ A*B*C + ID, data = effects,
</code></pre>
<pre><code>## user system elapsed
## 12.510 0.126 14.142
## 9.090 0.157 9.865
</code></pre>
<pre><code class="r">t.la
</code></pre>
<pre><code>## user system elapsed
## 7.149 0.064 8.329
## 4.601 0.053 4.796
</code></pre>
<pre><code class="r">plot(log(extractBF(sort(bfs.is))$bf),log(extractBF(sort(bfs.la))$bf),
......@@ -516,7 +516,7 @@ bfEff &lt;- colMeans(B5out[,1:10])
<!-- html table generated in R 3.5.0 by xtable 1.8-2 package -->
<!-- Mon May 7 18:03:46 2018 -->
<!-- Tue May 8 11:21:26 2018 -->
<table border=1>
<tr> <th> </th> <th> lmer fixed effects </th> </tr>
......@@ -563,7 +563,7 @@ sideBySide &lt;- data.frame(BayesFactor=bfEff,lmer=reparLmer)
<!-- html table generated in R 3.5.0 by xtable 1.8-2 package -->
<!-- Mon May 7 18:03:46 2018 -->
<!-- Tue May 8 11:21:26 2018 -->
<table border=1>
<tr> <th> </th> <th> BayesFactor </th> <th> lmer </th> </tr>
......@@ -593,7 +593,7 @@ abline(0,1, lty=2)
<hr/>
<p><em>This document was compiled with version 0.9.12-4 of BayesFactor (R version 3.5.0 (2018-04-23) on x86_64-apple-darwin15.6.0).</em></p>
<p><em>This document was compiled with version 0.9.12-4.1 of BayesFactor (R version 3.5.0 (2018-04-23) on x86_64-apple-darwin15.6.0).</em></p>
</body>
......@@ -2249,7 +2249,7 @@ Ly, A., Verhagen, A. J. &amp; Wagenmakers, E.-J. (2015). Harold Jeffreys&#39;s D
<p>Social media icons by <a href="http://www.awicons.com/">Lokas Software</a>.</p>
<p><em>This document was compiled with version 0.9.12-4 of BayesFactor (R version 3.5.0 (2018-04-23) on x86_64-apple-darwin15.6.0).</em></p>
<p><em>This document was compiled with version 0.9.12-4.1 of BayesFactor (R version 3.5.0 (2018-04-23) on x86_64-apple-darwin15.6.0).</em></p>
</body>
......@@ -407,7 +407,7 @@ post.prob
<p>Social media icons by <a href="http://www.awicons.com/">Lokas Software</a>.</p>
<p><em>This document was compiled with version 0.9.12-4 of BayesFactor (R version 3.5.0 (2018-04-23) on x86_64-apple-darwin15.6.0).</em></p>
<p><em>This document was compiled with version 0.9.12-4.1 of BayesFactor (R version 3.5.0 (2018-04-23) on x86_64-apple-darwin15.6.0).</em></p>
</body>
......
......@@ -428,7 +428,7 @@ t.test(x~grp,data=dat,paired=TRUE)
<hr/>
<p><em>This document was compiled with version 0.9.12-4 of BayesFactor (R version 3.5.0 (2018-04-23) on x86_64-apple-darwin15.6.0).</em></p>
<p><em>This document was compiled with version 0.9.12-4.1 of BayesFactor (R version 3.5.0 (2018-04-23) on x86_64-apple-darwin15.6.0).</em></p>
</body>
......
......@@ -13,7 +13,7 @@ regression, correlations, proportions, and contingency tables.
}
\details{
\tabular{ll}{ Package: \tab BayesFactor\cr Type: \tab Package\cr Version: \tab
0.9.12-4\cr Date: \tab 2015-2-20\cr License: \tab GPL 2.0\cr LazyLoad: \tab
0.9.12-4.1\cr Date: \tab 2018-5-08\cr License: \tab GPL 2.0\cr LazyLoad: \tab
yes\cr } The following methods are currently implemented, with more to follow:
general linear models (including linear mixed effects models): \code{\link{generalTestBF}}, \code{\link{lmBF}}
......@@ -33,6 +33,8 @@ contingency tables: \code{\link{contingencyTableBF}};
single proportions: \code{\link{proportionBF}};
linear correlations: \code{\link{correlationBF}};
Other useful functions: \code{\link{posterior}}, for sampling from posterior
distributions; \code{\link{recompute}}, for re-estimating a Bayes factor or
posterior distribution; \code{\link{compare}}, to compare two model
......
......@@ -22,12 +22,12 @@ double bFunc(const double rho, int const n, const double r, const bool hg_checkm
NumericVector U(2, n*0.5);
NumericVector L(1, 1.5);
NumericVector z(1, r * r * rho * rho);
double hyper_term = genhypergeo_series_pos(U, L, z, hg_checkmod, hg_iter, 0, 0, 0)[0];
double log_term = 2 * ( lgamma(n*0.5) - lgamma((n-1)*0.5) ) +
(n-1) * 0.5 * log1p( -(rho*rho) ) + log(2);
double log_term = 2 * ( lgamma(n*0.5) - lgamma((n-1)*0.5) ) +
(n-1) * 0.5 * log1p( -(rho*rho) ) + log(2.0);
return r * rho * exp( log_term + hyper_term );
}
// [[Rcpp::export]]
......@@ -47,7 +47,7 @@ double corrtest_like_Rcpp(double zeta, NumericVector r, NumericVector n, double
int i;
double rho = tanh( zeta );
double logdens = Rf_dbeta( (rho+1.0)/2.0, a_prior, b_prior, 1) + log1p( -(rho*rho) );
for( i = 0; i < r.size() ; i++ ){
if( approx ){
logdens += jeffreys_approx_corr( rho, n[i], r[i] );
......@@ -60,14 +60,14 @@ double corrtest_like_Rcpp(double zeta, NumericVector r, NumericVector n, double
// [[Rcpp::export]]
NumericMatrix metropCorrRcpp_jeffreys(NumericVector r, NumericVector n, double a_prior, double b_prior, bool approx, int iterations, bool doInterval,
NumericVector intervalz, bool intervalCompl, bool nullModel, int progress, Function callback, double callbackInterval)
NumericMatrix metropCorrRcpp_jeffreys(NumericVector r, NumericVector n, double a_prior, double b_prior, bool approx, int iterations, bool doInterval,
NumericVector intervalz, bool intervalCompl, bool nullModel, int progress, Function callback, double callbackInterval)
{
RNGScope scope;
// setting last_cb to the beginning of the epoch
// setting last_cb to the beginning of the epoch
// ensures that the callback is called once, first
time_t last_cb = static_cast<time_t>(int(0));
time_t last_cb = static_cast<time_t>(int(0));
int i = 0;
double Ubounds[2];
......@@ -75,7 +75,7 @@ NumericMatrix metropCorrRcpp_jeffreys(NumericVector r, NumericVector n, double a
double candidate, z, trans_zeta;
bool inInterval, valid_zeta = true;
// For intervals
if( doInterval){
if( intervalz.size() == 0){
......@@ -87,25 +87,25 @@ NumericMatrix metropCorrRcpp_jeffreys(NumericVector r, NumericVector n, double a
// starting values
double fish_z0 = sum ( fish_z * ( n - 2 ) ) / sum( n - 2 );
double fish_sd = sqrt( 1 / sum( n - 2 ) );
double fish_sd = sqrt( 1 / sum( n - 2 ) );
double zeta = fish_z0;
// create progress bar
class Progress p(iterations, (bool) progress);
// Create matrix for chains
NumericMatrix chains(iterations, 2);
if(nullModel){
std::fill(chains.begin(), chains.end(), 0);
return chains;
}
if(doInterval){
Ubounds[0] = Rf_pnorm5( intervalz[0], fish_z0, fish_sd, 1, 0 );
Ubounds[1] = Rf_pnorm5( intervalz[1], fish_z0, fish_sd, 1, 0 );
}
// Start sampler
for( i = 0 ; i < iterations ; i++ )
{
......@@ -113,18 +113,18 @@ NumericMatrix metropCorrRcpp_jeffreys(NumericVector r, NumericVector n, double a
// Check interrupt
if (Progress::check_abort() )
Rcpp::stop("Operation cancelled by interrupt.");
p.increment(); // update progress
// Check callback
if( RcppCallback( &last_cb, callback, ( 1000.0 * ( i + 1 ) ) / iterations, callbackInterval) )
Rcpp::stop("Operation cancelled by callback function.");
// sample delta
// sample delta
if(doInterval){
if(intervalCompl){
candidate = Rf_runif(0, Ubounds[0] + 1 - Ubounds[1]);
if( candidate > Ubounds[0])
if( candidate > Ubounds[0])
candidate = candidate - Ubounds[0] + Ubounds[1];
}else{
candidate = Rf_runif(Ubounds[0], Ubounds[1]);
......@@ -133,23 +133,23 @@ NumericMatrix metropCorrRcpp_jeffreys(NumericVector r, NumericVector n, double a
}else{
candidate = Rf_rnorm( fish_z0, fish_sd );
}
// Metropolis-Hastings step
z = corrtest_like_Rcpp(candidate, r, n, a_prior, b_prior, approx, 0, 2000) -
z = corrtest_like_Rcpp(candidate, r, n, a_prior, b_prior, approx, 0, 2000) -
corrtest_like_Rcpp(zeta, r, n, a_prior, b_prior, approx, 0, 2000) +
Rf_dnorm4(zeta, fish_z0, fish_sd, 1) -
Rf_dnorm4(zeta, fish_z0, fish_sd, 1) -
Rf_dnorm4(candidate, fish_z0, fish_sd, 1);
if(doInterval){
trans_zeta = Rf_pnorm5(zeta, fish_z0, fish_sd, 1, 0 );
inInterval = ( Ubounds[0] > trans_zeta ) && ( Ubounds[1] < trans_zeta );
if( (inInterval && intervalCompl) || (!inInterval && !intervalCompl) )
valid_zeta = false;
}
if( ( Rf_rexp(1) > -z ) || !valid_zeta ){
zeta = candidate;
zeta = candidate;
}
// copy to chains
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment