Wrap getAFIs and getMIs calls in permuteOnce.mgcfa and permuteOnce.mimic with tryCatch (closes #159)#160
Open
Shotgunosine wants to merge 2 commits into
Open
Wrap getAFIs and getMIs calls in permuteOnce.mgcfa and permuteOnce.mimic with tryCatch (closes #159)#160Shotgunosine wants to merge 2 commits into
Shotgunosine wants to merge 2 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When
getAFIs(callinglavaan::fitMeasures) orgetMIs(calling lavaan::lavTestScore) errors during a permutation iteration — for example due toLAPACK dgesddfailures on numerically pathological score-test matrices, see Reference-LAPACK/lapack#672 — the unhandled error kills the worker. UnderparallelType = "multicore"this causesmclapplyto return atry-errorfor that permutation, which then crashes the aggregation at line ~990 withError in x$AFI : $ operator is invalid for atomic vectors.The fix wraps both calls in
tryCatchwith the same NA fallback that the function already uses for the sparse/nonconv branch (lines 1404–1410), so a single bad permutation contributes NA to the null distribution rather than terminating the entire call. I applied the same change topermuteOnce.mimicfor consistency.Note that I didn't add a new counter for something like
n.LapackFail, so then.nonConvergedcounter will be under-counting the true number of failures. I kept this initial proposed fix as narrow in scope as possible, but I can try to add an additional failure counter if you'd like.