\HeaderA{GpdGlmFit}{Modelling the GPD Distribution including GLM}{GpdGlmFit}
\aliasA{gpdglmFit}{GpdGlmFit}{gpdglmFit}
\aliasA{gpdglmprofPlot}{GpdGlmFit}{gpdglmprofPlot}
\aliasA{gpdglmprofxiPlot}{GpdGlmFit}{gpdglmprofxiPlot}
\aliasA{plot.gpdglmFit}{GpdGlmFit}{plot.gpdglmFit}
\aliasA{print.gpdglmFit}{GpdGlmFit}{print.gpdglmFit}
\aliasA{summary.gpdglmFit}{GpdGlmFit}{summary.gpdglmFit}
\keyword{models}{GpdGlmFit}
\begin{Description}\relax
a collection of functions to model the Generalized 
Pareto Distribution, GPD, by maximum likelihood 
approximation based on \R's 'ismev' package. In 
addition to the function 'gpdFit' the parameter 
estimation allows to include generalized linear 
modelling, glm, of each parameter.
\\

The functions are:

\Tabular{ll}{
\code{gpdglmFit} & fits empirical or simulated data to the distribution, \\ 
\code{print} & print method for a fitted GPD object of class ..., \\
\code{plot} & plot method for a fitted GPD object, \\ 
\code{summary} & summary method for a fitted GPD object, \\     
\code{gpdglmprofPlot} & profile log-likelihoods for return levels, \\ 
\code{gpdglmprofxiPlot} & profile log-likelihoods for shape parameters. }
\end{Description}
\begin{Usage}
\begin{verbatim}
gpdglmFit(x, threshold = min(x), npy = 365, y = NULL, sigl = NULL,
    shl = NULL, siglink = identity, shlink = identity, show = FALSE,
    method = "Nelder-Mead", maxit = 10000, ...)

## S3 method for class 'gpdglmFit':
print(x, ...)
## S3 method for class 'gpdglmFit':
plot(x, which = "all", ...)
## S3 method for class 'gpdglmFit':
summary(object, doplot = TRUE, which = "all", ...)

gpdglmprofPlot(fit, m, xlow, xup, conf = 0.95, nint = 100, ...)
gpdglmprofxiPlot(fit, xlow, xup, conf = 0.95, nint = 100, ...)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{conf}] [gpdglmprof*Plot] - \\
the confidence coefficient of the plotted profile confidence 
interval.

\item[\code{doplot}] a logical. Should the results be plotted?

\item[\code{fit}] a fitted object either of class \code{"gpdglm"}.

\item[\code{m}] [gpdglmprof*Plot] - \\
the return level; i.e. the profile likelihood is for the value 
that is exceeded with probability 1/\code{m}.

\item[\code{maxit}] [gpdglmFit] - \\
the maximum number of iterations.

\item[\code{method}] [gpdglmFit] - \\
the optimization method; see \code{\LinkA{optim}{optim}} for
details.

\item[\code{nint}] [gpdglmprof*Plot] - \\
the number of points at which the profile likelihood is evaluated.

\item[\code{npy}] [gpdglmFit] - \\
the number of observations per year/block. By default 365.

\item[\code{object}] [summary] -
a fitted object of class \code{"gpdglmFit"}.

\item[\code{show}] [gpdglmFit] - \\
a logical; if \code{TRUE} (the default), print details of
the fit.

\item[\code{sigl, shl}] [gpdglmFit] - \\
numeric vectors of integers, giving the columns
of \code{ydat} that contain covariates for generalized linear
modelling of the scale and shape parameters repectively
(or \code{NULL} (the default) if the corresponding parameter is
stationary).

\item[\code{siglink, shlink}] [gpdglmFit] - \\
inverse link functions for generalized
linear modelling of the scale and shape parameters repectively.

\item[\code{threshold}] [gpdglmFit] - \\
the threshold value; a single number or a numeric
vector of the same length as \code{xdat}.

\item[\code{which}] [plot][summary] - \\
a vector of logicals, one for each plot, denoting which plot 
should be displayed. By default \code{c(TRUE, TRUE, TRUE, TRUE, 
        TRUE)}.

\item[\code{x}] A numeric vector of data to be fitted.
\\{}
[print][plot] - \\
a fitted object of class \code{"gpdglmFit"}.

