Skip to contents

Report plug-in posterior reliability using the manuscript's marginal and intercept-residualized definitions. These diagnostics do not change the fit.

Usage

repair_reliability(
  object,
  detail = c("summary", "unit"),
  scope = c("structural", "all"),
  type = c("both", "marginal", "residualized")
)

Arguments

object

A fitted repair() result, including a numerical structural failure.

detail

"summary" (default) gives equally weighted scope summaries; "person" gives one row per unit, selected effect, and reliability measure.

scope

"structural" (default) uses the structural analysis IDs for every model. "all" uses all effective grouping levels separately for each referenced model, including units excluded from structural analysis.

type

"both" (default), "marginal", or "residualized". Residualized reliability is available for a selected slope only in a two-coefficient random-intercept/random-slope model. Other selected effects are returned with an explicit not-applicable status when this measure is requested alone.

Value

A data frame of class repair_reliability, with model, group, selected term, structural role, measure, scope, reliability, and denominator/status columns. Person rows also include ID, effective observation count, prior and posterior variance, and a reason for undefined results. Summary rows include n_units, n_defined, n_undefined, mean_defined, and distribution summaries.

Details

For fitted random-effect covariance G and posterior covariance V_i, marginal reliability of coefficient k is 1 - V_i[k,k] / G[k,k]. Posterior covariance is computed as G - G Z_i' (R_i + Z_i G Z_i')^-1 Z_i G using fitted effective observations and target-specific residual covariance. For nested lmer models, R_i includes every nuisance-group covariance contribution, as in likelihood prediction extraction. This supports singular G without inverting G.

For a slope residualized on the intercept, the contrast is a = c(-G[1,2] / G[1,1], 1) in intercept/slope order and reliability is 1 - (a' V_i a) / (a' G a). This uses the full covariance, not just diagonals. It does not residualize on observed structural predictors or other models.

Cohort reliability is the equally weighted mean across units, matching the manuscript. If any requested unit has undefined reliability, the overall reliability is NA; mean_defined summarizes only defined values and the counts make that denominator explicit. Zero or numerically degenerate contrast variance is undefined, not zero reliability. Singular G does not itself make all marginal reliabilities undefined. Tiny boundary deviations within 1e-8 are rounded to the interval from zero to one; larger invalid values receive an explanatory status.

Posterior reliability describes uncertainty reduction under the fitted MLM. It is distinct from the likelihood-only prediction-error covariance used by REPAIR. A rank-deficient cluster can have defined posterior reliability while failing likelihood-only prediction extraction. Reliability is calculated within each MLM, without borrowing information across models or applying the cross-model prediction-error policy. It conditions on fitted parameters and supplies no confidence interval or automatic adequacy cutoff.

Examples

data(repair_example)
growth <- lme4::lmer(score ~ day + (day | person), repair_example$repeated)
fit <- repair(re("day") ~ practice, growth, repair_example$people, "person")
repair_reliability(fit)
#>   model  group term    role      measure      scope n_units n_defined
#> 1   mlm person  day outcome     marginal structural      60        60
#> 2   mlm person  day outcome residualized structural      60        60
#>   n_undefined reliability mean_defined       min    median       max status
#> 1           0   0.9433813    0.9433813 0.9120433 0.9517006 0.9709681     ok
#> 2           0   0.8967932    0.8967932 0.8515263 0.9082681 0.9383112     ok
#>   reason
#> 1       
#> 2       
head(repair_reliability(fit, detail = "unit"))
#>   model  group term    role  measure      scope   id n_observations
#> 1   mlm person  day outcome marginal structural P001             11
#> 2   mlm person  day outcome marginal structural P002             11
#> 3   mlm person  day outcome marginal structural P003              8
#> 4   mlm person  day outcome marginal structural P004             10
#> 5   mlm person  day outcome marginal structural P005             11
#> 6   mlm person  day outcome marginal structural P006              8
#>   prior_variance posterior_variance reliability status reason
#> 1      0.4613192         0.01710460   0.9629224     ok       
#> 2      0.4613192         0.01710460   0.9629224     ok       
#> 3      0.4613192         0.04057612   0.9120433     ok       
#> 4      0.4613192         0.02228145   0.9517006     ok       
#> 5      0.4613192         0.01710460   0.9629224     ok       
#> 6      0.4613192         0.04057612   0.9120433     ok