Skip to contents

Return a long table of the covariance actually assembled for selected random coefficients, including cross-model blocks. This is distinct from vcov(fit), which describes uncertainty in structural regression coefficients.

Usage

repair_prediction_covariance(object)

Arguments

object

A repair() result or an assembled repair_data() object. A numerical structural failure is accepted because MLM predictions exist.

Value

A plain data frame with columns in order: id, model1, group1, term1, label1, role1, model2, group2, term2, label2, role2 (character), covariance (numeric), and source (character). There is one row per unordered pair (including the diagonal) per analyzed ID. Pairs follow the lower triangle in selected-effect order: (1,1), (2,1), (2,2), etc.; IDs within each pair follow analysis order. Mirror off-diagonal rows to reconstruct a symmetric matrix. Source is "within_model", "assumed_independent", or "supplied". The key is ID plus the two model/group/term identities.

Details

Only structural units and formula-selected random effects are included. MLM-scope cross-model covariance may not be available, so this accessor has no MLM-scope option. Observed structural columns have zero error by assumption and are not included. Within-model entries come from prediction extraction; cross-model entries reflect the explicit policy or supplied blocks. Values are conditional on fitted MLM quantities and are not posterior covariances. Extraction does not change inputs or assume new zero covariances.

Examples

data(repair_example)
growth <- lme4::lmer(score ~ day + (day | person), repair_example$repeated)
fit <- repair(re("day") ~ practice, growth, repair_example$people, "person")
head(repair_prediction_covariance(fit))
#>     id model1 group1 term1                   label1   role1 model2 group2 term2
#> 1 P001    mlm person   day re("day", model = "mlm") outcome    mlm person   day
#> 2 P002    mlm person   day re("day", model = "mlm") outcome    mlm person   day
#> 3 P003    mlm person   day re("day", model = "mlm") outcome    mlm person   day
#> 4 P004    mlm person   day re("day", model = "mlm") outcome    mlm person   day
#> 5 P005    mlm person   day re("day", model = "mlm") outcome    mlm person   day
#> 6 P006    mlm person   day re("day", model = "mlm") outcome    mlm person   day
#>                     label2   role2 covariance       source
#> 1 re("day", model = "mlm") outcome 0.01964941 within_model
#> 2 re("day", model = "mlm") outcome 0.01964941 within_model
#> 3 re("day", model = "mlm") outcome 0.05146273 within_model
#> 4 re("day", model = "mlm") outcome 0.02619921 within_model
#> 5 re("day", model = "mlm") outcome 0.01964941 within_model
#> 6 re("day", model = "mlm") outcome 0.05146273 within_model
# vcov(fit) instead describes structural coefficient uncertainty.