% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/gamma.R
\name{gamma_mixgpd}
\alias{gamma_mixgpd}
\alias{dGammaMixGpd}
\alias{pGammaMixGpd}
\alias{rGammaMixGpd}
\alias{qGammaMixGpd}
\title{Gamma mixture with a GPD tail}
\usage{
dGammaMixGpd(x, w, shape, scale, threshold, tail_scale, tail_shape, log = 0)

pGammaMixGpd(
  q,
  w,
  shape,
  scale,
  threshold,
  tail_scale,
  tail_shape,
  lower.tail = 1,
  log.p = 0
)

rGammaMixGpd(n, w, shape, scale, threshold, tail_scale, tail_shape)

qGammaMixGpd(
  p,
  w,
  shape,
  scale,
  threshold,
  tail_scale,
  tail_shape,
  lower.tail = TRUE,
  log.p = FALSE,
  tol = 1e-10,
  maxiter = 200
)
}
\arguments{
\item{x}{Numeric scalar giving the point at which the density is evaluated.}

\item{w}{Numeric vector of mixture weights of length \eqn{K}.}

\item{shape, scale}{Numeric vectors of length \eqn{K} giving Gamma shape and scale parameters.}

\item{threshold}{Numeric scalar threshold at which the GPD tail is attached.}

\item{tail_scale}{Numeric scalar GPD scale parameter; must be positive.}

\item{tail_shape}{Numeric scalar GPD shape parameter.}

\item{log}{Logical; if \code{TRUE}, return the log-density.}

\item{q}{Numeric scalar giving the point at which the distribution function is evaluated.}

\item{lower.tail}{Logical; if \code{TRUE} (default), probabilities are \eqn{P(X \le q)}.}

\item{log.p}{Logical; if \code{TRUE}, probabilities are returned on the log scale.}

\item{n}{Integer giving the number of draws. The RNG implementation supports \code{n = 1}.}

\item{p}{Numeric scalar probability in \eqn{(0,1)} for the quantile function.}

\item{tol}{Numeric scalar tolerance passed to \code{stats::uniroot}.}

\item{maxiter}{Integer maximum number of iterations for \code{stats::uniroot}.}
}
\value{
Spliced density/CDF/RNG functions return numeric scalars. \code{qGammaMixGpd()} returns a
numeric vector with the same length as \code{p}.
}
\description{
Spliced bulk-tail family formed by attaching a generalized Pareto tail to a gamma mixture bulk.
}
\details{
The gamma mixture governs the body of the distribution up to the threshold \eqn{u}. Beyond
\eqn{u}, only the remaining survival mass is modeled by the GPD, giving
\deqn{
f(x) =
\left\{
\begin{array}{ll}
f_{mix}(x), & x < u, \\
\{1-F_{mix}(u)\} g_{GPD}(x \mid u,\sigma_u,\xi), & x \ge u.
\end{array}
\right.
}
This is the positive-support analogue of the normal and lognormal splice families. Bulk quantiles
are still found by numerical inversion, while tail quantiles use the explicit GPD inverse.
}
\section{Functions}{
\itemize{
\item \code{dGammaMixGpd()}: Gamma mixture + GPD tail density

\item \code{pGammaMixGpd()}: Gamma mixture + GPD tail distribution function

\item \code{rGammaMixGpd()}: Gamma mixture + GPD tail random generation

\item \code{qGammaMixGpd()}: Gamma mixture + GPD tail quantile function

}}
\examples{
w <- c(0.55, 0.30, 0.15)
scale <- c(1.0, 2.5, 5.0)
shape <- c(2, 4, 6)
threshold <- 3
tail_scale <- 0.9
tail_shape <- 0.2

dGammaMixGpd(4.0, w = w, scale = scale, shape = shape,
            threshold = threshold, tail_scale = tail_scale,
            tail_shape = tail_shape, log = 0)
pGammaMixGpd(4.0, w = w, scale = scale, shape = shape,
            threshold = threshold, tail_scale = tail_scale,
            tail_shape = tail_shape, lower.tail = 1, log.p = 0)
qGammaMixGpd(0.50, w = w, scale = scale, shape = shape,
            threshold = threshold, tail_scale = tail_scale,
            tail_shape = tail_shape)
qGammaMixGpd(0.95, w = w, scale = scale, shape = shape,
            threshold = threshold, tail_scale = tail_scale,
            tail_shape = tail_shape)
replicate(10, rGammaMixGpd(1, w = w, scale = scale, shape = shape,
                          threshold = threshold,
                          tail_scale = tail_scale,
                          tail_shape = tail_shape))
}
\seealso{
\code{\link[=gamma_mix]{gamma_mix()}}, \code{\link[=gamma_gpd]{gamma_gpd()}}, \code{\link[=gpd]{gpd()}}, \code{\link[=gamma_lowercase]{gamma_lowercase()}}, \code{\link[=dpmgpd]{dpmgpd()}}.

Other gamma kernel families: 
\code{\link{gamma_gpd}},
\code{\link{gamma_mix}}
}
\concept{gamma kernel families}
