For a the supplied outcome argument OCode this function classifies the difference between MeanC and MeanT into character and numeric columns based on the Threshold and Vals arguments. These columns are appended to the input dataset that has been subset to the outcome of interest.

ClassifyNegVals(
  Data,
  OCode,
  Thresholds = c(0.7, 0.95, 1.05, 1.3),
  Vals = c(`0` = 0, `++` = 2, `+` = 1, `-` = -1, `--` = -2, `+-` = 1, `-+` = -1, `+0` =
    1, `0+` = -1, `-0` = -1, `0-` = 1),
  Invert2xNeg = T
)

Arguments

Data

An ERA data.table (e.g. ERAg::ERA.Compiled).

OCode

An ERA outcome code (see ERAg::OutcomeCodes[,Codes].

Thresholds

A numeric vector of length four corresponding to classification thresholds for worst, poor, good & best outcomes. If:

  • MeanT/MeanC<Threshold[1] then Class = --

  • Threshold[1]<=MeanT/MeanC<Threshold[2] then Class = -

  • Threshold[2]<=MeanT/MeanC<Threshold[3] then Class = 0

  • Threshold[3]<=MeanT/MeanC<Threshold[4] then Class = +

  • MeanT/MeanC>=Threshold[4]`` then Class = ++`

Vals

A numeric vector of length 11 proving numeric scores for each outcome classification:

  • Vals[1]: Class 0 = MeanT/MeanC<Threshold[1]

  • Vals[2]: Class ++ = Threshold[1]<=MeanT/MeanC<Threshold[2]

  • Vals[3]: Class += Threshold[2]<=MeanT/MeanC<Threshold[3]

  • Vals[4]: Class - = Threshold[3]<=MeanT/MeanC<Threshold[4]

  • Vals[5]: Class -- = MeanT/MeanC>=Threshold[4]

  • Vals[6]: Class +- = MeanT>0 & MeanC<0

  • Vals[7]: Class -+ = MeanT<0 & MeanC>0

  • Vals[8]: Class +0 = MeanT>0 & MeanC==0

  • Vals[9]: Class 0+ = MeanT==0 & MeanC>0

  • Vals[10]: Class -0 = MeanT<0 & MeanC==0

  • Vals[11]: Class 0- = MeanT==0 & MeanC<0

Invert2xNeg

Logical T/F. Where MeanC<0 & MeanT<0 invert the calculation of yi to log(MeanC/MeanT)

Value

ClassifyNegVals returns the input Data subset to the outcome provided in the OCodeargument and with the additional columns:

  • Class a character vector of class names

  • Class.Val a numeric vector of class values

Details

When generating ratios the function will invert outcomes where MeanT and MeanC are both negative unless the Invert2xNeg argument is set to FALSE.

Where MeanC is NA and MeanT is populated this function will base classfications on the MeanT value only.