This is the code:Tolerance for test 2. A candidate is discarded if the norm of its gradient is smaller than \code{gTest} AND its LL is further than \code{llTest} from a better
Code: Select all
# Apply tests only if it hasn't converged and is not the best LL of the stage if(length(betterLLRows)>0 & !converged[j]){ # Test 1: Distance in parameter space to a better one betterParams <- candidates[[s+1]][betterLLRows,] if(length(betterLLRows)==1) betterParams <- matrix(betterParams, nrow=1) distParam <- apply(betterParams, MARGIN=1, function(x) sqrt(sum((x-candParam)^2)) ) failedT1Rows <- betterLLRows[ distParam<dTest ] # Test 2: small gradient norm and close to another browser() distLL <- abs(as.vector(LL[betterLLRows,s+1] - candLL)) failedT2Rows <- betterLLRows[ gradientNorm[betterLLRows]<gTest & distLL>=llTest ]
Please let me know if that is a proper assessment, or if I am incorrect. Thank you for your attention and hard work in putting together Apollo.