Skip to content

Commit

Permalink
Merge pull request #32 from willwerscheid/small-fixes
Browse files Browse the repository at this point in the history
Small fixes 4: fix maxiter parameter
  • Loading branch information
stephens999 authored Feb 20, 2018
2 parents 510b231 + c6e8ec9 commit dce01e6
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions R/flash.R
Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,12 @@ flash_backfit = function(data,f,kset=NULL,var_type = c("by_column","constant"),t
if(verbose){message("objective: ",c)}

diff = Inf
iteration = 2

while(diff > tol){
diff = Inf
iteration = 1

while((diff > tol) & (iteration <= maxiter)){
# There are two steps; first backfit, then null check
# (if nullcheck removes some factors then the whole process is repeated)
while((diff > tol) & (iteration < maxiter)){
iteration = iteration + 1
while((diff > tol) & (iteration <= maxiter)){
if(verbose){message("iteration:", iteration)}
for(k in kset){
f = flash_update_single_fl(data,f,k,var_type,ebnm_fn,ebnm_param)
Expand All @@ -141,6 +138,7 @@ flash_backfit = function(data,f,kset=NULL,var_type = c("by_column","constant"),t
diff = cnew-c
c = cnew
if(verbose){message("objective: ",c)}
iteration = iteration + 1
}

if(nullcheck){
Expand All @@ -152,6 +150,7 @@ flash_backfit = function(data,f,kset=NULL,var_type = c("by_column","constant"),t
cnew = flash_get_objective(data, f)
diff = cnew-c
c = cnew
iteration = 1
}

}
Expand Down

0 comments on commit dce01e6

Please sign in to comment.