Skip to contents

Assemble the observations an analysis or model is fit to. Beyond a plain systematic record (exact), a frame can carry the censored observation types Bulletin 17C flood-frequency work depends on: historical or paleoflood observations known only within a range (interval), perception thresholds recording that nothing above a level occurred over a span of years (threshold), and observations whose measurement error is itself a distribution (uncertain).

Usage

analysis_data(
  exact = NULL,
  interval = NULL,
  threshold = NULL,
  uncertain = NULL,
  low_outlier_threshold = NULL,
  mgbt_low_outliers = FALSE
)

Arguments

exact

a numeric vector of observations, or a data frame with a value column plus optional index and is_low_outlier columns.

interval

a data frame with lower, value, and upper columns plus an optional index, giving observations known only to lie in a range.

threshold

a data frame with start_index, end_index, value, and number_above columns, giving perception thresholds over spans of the record.

uncertain

a list of distribution() objects (one per observation), or a list with an index element and a distribution element holding them.

low_outlier_threshold

optional numeric; values at or below it are treated as left-censored low outliers.

mgbt_low_outliers

logical; when TRUE the Multiple Grubbs-Beck test picks the low outlier threshold from the data. Mutually exclusive with low_outlier_threshold and with explicit is_low_outlier flags.

Value

An object of class corehydro_data.

Details

This is the port of the RMC.BestFit DataFrame class. It is named analysis_data() rather than data_frame() to avoid colliding with the R and pandas types of that name.

Indexes are 0-based, matching the C# library and the shared C++ core, and are generated sequentially when not supplied. An index is a position in the record, so an interval observation at index 40 sits after the 40th exact observation in chronological order.

See also

analysis_data_summary() for plotting positions and record diagnostics, model_univariate() to fit a model to one, mgbt_test().

Examples

# A systematic record on its own.
peaks <- c(12500, 15300, 8900, 22100, 18700, 14200, 9800, 28500)
analysis_data(peaks)
#> <corehydro_data> 8 exact

# Adding two historical floods known only within a range, and a perception threshold
# covering the 40 years before the gauge was installed.
analysis_data(
  exact = peaks,
  interval = data.frame(
    index = c(8, 9), lower = c(30000, 26000),
    value = c(35000, 29000), upper = c(40000, 32000)
  ),
  threshold = data.frame(
    start_index = 8, end_index = 47, value = 25000, number_above = 2
  )
)
#> <corehydro_data> 8 exact, 2 interval, 1 threshold