Binary outcomes
Conditional log odds and separate marginal ratio estimands. Check the scale of each result.
fit_binomial(y, exposures, covariates=None, *, q=4, breaks=None, alpha=0.05, weights=None)
Fit an additive Bernoulli-logit model and sum exposure coefficients.
y must contain only 0 and 1. Inputs are complete, real and finite.
Positive case weights act as GLM prior weights. Exposure cuts ignore weights.
The sum is a conditional log odds ratio. Its confidence interval uses
normal limits and a normal z p-value, following R qgcomp 2.19.6.
fit_binomial_formula(formula, data, exposures, *, q=4, breaks=None, alpha=0.05, missing='raise', weights=None)
Fit additive Bernoulli-logit main effects from named columns.
missing='drop' removes incomplete rows after estimating automatic
exposure cutpoints from all observed exposure values, as in R qgcomp.
fit_binomial_risk_ratio(y, exposures, covariates=None, *, q=2, breaks=None, alpha=0.05, B=200, seed=None)
Estimate a marginal risk ratio per joint score-category increase.
For two levels the effect is the ratio of standardized risks at 1 and 0. For three or more levels it is the slope of a degree-one log-binomial marginal structural model fitted to standardized risks at every level. Inputs must have complete numeric rows, no case weights and independent rows. A failed bootstrap draw raises an error instead of being replaced. R is needed only for optional reference checks, never at Python run time.
fit_binomial_odds_ratio(y, exposures, covariates=None, *, q=2, breaks=None, alpha=0.05, B=200, seed=None)
Estimate a fitted marginal odds-ratio summary across joint score levels.
The conditional outcome model is additive logistic regression. Risks are standardized over observed covariates at each joint score, then a degree-one logistic marginal structural model is fitted. Independent rows are resampled with fixed exposure cuts. Case weights and missing rows are not supported. With more than two levels, the fitted odds ratio need not equal any one adjacent-level marginal odds ratio or the conditional odds ratio.
fit_binomial_ee(y, exposures, cluster_ids, covariates=None, *, q=4, breaks=None, alpha=0.05, rr=True, weights=None)
Fit a marginal binary ratio with a cluster-summed sandwich covariance.
rr=True uses a log-risk marginal model; rr=False uses a logit
marginal model. The conditional fit is logistic in both cases. Inputs
must be complete numeric rows with binary outcomes and integer IDs.
Positive weights affect both estimating equations and cluster scores
but not exposure cuts.