Given a probabiliy p it returns the term used to describe the category this probability belongs to. It ensures the levels of the output are ordered appropietly.

get_likelihood_category(
  p,
  scale = c("statsnz", "ipcc"),
  term_type = c("worsening-improving", "improving-worsening", "increasing-decreasing",
    "decreasing-increasing", "likely-unlikely"),
  p_is = c("probability", "percentage")
)

Arguments

p

the probability (or percentage) used to caclulate the category

scale

whether to base the categories using the Statistics New Zealand likelihood scale ("statsnz") or the IPCC scale ("ipcc")

term_type

when scale = "statsnz" it allows to modify the terms depending on what the probability p indicates. term_type = "worsening-improving" indicates that a large p corresponds to a worsening trend; this is the default. term_type = "improving-worsening" indicates that a large p corresponds to an improving trend. term_type = "increasing-decreasing" indicates that the output should range from "Very likely increasing" to "Very likely decreasing". term_type = "likely-unlikely" indicates that the output should range from "Very likely" to "Very unlikely".

p_is

whether p is a probability (from 0 to 1) or a percentage (from 0 to 100)

Value

a character

Details

This function uses the data contained in the statsnz_likelihood_scale and ipcc_likelihood_scale tables to determine the category of a given probability (usually a p-value). It uses order_likelihood_levels to ensure that levels of the output are ordered correctly.

See also

Other likelihood functions: order_likelihood_levels(), simplify_likelihood_levels()

Examples

p <- seq(0, 1, length.out = 11)

# In most water quality metrics an increasing trend (large p) corresponds to
# a worsening trend
get_likelihood_category(p, term_type = "worsening-improving") %>%
  order_likelihood_levels()
#>  [1] Very likely improving Likely improving      Likely improving     
#>  [4] Likely improving      Indeterminate         Indeterminate        
#>  [7] Indeterminate         Likely worsening      Likely worsening     
#> [10] Likely worsening      Very likely worsening
#> 5 Levels: Very likely improving Likely improving ... Very likely worsening

# In climate metrics we usually prefer an increasing-decreasing scale
get_likelihood_category(p, term_type = "increasing-decreasing") %>%
  order_likelihood_levels()
#>  [1] Very likely increasing Likely increasing      Likely increasing     
#>  [4] Likely increasing      Indeterminate          Indeterminate         
#>  [7] Indeterminate          Likely decreasing      Likely decreasing     
#> [10] Likely decreasing      Very likely decreasing
#> 5 Levels: Very likely increasing Likely increasing ... Very likely decreasing

# Also works when p is a percentages
get_likelihood_category(p*100, p_is = "percentage") %>%
  order_likelihood_levels()
#>  [1] Very likely improving Likely improving      Likely improving     
#>  [4] Likely improving      Indeterminate         Indeterminate        
#>  [7] Indeterminate         Likely worsening      Likely worsening     
#> [10] Likely worsening      Very likely worsening
#> 5 Levels: Very likely improving Likely improving ... Very likely worsening

# We can also get terms used by ipcc if desired
get_likelihood_category(p, scale = "ipcc") %>%
  order_likelihood_levels()
#>  [1] Exceptionally unlikely Unlikely               Unlikely              
#>  [4] Unlikely               About as likely as not About as likely as not
#>  [7] About as likely as not Likely                 Likely                
#> [10] Likely                 Virtually certain     
#> 9 Levels: Virtually certain Extremely likely Very likely ... Exceptionally unlikely