Wraps a refitted model (lm, rfit, ...) with borrowed
covariance information. S3 generics vcov(), sigma(), and df.residual()
dispatch to the borrowed values instead of the original model's, while
coef()/terms() still fall through to the wrapped fit. The wrapper is
backend-neutral: the class is prepended to whatever the refit already
carries (e.g. c("imputed_model", "lm") or
c("imputed_model", "rfit_prolfqua", "rfit")).
Usage
new_imputed_model(
model,
borrowed_vcov,
borrowed_sigma,
borrowed_df,
n_observed,
imputed_rows = NULL
)Arguments
- model
model object fitted on imputed data
- borrowed_vcov
matrix, borrowed variance-covariance matrix
- borrowed_sigma
numeric, borrowed residual standard error / scale
- borrowed_df
numeric, borrowed residual degrees of freedom
- n_observed
integer, number of non-imputed observations
- imputed_rows
logical vector identifying rows filled at the LOD
See also
Other modelling:
AnovaExtractor,
Contrasts,
ContrastsComparison,
ContrastsDEqMSFacade,
ContrastsDEqMSVoomFacade,
ContrastsFacadeBase,
ContrastsFirth,
ContrastsFirthFacade,
ContrastsHurdleFacade,
ContrastsHurdleNestedFacade,
ContrastsLMFacade,
ContrastsLMImputeFacade,
ContrastsLimma,
ContrastsLimmaFacade,
ContrastsLimmaImputeFacade,
ContrastsLimmaVoomFacade,
ContrastsLimmaVoomImputeFacade,
ContrastsLimpaFacade,
ContrastsLimpaNestedFacade,
ContrastsLmerNestedFacade,
ContrastsModerated,
ContrastsModeratedDEqMS,
ContrastsPlotter,
ContrastsRLMFacade,
ContrastsROPECA,
ContrastsROPECANestedFacade,
ContrastsROPECAV2,
ContrastsROPECAV2NestedFacade,
ContrastsRfitFacade,
ContrastsRfitImputeFacade,
ContrastsTable,
INTERNAL_FUNCTIONS_BY_FAMILY,
Model,
ModelFirth,
ModelLimma,
StrategyLM,
StrategyLimma,
StrategyLimpa,
StrategyLmer,
StrategyLogistf,
StrategyRLM,
StrategyRfit,
build_contrast_analysis(),
build_model(),
build_model_glm_protein(),
build_model_impute(),
build_model_limma(),
build_model_limma_impute(),
build_model_limma_voom(),
build_model_limma_voom_impute(),
build_model_limpa(),
compute_borrowed_variance(),
compute_borrowed_variance_limma(),
df.residual.rfit_prolfqua(),
group_label(),
impute_from_model(),
impute_refit_singular(),
list_facades(),
lookup_facade(),
lr_test(),
merge_contrasts_results(),
nobs.rfit_prolfqua(),
pivot_model_contrasts_to_wide(),
prolfqua_analysis_methods,
register_facade(),
sigma.rfit_prolfqua(),
strategy_limma(),
strategy_limpa(),
strategy_logistf(),
vcov.rfit_prolfqua()
Examples
# Fit a normal lm, then wrap it with borrowed covariance
dat <- data.frame(group_ = rep(c("A", "B"), each = 4),
y = c(20.1, 20.5, 19.8, 20.3, 22.1, 22.4, 21.9, 22.2))
fit <- lm(y ~ group_, data = dat)
# Wrap with borrowed variance (in practice these come from donor pool)
wrapped <- prolfqua:::new_imputed_model(fit,
borrowed_vcov = vcov(fit),
borrowed_sigma = 0.8,
borrowed_df = 6,
n_observed = 5)
# S3 dispatch returns borrowed values
stopifnot(inherits(wrapped, "imputed_model"))
stopifnot(sigma(wrapped) == 0.8)
stopifnot(df.residual(wrapped) == 6)
# coefficients() still dispatches to underlying lm
stopifnot(identical(coefficients(wrapped), coefficients(fit)))