% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/amoroso.R
\name{amoroso_mixgpd}
\alias{amoroso_mixgpd}
\alias{dAmorosoMixGpd}
\alias{pAmorosoMixGpd}
\alias{rAmorosoMixGpd}
\alias{qAmorosoMixGpd}
\title{Amoroso mixture with a GPD tail}
\usage{
dAmorosoMixGpd(
  x,
  w,
  loc,
  scale,
  shape1,
  shape2,
  threshold,
  tail_scale,
  tail_shape,
  log = 0
)

pAmorosoMixGpd(
  q,
  w,
  loc,
  scale,
  shape1,
  shape2,
  threshold,
  tail_scale,
  tail_shape,
  lower.tail = 1,
  log.p = 0
)

rAmorosoMixGpd(
  n,
  w,
  loc,
  scale,
  shape1,
  shape2,
  threshold,
  tail_scale,
  tail_shape
)

qAmorosoMixGpd(
  p,
  w,
  loc,
  scale,
  shape1,
  shape2,
  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}. The functions treat the weights
as non-negative and normalize them internally when needed.}

\item{loc}{Numeric vector of length \eqn{K} giving component locations.}

\item{scale}{Numeric vector of length \eqn{K} giving component scales.}

\item{shape1}{Numeric vector of length \eqn{K} giving the first Amoroso shape parameter for each component.}

\item{shape2}{Numeric vector of length \eqn{K} giving the second Amoroso shape parameter for each component.}

\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 (integer flag \code{0/1} in NIMBLE).}

\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. For portability inside NIMBLE,
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} in quantile inversion.}

\item{maxiter}{Integer maximum number of iterations for \code{stats::uniroot}.}
}
\value{
Spliced density/CDF/RNG functions return numeric scalars. \code{qAmorosoMixGpd()} returns a
numeric vector with the same length as \code{p}.
}
\description{
Spliced bulk-tail family formed by attaching a generalized Pareto tail to an Amoroso mixture
bulk. Let \eqn{F_{mix}} denote the Amoroso mixture CDF. The spliced CDF is
\eqn{F(x)=F_{mix}(x)} for \eqn{x<threshold} and
\eqn{F(x)=F_{mix}(threshold) + \left\{1-F_{mix}(threshold)\right\}G(x)} for \eqn{x\ge threshold}, where \eqn{G}
is the GPD CDF for exceedances above \code{threshold}.
}
\details{
The density, CDF, and RNG are implemented as \code{nimbleFunction}s for use in NIMBLE models.
The quantile function is an R function that uses numerical inversion in the bulk region and
the closed-form GPD quantile in the tail region.

The Amoroso mixture describes the bulk up to the threshold and the generalized Pareto describes
exceedances above it. If \eqn{F_{mix}(u)=p_u}, then the splice uses
\deqn{
f(x) =
\left\{
\begin{array}{ll}
f_{mix}(x), & x < u, \\
(1-p_u) g_{GPD}(x \mid u,\sigma_u,\xi), & x \ge u.
\end{array}
\right.
}
Bulk quantiles are computed numerically from the Amoroso mixture CDF and tail quantiles are
obtained from the GPD inverse after rescaling the tail probability.
}
\section{Functions}{
\itemize{
\item \code{dAmorosoMixGpd()}: Density Function of Amoroso Mixture Distribution with GPD Tail

\item \code{pAmorosoMixGpd()}: Cumulative Distribution Function of Amoroso Mixture Distribution with GPD Tail

\item \code{rAmorosoMixGpd()}: Random Generation for Amoroso Mixture Distribution with GPD Tail

\item \code{qAmorosoMixGpd()}: Quantile Function of Amoroso Mixture Distribution with GPD Tail

}}
\examples{
w <- c(0.60, 0.25, 0.15)
loc <- c(0, 1, 2)
scale <- c(1.0, 1.2, 1.6)
shape1 <- c(2, 4, 6)
shape2 <- c(1.0, 1.2, 1.5)
threshold <- 3
tail_scale <- 1.0
tail_shape <- 0.2

dAmorosoMixGpd(4.0, w, loc, scale, shape1, shape2,
              threshold, tail_scale, tail_shape, log = 0)
pAmorosoMixGpd(4.0, w, loc, scale, shape1, shape2,
              threshold, tail_scale, tail_shape, lower.tail = 1, log.p = 0)
qAmorosoMixGpd(0.50, w, loc, scale, shape1, shape2,
              threshold, tail_scale, tail_shape)
qAmorosoMixGpd(0.95, w, loc, scale, shape1, shape2,
              threshold, tail_scale, tail_shape)
replicate(10, rAmorosoMixGpd(1, w, loc, scale, shape1, shape2,
                            threshold, tail_scale, tail_shape))
}
\seealso{
\code{\link[=amoroso_mix]{amoroso_mix()}}, \code{\link[=amoroso_gpd]{amoroso_gpd()}}, \code{\link[=gpd]{gpd()}}, \code{\link[=amoroso_lowercase]{amoroso_lowercase()}}, \code{\link[=dpmgpd]{dpmgpd()}}.

Other amoroso kernel families: 
\code{\link{amoroso_gpd}},
\code{\link{amoroso_mix}}
}
\concept{amoroso kernel families}
