feat: new Bayesian Quality Control module with Bayesian Process Capability Study - #1
Draft
juliuspfadt wants to merge 8 commits into
Draft
Conversation
strip template example analyses, reuse quality control icons, set module metadata and Description.qml Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
ported verbatim from jasp-stats/jaspQualityControl#414 (branch vandenman:bqc, commit afe3837). dead common/Priors.qml dropped, common/PriorsNew.qml renamed to common/Priors.qml.
- qc:::samples_to_mu_and_sigma no longer exists; replace the three qc::: internals with exported qc::extract_predictive_samples, which handles the integration method natively (incl. degenerate data) and drops the hand-rolled NIG predictive - noChains/noWarmup/noIterations were dependencies but never read, so the MCMC settings in the GUI had no effect; pass them to all qc::bpc calls - interval estimate plot declared hasEstimate/hasCi deps and omitted hasType, the inverse of its Common.PlotLayout flags, so the Lower/Upper fields did not invalidate the plot (reported by julianwuth on #414) - rename getCustomAxisLimits -> .bpcsGetCustomAxisLimits, it leaked into the package namespace - drop unused rlang import Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
qc returns metrics named Cpu/Cpl and errors on CpU/CpL, but .bpcsGetSelectedMetrics built CpU/CpL. the %in% filters in the capability table, interval table and sequential plot therefore dropped both metrics, and qc::plot_density(what=) would have rejected them, so ticking Cpu or Cpl in the GUI produced nothing. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
#414 shipped with no tests. covers the capability table, metric selection, interval table, distribution and predictive plots, readiness, and both regressions fixed here (metric name casing, plot dependencies). includes a helper supplying the options jaspTools cannot read, it does not expand the Common.PlotLayout / Common.Priors qml components. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
- stats:: is used for density/median/quantile but was undeclared - %||% at the mcmc fallback is base R only since 4.4.0, undeclared - drop qualityControl-measurement.svg, unreferenced until gauge r&R lands - cover the sequential analysis plots, previously untested, and pin the unimplemented "Posterior updating table" option so it is not forgotten Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
the template lockfile carried 61 packages and none of qc, BayesTools, HDInterval or ggh4x, so renv::restore() could not have satisfied this module. regenerated to 129 packages against R 4.5.2, matching CI. - qc, jaspBase and jaspGraphs are pinned by commit sha, so the qc API drift that broke #414 cannot recur silently - fs, glue and posterior had been recorded against literal repository urls not present in the lockfile; all three are on CRAN at the same versions, so they are normalised to CRAN - RSPM is declared alongside CRAN, mirroring jaspQualityControl, so the ggh4x entry resolves jaspTools is deliberately absent, jasp-actions installs it separately. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
the template ships unittests.yml with its push/pull_request triggers commented out behind workflow_dispatch, so nothing ran on this PR. enabled them, with renv.lock added to the watched paths. build-bundle.yml is needed to prove the Stan-compiled qc dependency bundles on windows, linux and both macOS targets, which is the open risk on this module. test-coverage.yml skips drafts by design. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
Sets up
jaspBayesianQualityControland lands its first analysis, the Bayesian Process Capability Study, ported from the long-stalled jasp-stats/jaspQualityControl#414.Splitting the Bayesian analyses into their own module is the conclusion the original PR authors reached themselves — see this thread, where @julianwuth reports that he and EJ agreed a separate module was the better home. #414 stays open until this is merged; nothing is removed from
jaspQualityControlhere.Why a port rather than a merge
vandenman:bqcis merge-dirtyand not rebaseable againstjaspQualityControlmaster, and its diff carries 4166 lines ofrenv.lockchurn, a strayexample.csv, an.Rprojedit, and two roxygenman/*.Rdfiles left over fromdoeAnalysis. Porting the four source files was cleaner than untangling that.The analysis code is committed verbatim in
7784b18and authored to @vandenman, so the fixes that follow are reviewable as a diff against his original rather than blended into a squashed import. Only change in that commit: the deadcommon/Priors.qmlis dropped andcommon/PriorsNew.qmltakes its name (the analysis only ever referencedPriorsNew).The PR did not run as-is
Every unit-test job on #414 failed at
renv::restore()with a dependency-solve conflict, so CI never reached the code and none of it had ever executed. Five real bugs came out of getting it to run:1. Broken against the current
qcAPI. The predictive plots called threeqc:::internals, andsamples_to_mu_and_sigmahas since been deleted fromqc. The default path is unaffected — a conjugate prior undermethod = "integration"goes through.nig_posterior, which still exists — but any non-conjugate prior ("Informed uniform", custom informative) lands in the branch that calls the deleted function, so both predictive plots error. Verified reachable: a uniform prior resolves tomethod = "integration"withprior_resolvednotPriorConjugate.All three internals are replaced with exported
qc::extract_predictive_samples(), which is exactlyqc's own internal chain, handlesmethod = "integration"natively, and adds a degenerate-data guard the original lacked.qc::extract_predictive_samplesdraws Monte Carlo samples from the same posterior. Same distribution, different draws — posterior-predictive plots will not be pixel-identical to your version. If you would rather keep the analytic form, the alternative is exporting.nig_posteriorfromqcand reinstating it.2.
CpuandCplwere silently dropped.qcnames these metricsCpu/Cpland errors onCpU/CpL, but.bpcsGetSelectedMetricsbuiltCpU/CpL. The%in%filters in the capability table, the interval table and the sequential plot therefore removed both, andqc::plot_density(what = )would have rejected them. Ticking either box in the GUI produced nothing at all.3. The interval-estimate plot's dependencies were the inverse of its QML flags. It declared
hasEstimate/hasCi(controls that plot does not have) and omittedhasType, so the Lower and Upper fields never invalidated it. This is the issue @julianwuth reported in January; his second point, the 0–1 y-limits, had already been addressed.4. The MCMC settings were never read.
noChains/noWarmup/noIterationsappeared in.bpcsStateDeps()but nowhere else, so changing them invalidated the cache and recomputed an identical fit. They are now passed to everyqc::bpccall — but see the open question below, because that alone does not make them work.5. The "Posterior updating table" checkbox does nothing.
sequentialAnalysisUpdatingTableis defined in the qml (marked// TODO:) with aninfotooltip describing the table it would show, but has no R implementation at all — ticking it adds no output. Left unimplemented, with a test pinning the current behaviour so it is not silently forgotten. Worth hiding the control until the table exists.Also:
getCustomAxisLimitswas leaking into the package namespace (renamed.bpcsGetCustomAxisLimits);rlangwas imported for a.datapronoun that is never used;statswas used via::but undeclared; and%||%(base R only since 4.4.0) was used without an R version requirement, soDepends: R (>= 4.4.0)is now declared.Open question: the MCMC Settings group does nothing
qc::bpcdefaults tomethod = "integration"— deterministic numerical integration, not sampling — and there is no QML control anywhere for the estimation method. So even with fix 4 applied, chains/warmup/iterations have no effect on the capability table; they only reach the MCMC fallback inside the predictive plots.Two ways out, and this is a call for @vandenman rather than something to guess at:
Left as-is and documented in the test file rather than resolved unilaterally.
Tests
#414 shipped with none. This adds 10 tests / 26 assertions over the capability table, metric selection, the interval table, the distribution and predictive plots, the sequential analysis, readiness, and the regressions above, against a small committed dataset. Full suite runs in roughly 20 min against the locked dependency set, dominated by the sequential analysis, which refits once per observation. That is within the range of
jaspQualityControl's own jobs, but say the word and the sequential test can be trimmed or skipped on CI.Because the fit is numerical rather than sampled, results are deterministic across runs — so this suite should be far less platform-brittle than a sampler-based one would have been.
One wrinkle worth knowing:
jaspTools::analysisOptions()does not expand theCommon.PlotLayout/Common.Priorscomponents, so it returns only 37 of the 148 options this analysis needs. The test file carries a helper that supplies the other 111 at their qml defaults. This is a pre-existing jaspTools limitation rather than anything new here —jaspQualityControl's ownvariablesChartsSubgroupshas the same gap withCommon.ControlChartTests.Not in this PR
jasp-desktop/Modules/modules-settings.jsonand a mirror repo underjasp-stats-modules, oncebuild-bundleis green.msaGaugeRR.RandcommonQualityControl.R, so it needs a companion PR exporting those fromjaspQualityControl. Heads-up for whoever picks it up —.checkIfCrosseddropped itsmeasurementsargument on master, but #376 still calls it with four.Lockfile
Regenerated from the template's 61 packages to 129, against R 4.5.2 to match CI.
qc,jaspBaseandjaspGraphsare pinned by commit SHA rather than branch, so the kind of silentqcAPI drift that broke #414 cannot recur.fs,glueandposteriorhad been recorded against literal repository URLs absent from the lockfile; all three are on CRAN at identical versions and were normalised.RSPMis declared alongsideCRAN, mirroringjaspQualityControl.jaspToolsis deliberately absent — jasp-actions installs it separately, andjaspQualityControlomits it too.Verified:
renv::status()reports the project consistent, and the suite passes under the renv-activated environment against the locked versions, not just against a hand-assembled library path.Dependency note
qc(FBartos/qc, v0.0.0.9000) is GitHub-only and compiles Stan models (LinkingTo: BH, Rcpp, RcppEigen, RcppParallel, rstan, StanHeaders,SystemRequirements: GNU make). This was the main risk on the module, and CI has now settled it:qcbuilds from source and the full suite passes on windows-latest, ubuntu-latest and macos-latest (2.6 min and 2.4 min to compile on Windows and Ubuntu respectively), under both the lockfile and latest-CRAN resolutions.Still outstanding: macOS x86_64 is not covered by
unit-tests(macos-latestis arm64), and the.JASPModulebundle format itself is unproven. Both needbuild-bundle, which isissue_comment-triggered against base master and so cannot run untilbuild-bundle.ymlis on master.Unrelated but noticed while testing: with degenerate specification limits (target far outside the observed range)
qcreturnsCpcaround1.7e+244withsdexactly0rather than erroring. Looks like aqcissue rather than a module one, @FBartos / @vandenman.🤖 Generated with Claude Code