Skip to content

Add check for perfect separation and some other tweaks#130

Merged
remlapmot merged 22 commits intomainfrom
2026-02-devel-4
Feb 25, 2026
Merged

Add check for perfect separation and some other tweaks#130
remlapmot merged 22 commits intomainfrom
2026-02-devel-4

Conversation

@remlapmot
Copy link
Collaborator

Hi Ryan

As I mentioned in our short course example we run across perfect separation - which (I guess to its credit) fastglm copes with - but it feels a bit dangerous that we don't warn folks - so I have included a check (I might have a go at putting this in the Python package in due course).

Also a few other fixes - I guess the 3 unused slots were features you might be planning to come back to??

  • Implement check for perfect separation when fitting logistic regression models.
  • Fixed a bug in and make some improvements to internal.weights().
  • The internal.analysis() function now sets the number of data.table threads as specified by nthreads.
  • Removed three unused slots in SEQopts().

1. **Model fitting** (numerator and denominator loops): before calling `model.passer()`, check `length(unique(y)) < 2`. If the outcome has no variation (all 0s or all 1s — the structural separation case), store a sentinel `list(skip = TRUE)` instead of fitting a model.

2. **Estimating loop**: check `isTRUE(model$skip)` before calling `inline.pred()`. If either the numerator or denominator model was skipped, assign `numerator = 1, denominator = 1` directly for that treatment level's rows — giving weights of 1, which is the correct answer when the treatment is structurally determined.

3. **Coefficient storage**: skip `clean_fastglm()` for sentinel models, storing `NULL` in the coefficient slot instead.
@remlapmot remlapmot requested a review from ryan-odea February 25, 2026 11:52
Copy link
Collaborator

@ryan-odea ryan-odea left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Tom!
This looks good to me - good idea on adding in the perfect separation warning.
Just two comments (not necessary to address).

calculate.var, hazard.fixed.dist, hazard.time_varying.dist
@remlapmot
Copy link
Collaborator Author

I've tweaked the pkgdown navbar to include the light-switch (dark mode) toggle, and clickable GitHub repo and CRAN page icons.

Screenshot 2026-02-25 at 13 59 41

@remlapmot
Copy link
Collaborator Author

Turns out we are meant to commit the favicons in pkgdown/favicon into the repo - which I've just done - I've never been involved with a package with a logo before so didn't spot this until reading the pkgdown workflow warning message.

@remlapmot remlapmot merged commit c5770f0 into main Feb 25, 2026
7 checks passed
@ryan-odea ryan-odea deleted the 2026-02-devel-4 branch February 27, 2026 14:02
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.

2 participants