% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/functional_resistance.R
\name{functional_resistance}
\alias{functional_resistance}
\title{Compute functional resistance and stability-adjusted functional resistance}
\usage{
functional_resistance(
  object,
  instability = NULL,
  reference,
  lambda = 1,
  method = c("positive_area", "l2_difference"),
  scale_nfi = FALSE,
  n_groups = 4,
  group_method = c("none", "quantile", "bootstrap", "clustering"),
  time_var = NULL,
  genotype_var = NULL,
  n_boot = 1000,
  ci_level = 0.95,
  clustering_method = c("hclust", "kmeans"),
  adjust_by = NULL,
  reference_within_group = FALSE,
  group_within_adjust_by = TRUE,
  ...
)
}
\arguments{
\item{object}{An object of class \code{functional_curves}.}

\item{instability}{Optional output from \code{functional_instability()}.}

\item{reference}{Character string naming the reference genotype, or a named vector if \code{reference_within_group = TRUE}.}

\item{lambda}{Numeric penalty weight for instability. Default is 1.}

\item{method}{Character string for distance method.}

\item{scale_nfi}{Logical; if \code{TRUE}, normalizes nFI to a 0-1 scale before applying penalty.}

\item{n_groups}{Integer number of classes to group into.}

\item{group_method}{Character string for the grouping method.}

\item{time_var}{Optional variable name overrides.}

\item{genotype_var}{Optional variable name overrides.}

\item{n_boot}{Integer number of bootstrap iterations.}

\item{ci_level}{Numeric confidence level for bootstrap intervals.}

\item{clustering_method}{Character string for clustering method if \code{group_method = "clustering"}.}

\item{adjust_by}{Optional character string naming a genotype-level covariate to stratify by.}

\item{reference_within_group}{Logical; if \code{TRUE}, the reference is evaluated within each \code{adjust_by} group.}

\item{group_within_adjust_by}{Logical; if \code{TRUE}, resistance classes are assigned within each \code{adjust_by} group.}

\item{...}{Additional arguments.}
}
\value{
A list with a \code{table} containing genotype, FRI, nFI, SAFRI, rank, and classes,
and optionally bootstrap results.
}
\description{
Computes a functional resistance index (FRI) relative to a reference genotype curve.
Optionally adjusts FRI by a functional instability penalty to calculate a
stability-adjusted functional resistance index (SAFRI). Supports grouping
genotypes into classes based on quantiles, clustering, or bootstrap-supported differences.
}
\examples{
\dontrun{
fr <- functional_resistance(
  fc,
  reference = "Susceptible",
  group_method = "bootstrap"
)
print(fr)
}
}
