Skip to contents

For proteins where the initial lm fit failed or produced NA coefficients, impute missing values with LOD, clamp, refit, and attach borrowed covariance.

Usage

impute_refit_singular(
  model_df,
  model_strategy,
  lod,
  response,
  sample_template,
  borrow_method = c("sigma", "vcov"),
  df_method = c("observed", "borrowed"),
  nr_children_col = NULL,
  on_misalign = c("fallback", "fail")
)

Arguments

model_df

tibble from model_analyse

model_strategy

strategy list from strategy_lm etc.

lod

numeric, limit of detection value

response

character, response column name in nested data

sample_template

data.frame with all sample/group combinations (columns matching the nested data minus the response). Used to complete proteins that are entirely missing in one or more groups.

borrow_method

"sigma" or "vcov"

df_method

"observed" uses max(n_observed - p, 1), "borrowed" uses median df from successful fits

nr_children_col

optional column name for nr_children (peptide counts); NA values in this column are filled with 1 for imputed rows so that weighted lm fits do not fail

on_misalign

passed to compute_borrowed_variance. With "fail", full covariance is borrowed from donors sharing the maximal coefficient set, without falling back to sigma borrowing.

Value

modified model_df with imputed models replacing failed/singular ones

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(), list_facades(), lookup_facade(), lr_test(), merge_contrasts_results(), new_imputed_model(), 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()