fdata: Transform datasets for factor copula modeling

View source: R/fdata.R

fdataR Documentation

Transform datasets for factor copula modeling

Description

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().

Usage

fdata(
  data,
  coord,
  grid = NULL,
  neigh = NULL,
  theta0 = NULL,
  cellsize = c(0.5, 0.5),
  parallel = TRUE,
  ncpus = 4,
  mc.set.seed = TRUE,
  ...
)

Arguments

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 NULL (default), a regular grid is generated based on cellsize.

neigh

Optional list of neighborhood station indices for each grid point. If NULL, neighborhoods are constructed using neighborhood_HT().

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 TRUE, run neighbourhood selection in parallel using pbmcapply. On Windows, pbmclapply will fall back to serial execution (progress still shown).

ncpus

Integer; number of worker processes when parallel = TRUE on Unix-alikes.

mc.set.seed

Logical; seed the RNG streams in workers (default TRUE). Effective on Unix-alikes; on Windows (serial fallback) it has no effect.

...

Additional arguments passed to neighborhood_HT().

Value

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

See Also

fcm(), neighborhood_HT()

Examples


# 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))


eFCM documentation built on Sept. 9, 2025, 5:52 p.m.