From 6ee64fb41c0d79839e92a3dc859de92d35faa724 Mon Sep 17 00:00:00 2001 From: Peter Carbonetto Date: Wed, 19 Feb 2020 16:57:12 -0600 Subject: [PATCH] Adjusted mixsqp settings; fixed a few of the tests. --- DESCRIPTION | 2 +- R/mix_opt.R | 4 +++- R/tests.R | 12 ++++++++++++ tests/testthat/test_binom.R | 3 ++- 4 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 R/tests.R diff --git a/DESCRIPTION b/DESCRIPTION index 81cb322..9ba6e0c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -13,7 +13,7 @@ Authors@R: c(person("Matthew","Stephens",role="aut", person("Jason","Willwerscheid",role="aut"), person("Nan","Xiao",role="aut"), person("Mazon","Zeng",role="ctb")) -Version: 2.2-44 +Version: 2.2-45 Date: 2020-02-19 Title: Methods for Adaptive Shrinkage, using Empirical Bayes Description: The R package 'ashr' implements an Empirical Bayes diff --git a/R/mix_opt.R b/R/mix_opt.R index 4b36aea..435da96 100644 --- a/R/mix_opt.R +++ b/R/mix_opt.R @@ -109,7 +109,9 @@ mixSQP <- function (matrix_lik, prior, pi_init = NULL, w <- w[w != 0] # Fit the mixture weights using the mix-SQP algorithm. - control0 <- list(verbose = FALSE) + control0 <- list(verbose = FALSE, + eps = 1e-6, + numiter.em = 20) control <- modifyList(control0,control,keep.null = TRUE) out <- mixsqp::mixsqp(A,w,pi_init,control = control) diff --git a/R/tests.R b/R/tests.R new file mode 100644 index 0000000..704f6f0 --- /dev/null +++ b/R/tests.R @@ -0,0 +1,12 @@ +# The Rmosek package on CRAN will not work with REBayes. This function +# is used for some of the tests to check whether the correct Rmosek +# package (the one downloaded from mosek.com) is installed. +# +#' @importFrom testthat skip_if_not_installed +#' @importFrom testthat skip_if +#' +skip_if_mixkwdual_doesnt_work <- function() { + skip_if_not_installed("REBayes") + skip_if_not_installed("Rmosek") + skip_if(!is.element("mosek_lptoprob",getNamespaceExports("Rmosek"))) +} diff --git a/tests/testthat/test_binom.R b/tests/testthat/test_binom.R index 942da22..9378efe 100644 --- a/tests/testthat/test_binom.R +++ b/tests/testthat/test_binom.R @@ -75,11 +75,12 @@ test_that("lik_binom (logit link) fitted g is close to true g",{ }) test_that("lik_binom (logit link) fitted g is close to true g",{ + # Simulate a Binomial dataset set.seed(1) truemode = 0 logitp = c(rep(0,800), runif(200,-3,3)) - p = 1/(1+exp(-logitp)) + p = 1/(1 + exp(-logitp)) n = rep(100,1000) x = rbinom(1000,n,p) # Binomial observations ash.binom.out = ash(rep(0,length(x)),1,lik=lik_binom(x,n,link="logit"),