evgam: Fitting generalised additive extreme-value family models

View source: R/generic.R

evgamR Documentation

Fitting generalised additive extreme-value family models

Description

Function evgam fits generalised additive extreme-value models. It allows the fitting of various extreme-value models, including the generalised extreme value and Pareto distributions. It can also perform quantile regression via the asymmetric Laplace distribution.

Usage

evgam(
  formula,
  data,
  family = "gev",
  correctV = TRUE,
  rho0,
  inits = NULL,
  outer = NULL,
  control = evgam.control(),
  removeData = FALSE,
  trace = 0,
  knots = NULL,
  maxdata = 1e+20,
  maxspline = 1e+20,
  compact = FALSE,
  gpd.args = list(),
  ald.args = list(),
  exi.args = list(),
  pp.args = list(),
  bgev.args = list(),
  sandwich.args = list(),
  egpd.args = list(),
  custom.fns = list(),
  sp = NULL,
  gamma = 1,
  sparse = FALSE,
  args = list(),
  jitter = TRUE
)

Arguments

formula

a list of formulae for location, scale and shape parameters, as in gam

data

a data frame

family

a character string giving the type of family to be fitted; defaults to "gev"

correctV

logical: should the variance-covariance matrix include smoothing parameter uncertainty? Defaults to TRUE

rho0

a scalar or vector of initial log smoothing parameter values; a scalar will be repeated if there are multiple smoothing terms

inits

a vector or list giving initial values for constant basis coefficients; if a list, a grid is formed using expand.grid, and the ‘best’ used; defaults to NULL, so initial values are automatically found

outer

a character string specifying the outer optimiser is full "Newton", "BFGS" or uses finite differences, "FD"; defaults to "BFGS"

control

a list of lists of control parameters to pass to inner and outer optimisers; defaults to evgam.control()

removeData

logical: should data be removed from evgam object? Defaults to FALSE

trace

an integer specifying the amount of information supplied about fitting, with -1 suppressing all output; defaults to 0

knots

passed to s; defaults to NULL

maxdata

an integer specifying the maximum number of data rows. data is sampled if its number of rows exceeds maxdata; defaults to 1e20

maxspline

an integer specifying the maximum number of data rows used for spline construction; defaults to 1e20

compact

logical: should duplicated data rows be compacted? Defaults to FALSE

gpd.args

a list of arguments for family="gpd"; see Details

ald.args

a list of arguments for family="ald"; see Details

exi.args

a list of arguments for family="exi"; see Details

pp.args

a list of arguments for family="pp"; see Details

bgev.args

a list of arguments for family="bgev"; see Details

sandwich.args

a list of arguments for sandwich adjustment; see Details

egpd.args

a list of arguments for extended GPD; see Details

custom.fns

a list of functions for a custom family; see Details

sp

a vector of fixed smoothing parameters

gamma

a total penalty adjustment, such that higher values (>1) give smoother overall fits; defaults to 1 (no adjustment)

sparse

logical: should matrices be coerced to be recognised as sparse? Defaults to FALSE

args

a list of arguments to supply to the likelihood. Default to none, which is list()

jitter

logical: should initial rho values be jittered before they're optimized? Defaults to TRUE

Details

See family.evgam for details of distributions that can be fitted with evgam using family = "..." and details of gpd.args, ald.args, exi.args, pp.args, bgev.args and egpd.args and see custom.family.evgam for details of using family = "custom" with custom.fns.

Arguments for the sandwich adjustment are given by sandwich.args. A character string id can be supplied to the list, which identifies the name of the variable in data such that independence will be assumed between its values. The method for the adjustment is supplied as "magnitude" (default) or "curvature"; see Chandler & Bate (2007) for their definitions.

Value

An object of class evgam

References

Chandler, R. E., & Bate, S. (2007). Inference for clustered data using the independence loglikelihood. Biometrika, 94(1), 167-183.

Wood, S. N., Pya, N., & Safken, B. (2016). Smoothing parameter and model selection for general smooth models. Journal of the American Statistical Association, 111(516), 1548-1563.

Youngman, B. D. (2022). evgam: An R Package for Generalized Additive Extreme Value Models. Journal of Statistical Software. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.18637/jss.v103.i03")}

See Also

predict.evgam

Examples


data(fremantle)
fmla_gev <- list(SeaLevel ~ s(Year, k=5, bs="cr"), ~ 1, ~ 1)
m_gev <- evgam(fmla_gev, fremantle, family = "gev")



data(COprcp)

## fit generalised Pareto distribution to excesses on 20mm

COprcp <- cbind(COprcp, COprcp_meta[COprcp$meta_row,])
threshold <- 20
COprcp$excess <- COprcp$prcp - threshold
COprcp_gpd <- subset(COprcp, excess > 0)
fmla_gpd <- list(excess ~ s(lon, lat, k=12) + s(elev, k=5, bs="cr"), ~ 1)
m_gpd <- evgam(fmla_gpd, data=COprcp_gpd, family="gpd")

## fit generalised extreme value distribution to annual maxima

COprcp$year <- format(COprcp$date, "%Y")
COprcp_gev <- aggregate(prcp ~ year + meta_row, COprcp, max)
COprcp_gev <- cbind(COprcp_gev, COprcp_meta[COprcp_gev$meta_row,])
fmla_gev2 <- list(prcp ~ s(lon, lat, k=30) + s(elev, bs="cr"), ~ s(lon, lat, k=20), ~ 1)
m_gev2 <- evgam(fmla_gev2, data=COprcp_gev, family="gev")
summary(m_gev2)
plot(m_gev2)
predict(m_gev2, newdata=COprcp_meta, type="response")

## fit point process model using r-largest order statistics

# we have `ny=30' years' data and use top 45 order statistics
pp_args <- list(id="id", ny=30, r=45)
m_pp <- evgam(fmla_gev2, COprcp, family="pp", args=pp_args)

## estimate 0.98 quantile using asymmetric Laplace distribution

fmla_ald <- prcp ~ s(lon, lat, k=15) + s(elev, bs="cr")
m_ald <- evgam(fmla_ald, COprcp, family="ald", args=list(tau=.98))




evgam documentation built on Sept. 3, 2026, 5:09 p.m.