[jaspFrequencies] Fix crash in Multinomial Test when Descriptives checkbox is...#310
Open
sisyphus-jasp wants to merge 1 commit into
Open
[jaspFrequencies] Fix crash in Multinomial Test when Descriptives checkbox is...#310sisyphus-jasp wants to merge 1 commit into
sisyphus-jasp wants to merge 1 commit 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.
Summary
Fixes: https://github.com/jasp-stats/INTERNAL-jasp/issues/3109
Root cause
R/multinomialtest.R.chisquareTest()calledchisq.test()even when only one observed factor level was present.chisq.test()then errored ('x' must at least have 2 elements), causing fatal termination when descriptives output requested that result path.What changed
.chisquareTest()forlength(dataTable) < 2.chisq.test()and returns chisq-like placeholder results (observed,expected,X-squared=NA,df=NA,p.value=NA) plus a translated warning message.length(dataTable) >= 2) keep the original code path unchanged.Why
Caveats / reviewer checks
debInf) because provided upgrade.jaspfixture lackedinternal.sqlitein this environment.testAll()run after rebuild:[ FAIL 0 | WARN 9 | SKIP 3 | PASS 110 ].status: completewith note instead of fatal error.Implementation Plan
Root cause
R/multinomialtest.R,.chisquareTest()callschisq.test()even whentable(factorVariable)has only one element.chisq.test()errors ('x' must at least have 2 elements), and this bubbles out from.multinomialDescriptivesTable()(because.chisquareTest()is called before its localtry()), causing fatal termination.Proposed changes
R/multinomialtest.R.chisquareTest()dataTable <- table(factorVariable):length(dataTable) < 2, skipchisq.test()and return chisq-like placeholder result objects per hypothesis.observed,expected,statistic(X-squared = NA_real_),parameter(df = NA_real_),p.value = NA_real_, andwarnwith a translated message.length(dataTable) >= 2.Expected test impact
Fix crash in Multinomial Test when Descriptives checkbox is checked by adding proper error handling for debInf values
Attachment Descriptions
The following images were attached to the issue. They have been converted to text descriptions — the original image files are NOT available in the workspace. Do not reference screenshot filenames in your output.
Image
The screenshot shows JASP’s Frequencies module using the Multinomial Test analysis (analysis title: “Copy of Multinomial Test”), and the run has failed with a red error panel.
Error text (transcribed exactly)
UI state and selected options
The screenshot shows:
Analyses list on the left:
Binomial Test(collapsed)Multinomial Test(collapsed)Copy of Multinomial Test(expanded and active)Variable assignment area:
debInfis assigned.Test Values section:
Equal proportions (multinomial test).Custom expected proportions (χ² test).Additional Statistics section:
Descriptives: checked.Confidence interval: checked, value set to95 %.Vovk-Sellke maximum p-ratio: unchecked.Display section:
Counts: selected.Proportions: unselected.Plots section:
Descriptives plot: checked.Confidence interval: checked, value95 %.Visible output elements
Reproduction-relevant state
The failure occurs with a multinomial test where only one factor variable (
debInf) is assigned and bothCountsandExpected Countsfields are empty, while descriptive statistics and descriptive plot options (with confidence intervals) are enabled. The error indicates the internalchisq.testinputxhas fewer than 2 elements.Test Results
Automated Code Review
Approved after 1 review iteration(s).