| Title: | Exponential Factor Copula Model |
|---|---|
| Description: | Implements the exponential Factor Copula Model (eFCM) of Castro-Camilo, D. and Huser, R. (2020) for spatial extremes, with tools for dependence estimation, tail inference, and visualization. The package supports likelihood-based inference, Gaussian process modeling via Matérn covariance functions, and bootstrap uncertainty quantification. See Castro-Camilo and Huser (2020) <doi:10.1080/01621459.2019.1647842>. |
| Authors: | Mengran Li [aut, cre], Daniela Castro-Camilo [aut] |
| Maintainer: | Mengran Li <[email protected]> |
| License: | GPL (>= 3) |
| Version: | 1.0 |
| Built: | 2026-05-07 07:53:31 UTC |
| Source: | https://github.com/cran/eFCM |
Implements the exponential Factor Copula Model (eFCM) of Castro-Camilo and Huser (2020) for spatial extremes, with tools for dependence estimation, tail inference,and visualization. The package supports likelihood-based inference, Gaussian process modeling via Matérn covariance functions, and bootstrap uncertainty quantification.
Castro-Camilo, D. & Huser, R. (2020). Local likelihood estimation of complex tail dependence structures, with application to U.S. precipitation extremes. Journal of the American Statistical Association, 115(531), 1037–1054. doi:10.1080/01621459.2019.1611584
Li, M. & Castro-Camilo, D. (2025). On the importance of tail assumptions in climate extreme event attribution. arXiv. doi:10.48550/arXiv.2507.14019
Compute the AIC value for a fitted fcm model using the formula:
where is the likelihood, is the number of parameters, and is a penalty parameter.
## S3 method for class 'fcm' AIC(object, ..., k = 2)## S3 method for class 'fcm' AIC(object, ..., k = 2)
object |
An object of class |
... |
Currently unused. |
k |
Penalty per parameter (default is |
A numeric scalar giving the AIC value for the fitted model.
logLik.fcm(), BIC.fcm(), AICc.fcm()
Compute the AICc value for a fitted fcm model using the formula:
where is the number of observations and is the number of parameters.
AICc(object, ...) ## S3 method for class 'fcm' AICc(object, ...)AICc(object, ...) ## S3 method for class 'fcm' AICc(object, ...)
object |
An object of class |
... |
Currently unused. |
A numeric scalar giving the AICc value for the fitted model.
Compute the BIC value for a fitted fcm model using the formula:
where is the number of observations and is the number of parameters.
## S3 method for class 'fcm' BIC(object, ...)## S3 method for class 'fcm' BIC(object, ...)
object |
An object of class |
... |
Currently unused. |
A numeric scalar giving the BIC value for the fitted model.
An example dataset stored as an object of class "fdata",
suitable for direct use with fcm
data(cf_data)data(cf_data)
An object of class "fdata"
data(cf_data) dim(cf_data)data(cf_data) dim(cf_data)
Compute the conditional exceedance probability ,
either from a fitted eFCM model (chi.fcm) or empirically (Echi).
measures the probability of simultaneous exceedances at high but finite thresholds.
## S3 method for class 'fcm' chi(object, h, u = 0.95, ...) Echi(object, which = c(1, 2), u = 0.95)## S3 method for class 'fcm' chi(object, h, u = 0.95, ...) Echi(object, which = c(1, 2), u = 0.95)
object |
an object of class |
h |
a positive numeric value representing the spatial distance (in kilometers). |
u |
a numeric value between 0 and 1 specifying the quantile threshold. Default is 0.95. |
... |
currently ignored. |
which |
A length-two integer vector giving the indices of the
columns in |
For two locations and separated by distance ,
with respective vector components and ,
the conditional exceedance probability is defined as
For the eFCM, the conditional exceedance probability
can be computed as
Here, is the marginal quantile function,
denotes the bivariate standard normal CDF with correlation ,
, and is the correlation matrix.
A named numeric value, the chi statistic for given h and u.
chi.fcm(): Model-based estimate from an object of class "fcm".
Echi(): Empirical estimate.
Castro-Camilo, D. and Huser, R. (2020). Local likelihood estimation of complex tail dependence structures, applied to US precipitation extremes. Journal of the American Statistical Association, 115(531), 1037–1054.
fit <- fcm(...) chi(fit, h = 150, u = 0.95)fit <- fcm(...) chi(fit, h = 150, u = 0.95)
Plots the eFCM conditional exceedance probability .
## S3 method for class 'fcm' chiplot( object, h = NULL, method = c("default", "hessian", "boot"), ci = 0.95, emp = TRUE, which = c(1, 2), ... ) chiplot(object, ...)## S3 method for class 'fcm' chiplot( object, h = NULL, method = c("default", "hessian", "boot"), ci = 0.95, emp = TRUE, which = c(1, 2), ... ) chiplot(object, ...)
object |
An object of class |
h |
A positive numeric distance in kilometers. If |
method |
Character. Method for computing confidence intervals. One of |
ci |
Confidence level for interval estimation. |
emp |
Logical. Whether to add empirical chi estimates. |
which |
Integer vector of length 2. Locations to compute empirical chi. |
... |
Further arguments passed to base plotting functions (e.g., |
A (invisible) list containing chi estimates and confidence bounds:
Estimated chi values.
Lower confidence bounds (if applicable).
Upper confidence bounds (if applicable).
Empirical chi curve (if emp = TRUE).
Distance used.
Castro-Camilo, D. and Huser, R. (2020). Local likelihood estimation of complex tail dependence structures, applied to US precipitation extremes. Journal of the American Statistical Association, 115(531), 1037–1054.
Extract estimated model parameters from objects returned by fcm().
Optionally computes confidence intervals via either the observed Hessian
(Delta method, on the log scale) or bootstrap sampling.
## S3 method for class 'fcm' coef(object, ..., method = c("default", "hessian", "boot"), ci = 0.95)## S3 method for class 'fcm' coef(object, ..., method = c("default", "hessian", "boot"), ci = 0.95)
object |
An object of class |
... |
Further arguments passed to or from other methods. |
method |
Character string specifying the method used to compute confidence intervals.
One of |
ci |
Confidence level for the interval estimation (e.g., 0.95). If |
If method = "hessian", confidence intervals are constructed on the log scale
using the Delta method, then exponentiated to return to the original parameter scale.
If method = "boot", confidence intervals are computed as empirical quantiles of
the bootstrap replicates.
If method = "default", returns a named vector of parameter estimates.
If method = "hessian" or method = "boot", returns a data.frame with columns:
par: the estimated parameter
lower: lower bound of the CI
upper: upper bound of the CI
data(fit) coef(fit) coef(fit, method = "hessian", ci = 0.95) coef(fit, method = "boot", ci = 0.95)data(fit) coef(fit) coef(fit, method = "hessian", ci = 0.95) coef(fit, method = "boot", ci = 0.95)
Weekly maxima of precipitation under natural-only forcing over a European domain. This processed dataset is used in the vignettes and examples to illustrate model fitting and attribution mapping with eFCM.
data(counterfactual)data(counterfactual)
A numeric matrix or data frame with dimensions (weeks × stations). Rows index consecutive winter-season weeks; columns correspond to stations. Units are millimetres.
This dataset is derived from daily-resolution counterfactual simulations (not included in the package due to size constraints) by aggregating to weekly maxima. It is intended for examples, tests, and vignettes where a lightweight dataset is preferred.
data(counterfactual) dim(counterfactual) plot(apply(counterfactual, 1, mean), type = "l", xlab = "Week", ylab = "Mean precipitation (mm)")data(counterfactual) dim(counterfactual) plot(apply(counterfactual, 1, mean), type = "l", xlab = "Week", ylab = "Mean precipitation (mm)")
Fits the eFCM at a specified grid point using local neighborhood data.
fcm( s, object, theta0 = c(2, 100), thres = 0.9, nu = 0.5, hessian = TRUE, control = list(), censorL = TRUE, boot = FALSE, R = 1000, progress = TRUE, lower = c(1, 1), upper = Inf, sample_prop = 0.9, sample_ids = NULL, parallel = FALSE, ncpus = 4, mc.set.seed = TRUE, ... )fcm( s, object, theta0 = c(2, 100), thres = 0.9, nu = 0.5, hessian = TRUE, control = list(), censorL = TRUE, boot = FALSE, R = 1000, progress = TRUE, lower = c(1, 1), upper = Inf, sample_prop = 0.9, sample_ids = NULL, parallel = FALSE, ncpus = 4, mc.set.seed = TRUE, ... )
s |
A single integer specifying the grid point index. |
object |
An object of class |
theta0 |
A numeric vector of initial values for the copula parameters ( |
thres |
A numeric scalar indicating the quantile-based threshold (default is 0.9). |
nu |
Numeric Matérn smoothness parameter. |
hessian |
Logical; whether to return the Hessian matrix. Default is TRUE. |
control |
A list of control options for |
censorL |
Logical; if TRUE (default), uses the censored likelihood. |
boot |
Logical; whether to perform bootstrap estimation (default |
R |
Integer; number of bootstrap replicates if |
progress |
Logical; if |
lower, upper
|
Numeric vectors of parameter bounds for optimization. |
sample_prop |
Numeric in (0,1). Proportion of rows to sample in each replicate
(default 0.9). Ignored if |
sample_ids |
Optional list of integer vectors. Each element specifies the row indices
to use for a bootstrap replicate; when supplied, overrides |
parallel |
Logical; if |
ncpus |
Integer; number of worker processes when |
mc.set.seed |
Logical; seed the RNG streams in workers (default |
... |
Additional arguments passed to |
The exponential Factor Copula Model (eFCM) assumes that the process , where is a zero-mean Gaussian process with correlation and is a latent common factor independent of and . This leads to nontrivial tail dependence between spatial locations.
An object of class "fcm", which is a list including:
pars |
Estimated parameters. |
hessian |
Hessian matrix (if requested). |
nllh |
Negative log-likelihood. |
data.u |
Pseudo-uniform transformed data. |
gridID |
Location of the selected grid point. |
arg |
Model arguments (e.g., |
neigh |
Neighbourhood indices used for estimation. |
coord |
Coordinates of the locations. |
data |
Observed data matrix at selected locations. |
boot |
(optional) Matrix of bootstrap samples of parameter estimates. |
Castro-Camilo, D. and Huser, R. (2020). Local likelihood estimation of complex tail dependence structures, applied to US precipitation extremes. JASA, 115(531), 1037–1054.
# Load precipitation data for counterfactual scenarios data("counterfactual") data("LonLat") coord = LonLat # station coordinates (longitude-latitude) cf_data <- fdata(counterfactual, coord, cellsize = c(1, 1)) fit = fcm(s = 1, cf_data, boot = T, R = 1000)# Load precipitation data for counterfactual scenarios data("counterfactual") data("LonLat") coord = LonLat # station coordinates (longitude-latitude) cf_data <- fdata(counterfactual, coord, cellsize = c(1, 1)) fit = fcm(s = 1, cf_data, boot = T, R = 1000)
Prepares and organizes datasets for use with the exponential Factor Copula Model (eFCM). The function converts raw station-level observations and their spatial coordinates into an "fdata" object, which contains the data, grid structure, and neighborhood information required for model fitting with fcm().
fdata( data, coord, grid = NULL, neigh = NULL, theta0 = NULL, cellsize = c(0.5, 0.5), parallel = TRUE, ncpus = 4, mc.set.seed = TRUE, ... )fdata( data, coord, grid = NULL, neigh = NULL, theta0 = NULL, cellsize = c(0.5, 0.5), parallel = TRUE, ncpus = 4, mc.set.seed = TRUE, ... )
data |
A matrix or data.frame. Each column corresponds to a station, with rows containing observations (on the original scale). |
coord |
A two-column matrix or data frame of station coordinates (longitude and latitude), one row per station. |
grid |
Optional two-column matrix or data frame of grid locations (longitude, latitude) at which the model will be fitted. If |
neigh |
Optional list of neighborhood station indices for each grid point. If |
theta0 |
Optional matrix or data.frame with two columns: initial lambda and delta. Must match number of stations. |
cellsize |
Numeric vector of length 1 or 2, specifying longitude and latitude resolution. |
parallel |
Logical; if |
ncpus |
Integer; number of worker processes when |
mc.set.seed |
Logical; seed the RNG streams in workers (default |
... |
Additional arguments passed to |
An object of class "fdata", which is a list with elements:
data |
Original input data |
coord |
Coordinates of stations |
grid |
Grid points with assigned IDs |
neigh |
List of neighbor station indices per grid point |
theta0 |
Initial values matrix |
N |
Number of stations |
# Load precipitation data for counterfactual scenarios data("counterfactual") data("LonLat") coord = LonLat # station coordinates (longitude-latitude) cf_data <- fdata(counterfactual, coord, cellsize = c(1, 1))# Load precipitation data for counterfactual scenarios data("counterfactual") data("LonLat") coord = LonLat # station coordinates (longitude-latitude) cf_data <- fdata(counterfactual, coord, cellsize = c(1, 1))
An example output of the fcm function, obtained by fitting
the exponential Factor Copula Model to a subset of precipitation data.
data(fit)data(fit)
An object of class "fcm"
data(fit) summary(fit)data(fit) summary(fit)
Extract the log-likelihood value from a fitted fcm object.
## S3 method for class 'fcm' logLik(object, ...)## S3 method for class 'fcm' logLik(object, ...)
object |
An object of class |
... |
Additional arguments (currently unused). |
A numeric value giving the log-likelihood of the fitted model.
AIC.fcm(), BIC.fcm(), AICc.fcm()
A dataset containing the longitude and latitude of monitoring stations used in the eFCM examples and vignettes.
data(LonLat)data(LonLat)
A data frame with rows and 2 variables:
Longitude (decimal degrees, WGS84).
Latitude (decimal degrees, WGS84).
data(LonLat) head(LonLat)data(LonLat) head(LonLat)
Identifies homogeneous neighbors around a given grid point using a combination of the Hosking-Wallis (1993) and Anderson-Darling (1987) tests for marginal homogeneity.
neighborhood_HT( data, coord, s0, miles = FALSE, min.neigh = 5, max.neigh = 20, pr = 0.9, alpha = 0.05, dmax = 150, which.test = c(1, 2) )neighborhood_HT( data, coord, s0, miles = FALSE, min.neigh = 5, max.neigh = 20, pr = 0.9, alpha = 0.05, dmax = 150, which.test = c(1, 2) )
data |
A matrix or data.frame. Each column corresponds to a station, with rows containing observations (on the original scale). |
coord |
A two-column matrix or data frame of station coordinates (longitude and latitude), one row per station. |
s0 |
Numeric vector of length 2: the longitude and latitude of the target grid point. |
miles |
Logical; whether to compute distance in miles (default: FALSE). |
min.neigh |
Minimum number of neighbors to accept (default: 5). |
max.neigh |
Maximum number of neighbors to test (default: 20). |
pr |
Probability threshold for quantile filtering (e.g. 0.9). |
alpha |
Significance level for homogeneity tests. |
dmax |
Maximum distance (in km) to consider. |
which.test |
Integer vector specifying which test(s) to run:
|
A vector of station indices considered homogeneous with the grid point.
Castro-Camilo, D. and Huser, R. (2020). JASA 115, 1037–1054. Hosking, J. and Wallis, J. (1993). Water Resour. Res. 29, 271–281. Scholz, F.W. and Stephens, M.A. (1987). JASA 82, 918–924.
neighborhood_HT(counterfactual, coord = LonLat, s0 = c(30, 39), which.test = c(1, 2))neighborhood_HT(counterfactual, coord = LonLat, s0 = c(30, 39), which.test = c(1, 2))
Density, distribution function, quantile function and random generation
for the distribution of univariate factor copula model with rate parameter
equal to lambda.
pfcm(w, lambda) dfcm(w, lambda) qfcm(u, lambda, tol = 1e-08, niter = 1000L) rfcm(n, lambda)pfcm(w, lambda) dfcm(w, lambda) qfcm(u, lambda, tol = 1e-08, niter = 1000L) rfcm(n, lambda)
w |
A numeric value representing the spatial process. |
lambda |
A numeric value representing rate parameter |
u |
a numeric vector of probabilities, with values in the interval from 0 to 1, at which the quantile function is to be computed. |
tol |
a scalar indicating the desired level of numerical accuracy for the algorithm; default is 1e-9. |
niter |
a scalar indicating the maximum number of iterations. |
n |
an integer value specifying the number of samples to generate |
The univariate eFCM distribution is
where is the rate parameter.
dfcm gives a numeric value representing the density of the factor copula model evaluated at w,
pfcm gives a numeric value representing the CDF evaluated at w,
qfcm gives the quantile function (QF) of the factor copula model.
and rfcm generate a numeric vector of random samples drawn.
pfcm(w = 1, lambda = 0.5) dfcm(w = 1, lambda = 0.5) qfcm(u = 0.5, lambda = 0.5) rfcm(n = 1000, lambda = 0.5)pfcm(w = 1, lambda = 0.5) dfcm(w = 1, lambda = 0.5) qfcm(u = 0.5, lambda = 0.5) rfcm(n = 1000, lambda = 0.5)
Computes the eFCM-based for a single -dimensional vector .
pmfcm( w, lambda, delta, dist = NULL, coord = NULL, smooth = 0.5, abseps = 1e-05, releps = 1e-05, maxpts = 25000, miles = FALSE )pmfcm( w, lambda, delta, dist = NULL, coord = NULL, smooth = 0.5, abseps = 1e-05, releps = 1e-05, maxpts = 25000, miles = FALSE )
w |
Numeric vector of length |
lambda, delta
|
Positive scalars: common-factor rate |
dist |
Optional |
coord |
Optional two-column matrix/data.frame of coordinates (lon, lat) to build |
smooth |
Matérn smoothness |
abseps, releps
|
Absolute/relative tolerances for the MVN CDF. |
maxpts |
Maximum number of function evaluations for the MVN CDF. |
miles |
Logical; passed to |
A single numeric CDF value in .
data(LonLat) d <- 2 w <- rep(0.3, d) pmfcm(w, lambda = 2, delta = 100, coord = LonLat[1:2, ])data(LonLat) d <- 2 w <- rep(0.3, d) pmfcm(w, lambda = 2, delta = 100, coord = LonLat[1:2, ])
Produce a Q–Q plot comparing empirical exceedances to the fitted eFCM tail, with an optional GPD tail overlay for diagnostic comparison.
qqplot(object, ...) ## S3 method for class 'fcm' qqplot( object, which = 1, gpd = TRUE, thres = 0.9, main = "Q-Q plot", xlab = "Theoretical quantiles (exceedances)", ylab = "Empirical exceedances", ... )qqplot(object, ...) ## S3 method for class 'fcm' qqplot( object, which = 1, gpd = TRUE, thres = 0.9, main = "Q-Q plot", xlab = "Theoretical quantiles (exceedances)", ylab = "Empirical exceedances", ... )
object |
An object of class |
... |
Additional graphical arguments forwarded to |
which |
Integer scalar. Station (column) index to plot. |
gpd |
Logical; if |
thres |
Numeric in |
main, xlab, ylab
|
Character. Graphical labels passed to |
The function first selects a threshold u as the empirical
thres-quantile of the selected station series x.
It then forms exceedances , fits the eFCM
(implicitly via qfcm() and a scalar estimate),
and plots empirical exceedances against theoretical eFCM quantiles in the tail.
If gpd=TRUE, a GPD is fitted to the exceedances (threshold 0) and
its theoretical tail quantiles are added for visual comparison.
A numeric vector of fitted eFCM theoretical tail quantiles, invisibly returned.
Draws samples from the eFCM.
rmfcm( lambda, delta, dist = NULL, coord = NULL, nu = 0.5, n = 5e+05, miles = FALSE, seed = NULL )rmfcm( lambda, delta, dist = NULL, coord = NULL, nu = 0.5, n = 5e+05, miles = FALSE, seed = NULL )
lambda, delta
|
Positive scalars: rate |
dist |
Optional |
coord |
Optional two-column matrix/data.frame of station coordinates (lon, lat).
Used to build |
nu |
Matérn smoothness parameter (default |
n |
Number of simulated rows (default |
miles |
Logical passed to |
seed |
Optional integer seed for reproducibility. |
A numeric matrix of size n x d (rows = samples, cols = stations).
data(LonLat) sim <- rmfcm(lambda = 2, delta = 100, coord = LonLat[1:2, ], n = 10000) dim(sim) # 10000 x 2data(LonLat) sim <- rmfcm(lambda = 2, delta = 100, coord = LonLat[1:2, ], n = 10000) dim(sim) # 10000 x 2
Summary method for objects of class "fcm", returned by fcm().
## S3 method for class 'fcm' summary(object, ...)## S3 method for class 'fcm' summary(object, ...)
object |
An object of class |
... |
Additional arguments (ignored). |
Invisibly, a list with summary components:
grid: the selected grid point
neighbors: indices and coordinates of neighbors
coef: parameter estimates with 95\
objective: negative log-likelihood
information criteria: c(AIC, BIC, AICc)
args: fitting arguments
data(fit) summary(fit)data(fit) summary(fit)