Skip to contents

Evaluates the probability that a study-level metric lies within a given range based in the posterior density provided by a call to a fit Bayes XXXX Model function. Action and warning limits are determined by parameters range and probs. That is, for a single range for the metric, various limits are defined, each based on an element of probs. Site-level KRIs are flagged based on the values in lower and upper.

Usage

evaluateProbabilityInRangeQTL(
  data,
  posterior,
  metric,
  observedMetric,
  statusCol = Status,
  range,
  probs,
  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

range

the range of values of metric to be used when calculating qtl = Prob(metric in range).

probs

the thresholds for Prob(metric in range) that define the action and warning limits for the QTL

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 contains the posterior probability that metric lies within range.

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