% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/saliva_markers.R
\name{saliva_markers}
\alias{saliva_markers}
\title{Calculate saliva-based stress & glycemic markers}
\usage{
saliva_markers(
  data,
  col_map = NULL,
  verbose = TRUE,
  na_action = c("keep", "omit", "error"),
  na_warn_prop = 0.2,
  times = c(0, 30, 60)
)
}
\arguments{
\item{data}{A data.frame or tibble with salivary markers.}

\item{col_map}{Named list mapping required inputs. Defaults assume same names:
\itemize{
\item cort1   -> "saliva_cort1" (nmol/L at wake)
\item cort2   -> "saliva_cort2" (nmol/L ~30 min)
\item cort3   -> "saliva_cort3" (nmol/L ~60 min)
\item amylase -> "saliva_amylase" (U/mL)
\item glucose -> "saliva_glucose" (mg/dL)
}}

\item{verbose}{Logical; if \code{TRUE} (default), prints column mapping, input
availability, physiological range information (informational only, values
not altered), the list of markers being computed with their inputs, and a
per-column results summary.}

\item{na_action}{One of \code{c("keep","omit","error")} for required-input NA handling. Default "keep".}

\item{na_warn_prop}{Proportion \eqn{[0,1]} to trigger high-missingness diagnostics (debug). Default 0.2.}

\item{times}{Numeric vector of sampling times (minutes) for CAR AUC. Must align with cort1/2/3. Default c(0,30,60).}
}
\value{
A tibble with columns:
\itemize{
\item \code{log_cortisol_wake}
\item \code{CAR_AUC}
\item \code{log_amylase}
\item \code{saliva_glucose}
}

If an ID column is detected in \code{data} (e.g. \code{id}, \code{IID}, \code{participant_id}),
it is prepended as the first output column.
}
\description{
Computes:
\itemize{
\item log_cortisol_wake (log-transformed waking cortisol)
\item CAR_AUC           (Cortisol Awakening Response, trapezoidal AUC over 0-60 min by default)
\item log_amylase       (log-transformed salivary alpha-amylase)
\item saliva_glucose    (raw salivary glucose)
}
}
\details{
Inputs are validated, missingness handled via \code{na_action}, logs made safe
(<= 0 -> NA), and optional extremes scan/cap is available.
}
\note{
\code{log_cortisol_wake} and \code{log_amylase} use the \strong{natural logarithm} (\code{log()}).
\code{CAR_AUC} is the trapezoidal area under the cortisol-time curve (Pruessner
et al. 2003, AUC with respect to ground). \code{saliva_glucose} is a
\strong{pass-through} column; no formula is applied.
}
\examples{
df <- tibble::tibble(
  saliva_cort1    = 12.5,
  saliva_cort2    = 18.0,
  saliva_cort3    = 16.2,
  saliva_amylase  = 85,
  saliva_glucose  = 4.2
)
saliva_markers(df)  # uses default col_map

}
\references{
\insertRef{pruessner2003auc}{HealthMarkers}
\insertRef{kirschbaum1994cortisol}{HealthMarkers} (salivary cortisol methods; background)
\insertRef{clow2004car}{HealthMarkers} (CAR methodological review; background)
\insertRef{nater2009amylase}{HealthMarkers} (salivary alpha-amylase SNS biomarker; background)
\insertRef{scales1987salgluc}{HealthMarkers} (salivary glucose application; pass-through, no formula)
}
