% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/sg-globalsens-sim.R
\name{sg_globalsens_sim}
\alias{sg_globalsens_sim}
\title{Global sensitivity analysis via PRCC or eFAST}
\usage{
sg_globalsens_sim(
  method = c("PRCC", "eFAST"),
  model,
  params,
  par_bounds,
  n_sim,
  stimes,
  output,
  stat_comp = c("mean", "min", "max"),
  et,
  theta = NULL,
  cov = NULL
)
}
\arguments{
\item{method}{Character string. \code{"PRCC"} or \code{"eFAST"}.}

\item{model}{A model object passed to \code{sg_sim()}.}

\item{params}{Character vector of parameter names to vary.}

\item{par_bounds}{A tibble or data frame with columns \code{PAR}, \code{LB}, \code{UB}.}

\item{n_sim}{Integer. Number of samples (LHS size for PRCC, base frequency size for eFAST).}

\item{stimes}{A numeric vector of simulation times.}

\item{output}{A character vector of outputs to keep. Passed to \code{sg_sim()}.}

\item{stat_comp}{A character vector of summary statistics to compute.
Supported internally: \verb{"mean","median","min","max","sd","cmax","SS"}.}

\item{et}{An event table passed to \code{sg_sim()}.}

\item{theta}{A named numeric vector of baseline parameters. Default is \code{NULL}.
Parameters listed in \code{params} are replaced by sampled values.}

\item{cov}{Covariates passed to \code{sg_sim()}. Default is \code{NULL}.}
}
\value{
List with:
\describe{
\item{result}{Tibble containing sensitivity analysis results.
For \code{PRCC} method columns include: \code{PAR}, \code{VAR}, \code{STAT}, \code{estimate}, \code{p.value}.
For \code{eFAST} method columns include: \code{PAR}, \code{VAR}, \code{STAT}, \code{TYPE}, \code{VALUE}, \code{METHOD}.}
}

\item{summary}{
Tibble of scalar summaries used for sensitivity computation:
\code{sim.id}, \code{VAR}, \code{STAT}, \code{value}.
}

\item{design}{
Data.frame of sampled parameter values (real scale) with \code{sim.id}.
For PRCC this corresponds to LHS samples.
For eFAST this corresponds to the FAST design matrix.
}

\item{bounds}{
Parameter bounds used in the analysis.
}
}
\description{
Performs global sensitivity analysis using either PRCC (Partial Rank
Correlation Coefficients with LHS sampling) or eFAST (extended Fourier
Amplitude Sensitivity Test). For each sampled parameter set, the function
runs simulations via \code{sg_sim()}, reduces trajectories to scalar summary
statistics, and computes sensitivity indices for each output–statistic pair.
}
\examples{
\donttest{
# Example model
library(rxode2)
library(tibble)
source(system.file("extdata", "RxODE_model", "example_rxode_model.R", package = "SimuRg")) # mod_ex


# Set up event table
et_base <- tribble(
  ~id, ~time, ~evid, ~cmt, ~amt, ~addl, ~ii, ~IGFR, ~POPN,
  1,   0,     1,     1,    10,   2,     24,  112,   1
)

# Define parameter bounds
inits <- rxInits(mod_ex)
par_bounds <- tibble::tibble(
  PAR = c("POPCL", "POPVC"),
  LB  = inits[c("POPCL", "POPVC")] * (1 - 0.9),
  UB  = inits[c("POPCL", "POPVC")] * (1 + 0.9)
)

# Run eFAST sensitivity analysis
res_efast <- sg_globalsens_sim(
  method = c("eFAST"),
  model = mod_ex,
  params = c("POPCL"),
  par_bounds = par_bounds,
  n_sim = 100,
  stimes = seq(0, 168, 10),
  output = "Cc",
  cov = c("IGFR", "POPN"),
  et = et_base,
  stat_comp = c("mean")
)

# Run PRCC sensitivity analysis
res_prcc <- sg_globalsens_sim(
  method = c("PRCC"),
  model = mod_ex,
  params = c("POPCL", "POPVC"),
  par_bounds = par_bounds,
  n_sim = 100,
  stimes = seq(0, 168, 10),
  output = "Cc",
  cov = c("IGFR", "POPN"),
  et = et_base,
  stat_comp = c("mean")
)
}



}
