gevreg {gevreg}R Documentation

Maximum Likelihood GEV Fitting

Description

Fit a GEV distribution to observations using maximum likelihood.

Usage

gevreg(formula, data, subset, na.action,
  model = TRUE, y = TRUE, x = FALSE, z = FALSE, v = FALSE,
  control = gevreg_control(...), ...)

gevreg_fit(x, y, z = NULL, v = NULL, n.stats, control)

gevreg_control(maxit = 5000, start = NULL, grad = TRUE, hessian = TRUE, ...)

Arguments

formula

a formula expression of the form y ~ x | z | v where y is the response and x, z and v are regressor variables for the location, scale and shape parameters of the Generalized Extreme value Distribution (GEV). For details how to set up the formula see details and Formula

.

data

a data frame containing the covariables used to fit the respons(es). Variables in the formula must occur as column name in data. A column named station is mandatory.

subset

an optional vector specifying a subset of observations to be used for fitting.

na.action

a function which indicates what should happen when the data contain NAs.

model

logical. If TRUE model frame is included as a component of the returned value.

x, y, z, v

for gevreg: logical. If TRUE the model matrix and response matrix used for fitting are returned as part of the returned gevreg object. For gevreg.fit: x, z, v are design matrices with regressors for the location, scale and shape parameters of the GEV and y is a vector of observed parameters.

...

arguments to be used to form the default control argument if it is not supplied directly.

control, maxit, start

a list of control parameters passed to optim .

n.stats

number of stations that have to be fitted simultaneously.

grad

should the gradient-based method "BFGS" used for optimization. If FALSE "Nelder-Mead" is used instead.

hessian

should a hessian be computed during the optimaztion process. Possible values are "none", "numderiv" or "optim", which is the default.

Details

gevreg Fit a GEV distribution simultaneously to a number of observation sites. The response y on the left-hand-side (LHS) of the formula must be available in the data data.frame. The right-hand-side (RHS) of the formual can consist of one, two or three parts, separated by a "|". If only one part is given it is supposed to be the regressor for the location parameter of the GEV distribution. The scale and shape parameter are extended to a regressor of 1. If the formula contains two parts, they are considered as the regressors for the location and scale parameter (from left to right). The formula is then extended to a shape regressor of 1.

gevreg_fit is the lower level function which provides the actual maximum likelihood fitting.

gevreg_control takes control parameters e.g. maxit which are transferred to optim. In addition grad specifies wether a gradient based optimization routine ("BFGS") or "Nelder-Mead" should be used for optimization. In the former case the gradient will be computed with the grad function.

Value

An object of class gevreg which inherits from optim with components:

coefficients

Either all, or if specified e.g. as location, scale or shape the coefficients of the fitted model for the three GEV parameters for al stations are returned.

loglik

The maximised log-likelihood value.

vcov

returns the variance-covariance matrix as the generic function vcov does.

x, y, z,v

If TRUE in the call the model matrix and response matrix used for fitting are returned.

References

Blanchet J, Lehning M (2010). Mapping snow depth return levels: smooth spatial modeling versus station interpolation. Hydrol. Earth Syst. Sci., 14, 2527–2544. https://www.hydrol-earth-syst-sci.net/14/2527/2010/hess-14-2527-2010.pdf.

Examples

data("gevregdata")

## Fit GEV to the snow depths of the first station in the dataset
gevreg(hs~station,gevregdata)

## Use Nelder-Mead as optmization method
gevreg(hs~station,gevregdata,grad=FALSE)

## Compute hessian afterwards with the grad function of the numDeriv package
m <- gevreg(hs~station,gevregdata,grad=FALSE,hessian="numderiv",maxit=6000)
print(m, ext = TRUE)

## check some S3-Methods
m <- gevreg(hs~station,gevregdata)
vcov(m,model="l")
m$vcov
coef(m)
coef(m, model="shape")
logLik(m)



[Package gevreg version 0.1-2 Index]