Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: bootstrap in network analysis cannot work well #3125

Open
1 of 3 tasks
alextaoo opened this issue Jan 13, 2025 · 4 comments
Open
1 of 3 tasks

[Bug]: bootstrap in network analysis cannot work well #3125

alextaoo opened this issue Jan 13, 2025 · 4 comments
Assignees
Labels
Module: jaspNetwork Waiting for requester If waiting for a long time it is reasonable to close an issue

Comments

@alextaoo
Copy link

alextaoo commented Jan 13, 2025

JASP Version

0.19.3

Commit ID

No response

JASP Module

Network

What analysis are you seeing the problem on?

No response

What OS are you seeing the problem on?

Windows 11

Bug Description

该分析意外终止。

Error in .extractErrorMessage(e): length(error) = 1 is not TRUE

Stack trace
.networkAnalysisBootstrap(mainContainer, network, options)

.networkAnalysisComputeBootstrap(bootstrapContainer, network, options)

tryCatch({
jaspBase::.suppressGrDevice({
for (nm in names(allNetworks)) {
bootstrapResult[[nm]] <- bootnet::bootnet(data = allNetworks[[nm]], nBoots = options[['bootstrapSamples']], type = options[['bootstrapType']], nCores = nCores, statistics = c('edge', 'strength', 'closeness', 'betweenness'), labels = options[['variables']])
}
})
}, error = function(e) bootstrapContainer$setError(.extractErrorMessage(e)))

tryCatchList(expr, classes, parentenv, handlers)

tryCatchOne(expr, names, parentenv, handlers[[1]])

value[3]

bootstrapContainer$setError(.extractErrorMessage(e))

private$jaspObject$setError(x)

.extractErrorMessage(e)

stopifnot(length(error) = 1)

要获得有关此问题的帮助,请在以下位置报告上述消息:https://jasp-stats.org/bug-reports

Expected Behaviour

should work well

Steps to Reproduce

This error message indicates an issue in the R code related to the networkAnalysisBootstrap and related functions. The key error message is length(error) = 1 is not TRUE which occurs within the stopifnot statement in the extractErrorMessage function (or a function that calls it).

Here's a breakdown of what might be going wrong:

1. extractErrorMessage function

The extractErrorMessage function likely expects the error object (which presumably represents an error that occurred earlier) to have a length of 1. But for some reason, when this check is made, the length of error is not 1, and thus the stopifnot condition fails and throws the error you're seeing.

2. Error handling in tryCatch

The tryCatch block is set up to handle errors that occur when running the bootnet::bootnet function. When an error happens during the execution of that bootnet call (for example, if there's an issue with the input data allNetworks[[nm]], incorrect specification of nBoots, type, etc., or a problem within the bootnet function itself), the error handler is supposed to call bootstrapContainer$setError(.extractErrorMessage(e)). However, since the extractErrorMessage function has the length check issue, it fails to handle the error gracefully.

3. Possible causes of incorrect error length

  • Multiple errors combined: Perhaps multiple errors are somehow being bundled together and passed to extractErrorMessage instead of a single error object, which would violate the expected length condition.
  • Incorrect error object creation: There could be a problem in how the error object is created or modified earlier in the code flow before it reaches the extractErrorMessage function. Maybe it's being initialized or populated in an unexpected way that results in it having a length other than 1.

4. Suggested steps for debugging

  • Check the bootnet call: Look closely at the input data (allNetworks), the values of nBoots, bootstrapType, nCores, and other parameters passed to bootnet::bootnet. Make sure they are all correctly specified and that the data is in the expected format. There could be something wrong with these inputs that is causing an error that then gets mishandled later.
  • Print the error object: Add some debugging statements to print the error object right before it's passed to extractErrorMessage in the tryCatch block. This can help you see what's actually in the error object and if it's indeed not in the expected format. For example, you could add print(e) just before bootstrapContainer$setError(.extractErrorMessage(e)) in the tryCatch block.
  • Check the extractErrorMessage function: Examine the extractErrorMessage function itself to see if there are any other parts of the code within it that could be modifying the error object's length or if there's an incorrect assumption about the structure of the error object that it's supposed to receive.

Overall, the error message points to a problem in the error handling and assumptions about the error object's structure in the context of the network analysis code you're working with.

Log (if any)

No response

More Debug Information

No response

Final Checklist

  • I have included a screenshot showcasing the issue, if possible.
  • I have included a JASP file (zipped) or data file that causes the crash/bug, if applicable.
  • I have accurately described the bug, and steps to reproduce it.
Copy link

@alextaoo, thanks for taking the time to create this issue. If possible (and applicable), please upload to the issue website (#3125, attaching to an email does not work) a screenshot showcasing the problem, and/or a compressed (zipped) .jasp file or the data file that causes the issue. If you would prefer not to make your data publicly available, you can send your file(s) directly to us, [email protected]

@github-actions github-actions bot added the Waiting for requester If waiting for a long time it is reasonable to close an issue label Jan 13, 2025
@alextaoo
Copy link
Author

do bootatrap
image

@github-actions github-actions bot removed the Waiting for requester If waiting for a long time it is reasonable to close an issue label Jan 13, 2025
@alextaoo alextaoo changed the title [Bug]: [Bug]: bootstrap in network analysis cannot work well Jan 13, 2025
@alextaoo
Copy link
Author

ineed help thanks

@tomtomme
Copy link
Member

@alextaoo
thx for the report. This error does only appear for non-parametric or case type bootstrap?
If so, it might be a duplicate of the bug reported here: #2863

If you agree, could you close this issue so that we can discuss over there? And lets press thumbs this can get fixed soon.

@tomtomme tomtomme added Waiting for requester If waiting for a long time it is reasonable to close an issue and removed OS: Windows 11 Bug labels Jan 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Module: jaspNetwork Waiting for requester If waiting for a long time it is reasonable to close an issue
Projects
None yet
Development

No branches or pull requests

3 participants