Skip to content

add robin_mh - #114

Open
clarkliming wants to merge 9 commits into
mainfrom
113_mh
Open

add robin_mh#114
clarkliming wants to merge 9 commits into
mainfrom
113_mh

Conversation

@clarkliming

Copy link
Copy Markdown
Collaborator

close #113

implement the robin_mh method

@github-actions

github-actions Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

badge

Code Coverage Summary

Filename                     Stmts    Miss  Cover    Missing
-------------------------  -------  ------  -------  -----------------------
R/bias.R                        34       0  100.00%
R/find_data.R                    3       0  100.00%
R/mh_effect.R                   25       0  100.00%
R/predict_couterfactual.R       77       0  100.00%
R/prediction_cf.R               22       0  100.00%
R/robin_glm.R                   49       1  97.96%   40
R/robin_lm.R                    28       0  100.00%
R/robin_mh.R                   261       5  98.08%   156, 168, 174, 420, 439
R/surv_effect.R                 60       0  100.00%
R/survival_cov_adj.R           146       0  100.00%
R/survival_score.R             294       0  100.00%
R/survival.R                   322       1  99.69%   567
R/treatment_effect.R           101       1  99.01%   51
R/utils.R                      235       3  98.72%   83, 115, 119
R/variance_anhecova.R           44       0  100.00%
R/variance_hc.R                 10       0  100.00%
TOTAL                         1711      11  99.36%

Diff against main

Filename           Stmts    Miss  Cover
---------------  -------  ------  --------
R/mh_effect.R        +25       0  +100.00%
R/robin_mh.R        +261      +5  +98.08%
R/surv_effect.R       -7       0  +100.00%
R/survival.R         -23       0  -0.02%
R/utils.R            +31       0  +0.19%
TOTAL               +287      +5  -0.22%

Results for commit: 4e8652a

Minimum allowed coverage is 80%

♻️ This comment has been updated with latest results

@github-actions

github-actions Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Unit Test Performance Difference

Test Suite $Status$ Time on main $±Time$ $±Tests$ $±Skipped$ $±Failures$ $±Errors$
robin_mh 👶 $+0.57$ $+72$ $+1$ $0$ $0$
survival 💔 $7.81$ $+1.06$ $0$ $0$ $0$ $0$
Additional test case details
Test Suite $Status$ Time on main $±Time$ Test Case
robin_mh 👶 $+0.02$ confint.mh_effect_returns_Wald_confidence_intervals_consistent_with_the_SE
robin_mh 👶 $+0.01$ h_mh_joint_strata_matches_interaction_when_no_label_collision_occurs
robin_mh 👶 $+0.01$ robin_mh_accepts_a_custom_contrast_against_ref_
robin_mh 👶 $+0.03$ robin_mh_accepts_factor_and_logical_binary_responses
robin_mh 👶 $+0.01$ robin_mh_does_not_retain_the_input_data_in_the_returned_object
robin_mh 👶 $+0.02$ robin_mh_does_not_warn_when_randomization_strata_carry_missing_values_but_are_covered
robin_mh 👶 $+0.02$ robin_mh_emits_a_warning_if_randomization_strata_are_not_analysis_strata
robin_mh 👶 $+0.01$ robin_mh_errors_on_randomization_strata_absent_from_data
robin_mh 👶 $+0.02$ robin_mh_extends_to_multi_arm_pairwise_comparisons_and_is_consistent_with_two_arm_fits
robin_mh 👶 $+0.01$ robin_mh_handles_unstratified_analysis_y_1_and_reduces_to_plain_risk_diff
robin_mh 👶 $+0.02$ robin_mh_keeps_strata_distinct_when_their_labels_contain_the_separator
robin_mh 👶 $+0.15$ robin_mh_matches_reference_formulas_across_estimand_and_variance_choices
robin_mh 👶 $+0.01$ robin_mh_messages_when_incomplete_observations_are_dropped
robin_mh 👶 $+0.01$ robin_mh_print_method_produces_the_expected_output
robin_mh 👶 $+0.01$ robin_mh_rejects_a_pair_referring_to_unobserved_treatment_levels
robin_mh 👶 $+0.02$ robin_mh_rejects_continuous_analysis_strata
robin_mh 👶 $+0.01$ robin_mh_rejects_the_treatment_variable_as_an_analysis_stratum
robin_mh 👶 $+0.02$ robin_mh_rejects_transformed_formula_terms_instead_of_silently_ignoring_them
robin_mh 👶 $+0.04$ robin_mh_reports_a_zero_standard_error_for_a_degenerate_stratum
robin_mh 👶 $+0.04$ robin_mh_returns_mh_effect_with_the_expected_components
robin_mh 👶 $+0.01$ robin_mh_stays_silent_when_the_analysis_strata_are_finer_than_the_randomization_strata
robin_mh 👶 $+0.02$ robin_mh_validates_inputs
robin_mh 👶 $+0.02$ robin_mh_with_y_1_reproduces_the_classic_two_sample_standard_errors
robin_mh 👶 $+0.02$ table.mh_effect_drops_the_Stratum_column_for_an_unstratified_analysis
robin_mh 👶 $+0.03$ table.mh_effect_returns_the_events_table_invisibly
survival 👶 $+0.01$ h_coef_mat_works_as_expected
survival 👶 $+0.03$ h_coef_mat_works_as_expected_for_multiple_comparisons
survival 💀 $0.01$ $-0.01$ h_log_hr_coef_mat_works_as_expected
survival 💀 $0.03$ $-0.03$ h_log_hr_coef_mat_works_as_expected_for_multiple_comparisons

Results for commit ff0fd56

♻️ This comment has been updated with latest results.

@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Unit Tests Summary

  1 files   14 suites   15s ⏱️
167 tests 120 ✅ 47 💤 0 ❌
420 runs  355 ✅ 65 💤 0 ❌

Results for commit 4e8652a.

♻️ This comment has been updated with latest results.

Resolve conflicts in R/RobinCar2-package.R (keep setNames import alongside
main's importFrom reorganization) and NEWS.md (move the robin_mh entry under
the unreleased 0.2.3.9000 heading rather than the released 0.2.3 section).

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
clarkliming and others added 4 commits July 29, 2026 09:57
`robin_mh()` adjusts for covariates by stratification only, which the
`y ~ s1 + s2` formula did not signal: bare RHS terms mean working-model
covariates in `robin_lm()`/`robin_glm()`. Keep the grammar, make the
semantics explicit, and reject the case it silently mishandled.

- Reject continuous analysis strata via `h_mh_assert_strata()`, which
  would otherwise contribute one stratum per distinct value. Mirrors the
  `assert_factor()` check the stratified log-rank code already applies.
- Document how the randomization scheme enters each analysis function in
  the `intro` vignette: `robin_lm()`/`robin_glm()` feed a scheme-specific
  variance correction from the `treatment` formula, so omitting a
  randomization variable from the model costs precision only, whereas
  `robin_mh()`/`robin_surv()` condition on the strata directly and have no
  such correction.
- State the direction of that failure, backed by simulation: under `pb` the
  unstratified standard error is conservative (SE/SD 1.18, 98% coverage),
  not anti-conservative, and carries no penalty under `sr`. A varying
  allocation ratio is the one case that biases the estimate.
- Add the MH-specific trade-offs to `?robin_mh`: cell sparsity, and the
  constant-allocation assumption behind `estimand = "ATE"`.
- Pin the `y ~ 1` degeneracy in tests: `GR`/`Sato` reproduce the unpooled
  Wald standard error, `mGR` its `n - 1` variant.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.

implement MH method

1 participant