Skip to content

Pad fixed boundary par vectors when adding analyses in gs_update_ahr() - #683

Open
yihui wants to merge 2 commits into
mainfrom
fix-update-ahr-add-analysis
Open

yihui wants to merge 2 commits into
mainfrom
fix-update-ahr-add-analysis

Conversation

@yihui

@yihui yihui commented Oct 6, 2026

Copy link
Copy Markdown
Collaborator

Problem

gs_update_ahr() can add an analysis beyond the original design (when n_analysis exceeds nrow(x$analysis)). For a boundary supplied as a fixed numeric par vector, that vector was left at its original length, so gs_power_npe() looked up par[k] for the new analysis and got NA, failing in if (a[k] > -Inf) with:

missing value where TRUE/FALSE needed

The common trigger is an efficacy-only design, whose lower bound is gs_b() with an -Inf par vector sized to the original number of analyses.

Fix

Pad fixed numeric par vectors (upper and lower) to the updated number of analyses, repeating the last value, before computing bounds. List-based spending pars already carry a timing of the right length and are left untouched. The alpha-only branch now uses the padded lpar for consistency (a no-op there, since that path keeps the original number of analyses).

Found while fixing keaven/gsDesign2Shiny#104 / keaven/gsDesign2Shiny#105, where adding a 4th analysis in the Update tab silently dropped back to 3 analyses.

Test

Added a developer test: an efficacy-only design (gs_b with -Inf futility) gains a 4th analysis and reports a finite efficacy bound at every analysis.

🤖 Generated with Claude Code

yihui and others added 2 commits October 6, 2026 15:48
…hr()

When gs_update_ahr() adds an analysis beyond the original design (n_analysis
greater than nrow(x$analysis)), a boundary supplied as a fixed numeric par
vector was left at its original length. The commonest case is an efficacy-only
design, whose lower bound is gs_b() with an -Inf par vector of length equal to
the original number of analyses: gs_power_npe() then looked up par[k] for the
new analysis, got NA, and failed in `if (a[k] > -Inf)` with "missing value
where TRUE/FALSE needed".

Pad fixed numeric par vectors (upper and lower) to the updated number of
analyses, repeating the last value, before computing bounds. List-based
spending pars already carry a `timing` of the right length and are untouched.
Also use the padded lpar in the alpha-only branch for consistency (a no-op
there, since that path keeps the original number of analyses).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@yihui
yihui requested a review from LittleBeannie October 6, 2026 20:01

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant