# Comparing fitted predmicror models

This vignette shows a compact workflow for comparing alternative predictive microbiology models with the `predmicror_fit` interface.

## Fit candidate models

    library(predmicror)

    data(growthfull)

    huang <- fit_growth(
      growthfull,
      model = "HuangFM",
      time = "Time",
      response = "lnN",
      start = list(Y0 = 0, Ymax = 22, MUmax = 1.7, lag = 5)
    )

    baranyi <- fit_growth(
      growthfull,
      model = "BaranyiFM",
      time = "Time",
      response = "lnN",
      start = list(Y0 = 0, Ymax = 22, MUmax = 1.7, lag = 5)
    )

## Extract fitted values and residuals

    head(predmicror_augment(huang))

The returned data frame keeps the original columns and adds:

- `.fitted`: predicted response on the fitted response scale;
- `.resid`: observed minus fitted response, when the response column is available;
- `.model`: fitted model name;
- `.type`: model family.

## Calculate diagnostics for one model

    fit_metrics(huang)

`fit_metrics()` reports residual and information-criterion diagnostics on the response scale used for fitting.

## Compare models

    compare_models(
      huang = huang,
      baranyi = baranyi,
      sort_by = "AIC"
    )

For models fitted to the same response variable and dataset, lower AIC, BIC, RMSE, and MAE values usually indicate a better fit. These criteria should be interpreted together with residual plots, biological plausibility, and parameter uncertainty.