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(
  modelDF,
  model_strategy,
  lod,
  response,
  sample_template,
  borrow_method = c("sigma", "vcov"),
  df_method = c("observed", "borrowed")
)

Arguments

modelDF

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

Value

modified modelDF with imputed models replacing failed/singular ones