Skip to content

Commit

Permalink
Made small adjustment to mixSQP().
Browse files Browse the repository at this point in the history
  • Loading branch information
pcarbo committed Apr 30, 2019
1 parent 2293b6e commit 4e22127
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ 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-35
Date: 2019-04-17
Version: 2.2-37
Date: 2019-04-30
Title: Methods for Adaptive Shrinkage, using Empirical Bayes
Description: The R package 'ashr' implements an Empirical Bayes
approach for large-scale hypothesis testing and false discovery
Expand Down
16 changes: 8 additions & 8 deletions R/mix_opt.R
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,6 @@ mixSQP <- function (matrix_lik, prior, pi_init = NULL,
if (is.null(pi_init))
pi_init <- rep(1,k)

# Always as a small "tweak" to the initial estimates of the mixture
# weights to ensure more reliable convergence.
pi_init <- pi_init + 0.01
pi_init <- pi_init/sum(pi_init)

# Add in observations corresponding to the prior.
A <- rbind(diag(k),matrix_lik)
w <- c(prior - 1,weights)
Expand All @@ -116,11 +111,16 @@ mixSQP <- function (matrix_lik, prior, pi_init = NULL,
# Fit the mixture weights using the mix-SQP algorithm.
control0 <- list(verbose = FALSE)
control <- modifyList(control0,control,keep.null = TRUE)
out <- mixsqp::mixsqp(A,w,pi_init,control = control)
out <- mixsqp::mixsqp(A,w,pi_init,control = control)

# Return the fitted mixture weights, and some other information
# about the optimization step.
return(list(pihat = out$x,
#
# Note that the mixture weights may not be normalized (i.e., they
# may not sum to 1) if the mix-SQP algorithm terminates prematurely,
# so to be extra cautious, the mix-SQP solution is normalized before
# returning it.
return(list(pihat = out$x/sum(out$x),
niter = nrow(out$data),
converged = (out$status == mixsqp.status.converged),
control = control))
Expand Down

0 comments on commit 4e22127

Please sign in to comment.