Skip to contents

Calculates the proportion of site-level KRIs that lie within a range defined by quantiles of the posterior density provided by a call to a fit Bayes XXXX Model function.

Usage

evaluateSiteMetricQTL(
  data,
  posterior,
  metric,
  observedMetric,
  statusCol = Status,
  statusFunc = NULL,
  lower = NULL,
  upper = NULL
)

Arguments

data

the tibble containing site-level observed metrics (KRIs)

posterior

the tibble containing the posterior distribution of the, metric, usually obtained from a fit Bayes model function.

metric

the column in posterior on which the QTL should be based

observedMetric

the column in data containing the site level observed metrics (KRIs)

statusCol

the name of the column to be added to data that will contain the site-level flags comparing the corresponding KRI to the QTL thresholds defined by lower and upper

statusFunc

a function that takes as its single argument the qtl element of the return value and converts it to a status string

lower

a scalar or vector of lower limits, or NULL. See Usage Notes below.

upper

a scalar or vector of upper limits, or NULL. See Usage Notes below.

Value

a list of three elements named status, data and qtl. If status is "OK", no breach of the QTL was detected. Otherwise, status is equal to name of the most serious breach of the QTL as determined by the values in either lower or upper. qtl is a tibble whose rows provide counts of the number of sites whose KRIs lie in the ranges defined by lower and upper. In addition, the quantiles element provides the conversion between quantiles of the posterior distribution of metric and values of metric itself.

Details

For more details, see Usage Notes below.

Usage Notes

Either or both lower of upper can be NULL. In what follows, limit refers to both lower and upper. #' If limit has names, those names are used. Otherwise, names are assigned based on the length of limit. If length(limit) is 1, the single element is named "action". If length(limit) is 2, the two elements are named "warn" and "action". (In this case, limit is first sorted appropriately.) If length(limit) is >2, its elements are named "1" to "n" where n is length(limit).

If statusFunc is NULL, then the status element of the return value is set to "OK" by default.