Skip to content

ENH: Add use_t and Kauermann-Carroll covariance to GEE - #10781

Merged
bashtage merged 10 commits into
statsmodels:mainfrom
ChenyangLi4288:enh/gee-small-sample
Nov 18, 2026
Merged

bashtage merged 10 commits into
statsmodels:mainfrom
ChenyangLi4288:enh/gee-small-sample

Conversation

@ChenyangLi4288

Copy link
Copy Markdown
Contributor

Adds two small-sample options to GEE, for data with few clusters:

  • use_t: fit(use_t=True) uses the t distribution for p-values, confidence intervals, t_test and f_test, with degrees of freedom = number of groups minus number of parameters. Also works for OrdinalGEE and NominalGEE. The default is unchanged.
  • cov_type="kauermann_carroll": the Kauermann-Carroll robust covariance. It is like "bias_reduced" (Mancl-DeRouen), but uses $$(I - H)^{-1/2}$$ instead of $$(I - H)^{-1}$$.

Tests:

  • Both "kauermann_carroll" and the existing "bias_reduced" match R geesmv 1.3 to about 1e-13. The R script, data and reference values are in genmod/tests/results.
  • geesmv's Kauermann-Carroll is only valid when I - H is symmetric (Gaussian, independence), so the other cases are checked against scipy.linalg.sqrtm.
  • The new tests fail on main and pass here.

AI Disclosure

Contributions must comply with the statsmodels AI Policy.

Tick exactly one of the following. If AI tools were used, replace the <...>
placeholders in the second option with the tool name(s) and how the tool's output was
used.

  • No AI tools were used to develop this pull request.
  • AI tools were used.
    Tool(s): Claude (Claude Code).
    Used for: drafting the tests, running the R scripts.
    I have personally read, understood, and can explain every line of this diff, and
    have verified the statistical/numerical correctness of the change.

With use_t=True, inference uses the t distribution with the number of groups minus the number of parameters as degrees of freedom. Closes statsmodels#8610.
Add cov_type="kauermann_carroll", tested against R geesmv along with the existing bias_reduced option. xref statsmodels#1183.
@ChenyangLi4288

ChenyangLi4288 commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor Author

Also because personally I am working with GGE a lot in my current project. Is it an option to add divide-and-conquer version GGE and does it make sense to cover more small-sample corrections, with t/F degrees of freedom, like, geesmv in R?

@bashtage

Copy link
Copy Markdown
Member

Thanks for the PR. The Kauermann-Carroll covariance agrees with an independent implementation and with R geesmv to about 1e-13, and CI is green. Two things need to change before this can be merged:

  1. Two branches are not tested. Dropping use_t in NominalGEE.fit, or skipping _handle_constraint for the KC covariance, leaves every test passing. Please parametrize the use_t test over OrdinalGEE and NominalGEE (check the p-values against t.sf with df_resid_inference), and add a constrained fit with cov_type="kauermann_carroll".
  2. use_t=True with too few clusters gives NaN without any message. df_resid_inference = n_groups - rank(exog) is 0 or negative when the clusters do not outnumber the parameters (3 clusters and 3 parameters gives df 0), and pvalues and conf_int are then all NaN. Please raise a ValueError (or warn and return NaN), say which in the use_t docstring, and add a test. Also, please explain in the docstring why n_groups - rank rather than n_groups - 1, which is what OLS with cluster-robust covariance (and Stata's vce(cluster)) use.

Nits:

  • The if x is None: warnings.warn(...) guard of the bias_reduced path now sits under the new KC block. Please put it back where it was.
  • Add a Notes/References entry for Kauermann and Carroll (2001, JASA 96, 1387-1396) and Mancl and DeRouen (2001). Say that the principal square root of I - H is used, which matters when I - H is not symmetric (any working correlation other than independence, any non-Gaussian family). A sentence on the cost for large clusters would help too.
  • geesmv was archived from CRAN, so the header of gee_small_sample.R should give where version 1.3 comes from, and where the data come from. Note also that the external reference covers the independence working correlation only.

Not needed here, but worth separate issues: get_margeff() ignores use_t, and cov_type is case-sensitive ("Kauermann_Carroll" raises an UnboundLocalError).

On your question about more geesmv corrections and a divide-and-conquer GEE: please do those as separate PRs after this one.

@ChenyangLi4288

ChenyangLi4288 commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor Author

Thank you for review @bashtage. Addressed your points in the code, and will raise separate for corrections and DC-GEE.

@bashtage
bashtage merged commit 9c7daca into statsmodels:main Nov 18, 2026
13 of 14 checks passed
@bashtage

Copy link
Copy Markdown
Member

LGTM. Thanks.

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.

ENH: GEE add use_t option for cov_params

3 participants