Skip to content

Refuse an all-NA additional covariate up front - #77

Merged
correspondMerchant merged 1 commit into
mainfrom
fix/validate-all-na-additional-covariate
Aug 10, 2026
Merged

Refuse an all-NA additional covariate up front#77
correspondMerchant merged 1 commit into
mainfrom
fix/validate-all-na-additional-covariate

Conversation

@correspondMerchant

Copy link
Copy Markdown
Owner

An additional covariate whose column is entirely NA made glm()'s internal na.omit drop every row, so the fit died with the opaque error "Error occurred during model fitting step: ... Argument mu must be a nonempty numeric vector", which never named the covariate. Unlike a collinear covariate, which glm() can drop and still fit (and which already warns), an all-NA covariate is always a mistake and can never enter the model.

validate_inputs() now refuses it up front, after the column-existence check, naming the offending covariate(s) in one error. all(is.na(col)) catches an all-NA column of any type (numeric, factor, character). No previously successful run changes; the check is narrow (a partially-observed covariate is untouched).

Adds end-to-end and unit tests: the refusal fires and names the covariate, catches all-NA factor/character columns, and stays silent on some-NA and fully-observed covariates. The end-to-end test asserts the clear message replaces the cryptic model-fitting error and fails on the prior source.

An additional covariate whose column is entirely NA made glm()'s internal
na.omit drop every row, so the fit died with the opaque error "Error
occurred during model fitting step: ... Argument mu must be a nonempty
numeric vector", which never named the covariate. Unlike a collinear
covariate, which glm() can drop and still fit (and which already warns), an
all-NA covariate is always a mistake and can never enter the model.

validate_inputs() now refuses it up front, after the column-existence check,
naming the offending covariate(s) in one error. all(is.na(col)) catches an
all-NA column of any type (numeric, factor, character). No previously
successful run changes; the check is narrow (a partially-observed covariate
is untouched).

Adds end-to-end and unit tests: the refusal fires and names the covariate,
catches all-NA factor/character columns, and stays silent on some-NA and
fully-observed covariates. The end-to-end test asserts the clear message
replaces the cryptic model-fitting error and fails on the prior source.
@correspondMerchant
correspondMerchant merged commit a2ce5d9 into main Aug 10, 2026
1 check passed
@correspondMerchant
correspondMerchant deleted the fix/validate-all-na-additional-covariate branch August 10, 2026 17:50
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