If the observed data in a cell contains an insufficient number of defined values, then all distribution parameters at that pixel will be undefined.

fit_cell_distributions(distribution, arr, nmin.unique = 10,
  nmin.defined = 10, zero.scale.to.na = TRUE, log.errors = NULL)

Arguments

distribution

The name of the distribution to fit (e.g., "gev", "pe3")

arr

A 3D array representing multiple observations of a variable in each 2D cell

nmin.unique

Minimum number of unique values required to perform the fit

nmin.defined

Minimum number of defined values required to perform the fit

zero.scale.to.na

If TRUE, fit will be discarded (set to NA) if the scale parameter is computed to be zero.

log.errors

Function that will be called with any errors reported by distribution-fitting function. If log.errors is not specified, errors will be written to stdout.

Value

A 3D array containing the fitted (location, scale, shape) parameters of the GEV for each pixel

Details

If the observed data at a pixel contains a a sufficient number of defined values, but an insufficient number of unique values, then the location parameter at that pixel will be set to the median of the defined values and the other parameters will remain undefined.

If a distribution cannot be fit, then the returned parameters will be NA. (TODO: Describe cases where this may happen.)