stephenslab / mixsqp

R package for fast maximum-likelihood estimation of mixture proportions using SQP.
https://bit.ly/2NtYHWT
Other
11 stars 7 forks source link

Add EM "pre-fitting" step to mixsqp method #29

Closed pcarbo closed 5 years ago

pcarbo commented 5 years ago

Running a very small number of EM updates before running mix-SQP can help to make mix-SQP converge more reliably to the solution. This is an example where mix-SQP on its own fails to find the correct solution, but running a few EM iterations first allows mix-SQP to easily converge to the solution.

load("ashr.RData")
out1 <- ash(x,s,"+uniform",method="shrink",outputlevel=3,optmethod="mixIP")
out2 <- ash(x,s,"+uniform",method="shrink",outputlevel=3,optmethod="mixEM")

# Fails to converge.
out3 <- suppressWarnings(
  ash(x,s,"+uniform",method="shrink",outputlevel=3,optmethod="mixSQP",
      control = list(maxiter.sqp = 40,verbose = TRUE)))

# Converges easily.
out4a <- suppressWarnings(
           ash(x,s,"+uniform",method="shrink",outputlevel=3,optmethod="mixEM",
               control = list(maxiter = 4)))
out4b <- ash(x,s,"+uniform",method="shrink",outputlevel=3,optmethod="mixSQP",
             g = out4a$fitted_g,fixg = FALSE,control = list(verbose = TRUE))

ashr.RData.gz

pcarbo commented 5 years ago

Implemented in commit 36a37b8.