group_mm: Fit Multiple Michaelis-Menten Curves by Group

View source: R/grouped.R

group_mmR Documentation

Fit Multiple Michaelis-Menten Curves by Group

Description

Clean a data frame, fit one or more working variance models within each group, and compare the competing fits using quasi-AIC as the primary criterion, with quasi-BIC and RMSE reported alongside it.

Usage

group_mm(data, s, v, groups = NULL,
  variance_models = default_variance_models(), power_values = NULL,
  include_auto = FALSE, power_selection = c("quasi_aic", "quasi_bic"),
  power_grid = default_power_grid(), interval_level = 0.95,
  invalid_response_values = c(-9999),
  invalid_substrate_values = numeric(0), allow_zero_substrate = TRUE,
  sort_x = TRUE, quiet = FALSE, variance_functions = NULL)

## S3 method for class 'group_mm'
print(x,
  digits = max(3L, getOption("digits") - 2L), ...)

## S3 method for class 'group_mm'
plot(x, which_groups = NULL, model = NULL,
  interval = TRUE, interval_type = c("prediction", "confidence"),
  level = NULL, ncol = NULL, main = NULL,
  xlab = "Substrate concentration", ylab = "Reaction velocity", ...)

Arguments

data

A data frame containing Michaelis-Menten observations.

s

Name of the substrate concentration column.

v

Name of the response column.

groups

Optional character vector of grouping columns.

variance_models

Character vector of built-in variance models. The special value "auto" adds a candidate that compares log(S + 1) with a grid of power functions and keeps the better fit.

power_values

Optional numeric vector of fixed exponents for additional S^power candidates.

include_auto

Logical; if TRUE, add one automatic candidate that selects between log(S + 1) and the supplied power_grid.

power_selection

Criterion used by the automatic candidate: "quasi_aic" or "quasi_bic".

power_grid

Candidate exponents used by the automatic candidate.

interval_level

Confidence level forwarded to fit_mm.

invalid_response_values

Values to remove before fitting.

invalid_substrate_values

Values to remove before fitting.

allow_zero_substrate

Logical; if FALSE, substrate concentrations must be strictly positive.

sort_x

Logical; sort observations within each group by concentration.

quiet

Logical; if TRUE, suppress progress messages.

variance_functions

Optional named list of fixed, vectorized positive functions h(S), forwarded to screen_mm within every group. Use variance_models = character(0) for custom-only comparisons.

x

A grouped fit object for the print and plot methods.

which_groups

Optional subset of groups to plot, matched against group_id or group_label.

model

Optional model name to use for every group. When NULL, the plotting method uses the best model recorded for each group.

interval

Logical; if TRUE, add interval bands to each panel.

interval_type

Either "prediction" or "confidence".

level

Optional interval level. Defaults to the level stored in each fit.

ncol

Optional number of panel columns in the grouped display.

main

Optional panel title or titles.

xlab

Label for the x-axis.

ylab

Label for the y-axis.

digits

Number of printed digits.

...

Additional arguments passed to S3 methods.

Details

Custom variance functions use the same definition in every group and must obey the contract in variance_function. Group-specific scales are estimated, but shape parameters in the functions are treated as fixed. Ranking criteria and intervals omit uncertainty from external shape estimation or model selection. This is a set of separate single-curve fits, not a clustered model.

Value

An object of class "group_mm" containing cleaned data, fit summaries, augmented residual output, grouped rankings, and fitted objects.

Examples

grouped <- group_mm(
  data = sdl_demo,
  s = "s_uM",
  v = "v_uM_per_min",
  groups = "enzyme",
  variance_models = c("constant", "sqrt"),
  power_values = 0.4,
  include_auto = TRUE,
  quiet = TRUE
)

grouped
head(
  grouped$comparison$best_by_group[
    ,
    c("group_label", "model", "selected_model", "quasi_aic", "quasi_bic", "rmse")
  ]
)

plot(grouped, interval_type = "confidence")

inferMM documentation built on Oct. 30, 2026, 9:06 a.m.