\item[\code{xlow, xup}] [gpdglmprof*Plot] - \\
the least and greatest value at which to evaluate the profile 
likelihood.

\item[\code{y}] [gpdglmFit] - \\
a matrix of covariates for generalized linear modelling
of the parameters (or \code{NULL} (the default) for stationary
fitting). The number of rows should be the same as the length
of \code{xdat}.

\item[\code{...}] [gpdglmFit] - \\
other control parameters for the optimization. These are passed
to components of the \code{control} argument of \code{optim}.

\end{ldescription}
\end{Arguments}
\begin{Details}\relax
\bold{Simulation:}
\\\\
To simulate a GPD series use the function \code{gpdSim}.
\\

\bold{Parameter Estimation:}
\\\\
\code{gpdglmFit} fits by the Maximum-likelihood approach the generalized 
extreme value distribution, including generalized linear modelling 
of each parameter. 
\\

\bold{Methods:}
\\\\
\code{print.gpdglm}, \code{plot.gpdglm} and \code{summary.gpdglm} 
are print, plot, and summary methods for a fitted object of class 
\code{gpdglm}.
\\

\bold{Nonstationary Models:}
\\\\
For non-stationary fitting it is recommended that the covariates
within the generalized linear models are (at least approximately)
centered and scaled (i.e.\ the columns of \code{ydat} should be
approximately centered and scaled).
\end{Details}
\begin{Value}
A list containing the following components. A subset of these
components are printed after the fit. If \code{show} is
\code{TRUE}, then assuming that successful convergence is
indicated, the components \code{nexc}, \code{nllh},
\code{mle}, \code{rate} and \code{se} are always printed.

\begin{ldescription}
\item[\code{trans}] An logical indicator for a non-stationary fit.

\item[\code{model}] A list with components \code{sigl} and \code{shl}.

\item[\code{link}] A character vector giving inverse link functions.

\item[\code{threshold}] The threshold, or vector of thresholds.

\item[\code{nexc}] The number of data points above the threshold.

\item[\code{data}] The data that lie above the threshold. For
non-stationary models, the data is standardized.

\item[\code{conv}] The convergence code, taken from the list returned by
\code{\LinkA{optim}{optim}}. A zero indicates successful convergence.

\item[\code{nllh}] The negative logarithm of the likelihood evaluated at
the maximum likelihood estimates.

\item[\code{vals}] A matrix with three columns containing the maximum
likelihood estimates of the scale and shape parameters, and
the threshold, at each data point.

\item[\code{mle}] A vector containing the maximum likelihood estimates.

\item[\code{rate}] The proportion of data points that lie above the
threshold.

\item[\code{cov}] he covariance matrix.

\item[\code{se}] A vector containing the standard errors.

\item[\code{n}] The number of data points (i.e.\ the length of
\code{xdat}).

\item[\code{npy}] The number of observations per year/block.

\item[\code{xdata}] The data that has been fitted.

\end{ldescription}
 

For stationary models four plots are produced; a probability
plot, a quantile plot, a return level plot and a histogram
of data with fitted density. For non-stationary models two plots 
are produced; a residual probability plot and a residual quantile 
plot.
\end{Value}
\begin{Author}\relax
Alec Stephenson for the code implemented from \R's ismev package, \\
Stuart Scott for the original code, and
Diethelm Wuertz for this \R-port.
\end{Author}
\begin{References}\relax
Coles S. (2001);
\emph{Introduction to Statistical Modelling of Extreme Values},
Springer.
\end{References}
\begin{Examples}
\begin{ExampleCode}
## SOURCE("fExtremes.54B-GpdGlmFit")

## Use Rain Data:
   data(rain)
   
## Fit GPD Model:
   xmpExtremes("Start: Parameter Estimation >")
   fit = gpdglmFit(x = rain, threshold = 10)
   print(fit)
   xmpExtremes("Next: Summary Report > ")
   
## Summarize Results:
   xmpExtremes("Next: Profile Likelihood >")
   par(mfrow = c(2, 2), cex = 0.75)
   summary(fit, which = "all")
   # Profile Lielihood:
   par(mfrow = c(2, 1), cex = 0.75)
   gpdglmprofPlot(fit, m = 10, xlow = 55, xup = 75)
   title(main = "Rain")
   gpdglmprofxiPlot(fit, xlow = -0.02, 0.15)
   title(main = "Rain")
\end{ExampleCode}
\end{Examples}

