
Beta Regression Inference for Proportion Responses
Source:R/inference_proportion_beta.R
InferencePropBetaRegr.RdFits Ferrari and Cribari-Neto's (2004) beta regression for proportion
responses \(Y_i \in (0, 1)\): \(\mathrm{logit}(E[Y_i \mid w_i, x_i]) =
\beta_0 + \beta_T w_i + x_i^\top \gamma\), \(Y_i \mid w_i, x_i \sim
\mathrm{Beta}(\mu_i \phi, (1-\mu_i)\phi)\) for fitted mean \(\mu_i\) and a
single (constant, not covariate-dependent) precision parameter \(\phi\),
by maximum likelihood (fast_beta_regression_cpp/
fast_beta_regression_weighted_cpp). \(\hat\beta_T\) is a
log-odds-ratio on the conditional-mean scale: \(\exp(\hat\beta_T)\) is
the odds ratio for the expected proportion. Unlike
InferencePropFractionalLogit's
quasi-likelihood (which specifies only the conditional mean), beta
regression also specifies the conditional variance/shape via \(\phi\) —
a correctly specified beta model yields a fully efficient likelihood-based
fit and genuine likelihood-ratio/score/gradient tests, at the cost of
requiring the beta-distribution shape assumption to actually hold.
likelihood_tier = "full": likelihood-ratio, score, gradient, and
Wald tests are all available when the model converges, plus
parametric-likelihood-bootstrap calibration of the likelihood-ratio test.
\(Y_i\) values of exactly 0 or 1 are not supported by the beta density
and are handled by sanitize_beta_response()'s boundary adjustment
before fitting.
Estimand. Composes
MarginalEstimand
(set_estimand()/get_estimand()/get_supported_estimands()).
Under the default estimand = "conditional", \(\hat\beta_T\) is the
log-odds-ratio above. Under estimand = "marginal_mean_diff", the
reported quantity is instead the g-computation marginal mean difference
\(\frac{1}{n}\sum_i \{\mathrm{plogis}(\hat\beta_0 + \hat\beta_T +
X_i^\top \hat\gamma) - \mathrm{plogis}(\hat\beta_0 + X_i^\top
\hat\gamma)\}\) (the precision parameter \(\phi\) does not enter the
mean, so it plays no role in this functional). Only
"marginal_mean_diff" is supported — a ratio of two mean
proportions, both bounded in \([0,1]\), is not the standard estimand
for a beta-regression treatment effect the way a rate ratio is for count
data. Because there is no latent submodel for this family (unlike e.g.
InferencePropZeroOneInflatedBetaRegr's
zero/one-inflation mixture), the marginal mean function is exactly the
model's own fitted mean; no separate standardization step beyond the
g-computation average is needed. Standard errors under the marginal
estimand use the delta method against the mean-submodel coefficient
covariance (degrees of freedom Inf); testing_type is
restricted to "wald" whenever the estimand is non-conditional. The
underlying model fit is identical regardless of estimand — switching
estimand is a pure post-fit transform, never a refit.
References
Ferrari, S., and Cribari-Neto, F. (2004). "Beta regression for modelling rates and proportions." Journal of Applied Statistics, 31(7), 799-815, doi:10.1080/0266476042000214501 .
See also
InferencePropFractionalLogit
for a quasi-likelihood proportion model that specifies only the
conditional mean. Comparable Python API: no direct beta-regression
equivalent in statsmodels; see
statsmodels GLM for
the general exponential-family GLM framework. See also:
Beta
distribution (Wikipedia).
Super class
Inference -> InferencePropBetaRegr
Methods
+ inherited public methods from Inference
Inference$capabilities()Inference$compute_exact_confidence_interval()Inference$compute_exact_two_sided_pval_for_treatment_effect()Inference$duplicate()Inference$get_analysis_data()Inference$get_covariates()Inference$get_design_object()Inference$get_model_formula()Inference$get_nonestimable_reason()Inference$get_nonestimable_stage()Inference$get_optimization_alg()Inference$get_response()Inference$get_response_type()Inference$get_treatment()Inference$is_nonestimable()Inference$set_optimization_alg()Inference$set_seed()Inference$supports()
InferencePropBetaRegr$new()
Initialize inference for the beta regression model
\(\mathrm{logit}(E[Y_i \mid w_i, x_i]) = \beta_0 + \beta_T w_i +
x_i^\top \gamma\), \(Y_i \sim \mathrm{Beta}(\mu_i \phi, (1-\mu_i)
\phi)\); see
InferencePropBetaRegr for the
model form. Does not fit the model; the fit is deferred to the first
call to compute_estimate() or a method that requires it.
Usage
InferencePropBetaRegr$new(
des_obj,
model_formula = NULL,
verbose = FALSE,
smart_cold_start_default = NULL,
optimization_alg = NULL
)Arguments
des_objA completed
Designobject with a proportion response.model_formulaOptional formula for covariate adjustment. If
NULL(default), the formula from the design object is used and its pre-computed design matrix is reused. If a formula is provided, a new design matrix is constructed from the design's imputed covariates.verboseWhether to print progress messages.
smart_cold_start_defaultWhether to use smart cold start values by default.
optimization_algCharacter scalar specifying the optimization algorithm. Default is dispatched via policy.
InferencePropBetaRegr$compute_estimate()
Fits the beta regression model by maximum likelihood
(jointly estimating the mean coefficients and the precision parameter
\(\phi\)). Under the default estimand = "conditional",
returns the log-odds-ratio estimate \(\hat\beta_T\) on the
conditional-mean scale. Under estimand = "marginal_mean_diff"
(set via set_estimand()), returns the g-computation
marginal mean difference instead — see the class-level
@details for the formula. The underlying model fit is
identical either way (a pure post-fit transform of the same
cached fit, no refit).
InferencePropBetaRegr$compute_asymp_confidence_interval()
Wald confidence interval, dispatched by
testing_type for the conditional estimand (score/gradient/
likelihood-ratio/Bartlett available; see
InferenceAsympLik); under a
marginal estimand testing_type is always "wald" (the
only value set_estimand() permits there), so this always
resolves to the delta-method interval. Calls
self$compute_estimate() first (not private$shared()
directly) so the estimand-aware cache is always current
regardless of call order.
InferencePropBetaRegr$compute_asymp_two_sided_pval()
Wald two-sided p-value, dispatched by
testing_type exactly as
compute_asymp_confidence_interval(); see that method's
description for the marginal-estimand always-Wald note.
InferencePropBetaRegr$compute_estimate_with_bootstrap_weights()
Refits the beta model with subject/block-level weights
applied to the fitting log-likelihood (Bayesian-bootstrap or
nonparametric-bootstrap draw weights, expanded to row level via
private$expand_subject_or_block_weights_to_row_weights()) via
fast_beta_regression_weighted_cpp, and returns the
reweighted estimate \(\hat\beta_T^{(w)}\). Uses the same QR
column-dropping hardening as compute_estimate(); a
hardened-but-still-unreasonable fit is cached as nonestimable.
Examples
# \donttest{
seq_des = DesignSeqOneByOneBernoulli$new(n = 10, response_type = 'proportion')
for (i in 1:10) {
seq_des$add_one_subject_to_experiment_and_assign(data.frame(x1 = rnorm(1)))
}
seq_des$add_all_subject_responses(runif(10))
inf = InferencePropBetaRegr$new(seq_des)
inf$compute_estimate()
#> [1] -0.1292731
# }