prep_ordinal_all: Shared ordinal x-axis

View source: R/AUC_ordinals.R

prep_ordinal_allR Documentation

Shared ordinal x-axis

Description

Helper function to create ordinal values for x-axis variable. This helper function is designed to be used if the x-axis values are not identical across every set of indifference points. For example, if one subject was exposed to delays of 1 day and 1 month and a second subject was exposed to delays of 1 week and 1 month. In such a case, prep_ordinal_all() would return ordinal delays of (1, 3) for subject 1 and ordinal delays of (2, 3) for subject 2. If 0 exists, will be coded as 0.

Usage

prep_ordinal_all(dat, x_axis, prob_disc = FALSE)

Arguments

dat

Discounting data tibble

x_axis

Delays/probabilities/social distance variable

prob_disc

Boolean for probability discounting, if set to true function will calculate odrinals based on descending x_axis values which would be in line with increasing odds against.

Value

Tibble that has ordinal values for each x_axis value based on all possible x_axis values.

Examples

library(dplyr)

PD <- tibble(
  prob = c(
    c(.05, 1 / 100, 1 / 300, 1 / 750, 1 / 1000, 1 / 3000),
    c(.1, 1 / 100, 1 / 300, 1 / 750, 1 / 1000, 1 / 4000)
  ),
  indiff = c(c(95, 75, 50, 20, 5, 1), c(95, 75, 50, 20, 5, 1) + .25),
  sub = c(rep(1, 6), rep(2, 6))
)

prep_ordinal_all(PD, "prob", prob_disc = TRUE)

discAUC documentation built on March 31, 2023, 5:26 p.m.