prep_AUC: AUC data peperation helper function

View source: R/AUC_prep.R

prep_AUCR Documentation

AUC data peperation helper function

Description

Helper function to take AUC tibble and preprocess for other AUC calculations

Usage

prep_AUC(dat, indiff = NULL, x_axis, groupings = NULL, prob_disc = FALSE)

Arguments

dat

Discounting data tibble

indiff

Indifference points Variable

x_axis

Delays/probabilities/social distance variable

groupings

Variables for grouping (e.g., subject, expeirmental group) as a character or vector of characters

prob_disc

Boolean for probability discounting (MAYBE NOT NECESSARY PULLED OUT ODDS AGAINST TO DIFFERENT FUNCTION)

Value

Tibble that is grouped and arranged by groupings and x_axis (or x_axis_against, if probability discounting)

Examples

library(dplyr)

# Prep single set of data
DD <- tibble(
  delay = c(1 / 7, 1, 2, 4, 26, 52),
  indiff = c(95, 75, 50, 20, 5, 1)
) %>%
  arrange(delay)

prep_AUC(dat = DD, indiff = "indiff", x_axis = "delay")
# Prep multiple subject data

# Create DD data disorganize by delay
DD <- tibble(
  delay = rep(c(1 / 7, 1, 2, 4, 26, 52), 2),
  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))
) %>%
  arrange(delay)

# Group by subject and organize by subject and delay
prep_AUC(dat = DD, indiff = "indiff", x_axis = "delay", groupings = "sub")


# Probability discounting with subjects and different outcomes

# Create PD data and disorganize by probability
PD <- tibble(
  prob = rep(c(.1, 1 / 100, 1 / 300, 1 / 750, 1 / 1000, 1 / 3000), 4),
  value = rep(c(c(95, 75, 50, 20, 5, 1), c(95, 75, 50, 20, 5, 1) + .25), 2),
  sub = rep(c(rep(1, 6), rep(2, 6)), 2),
  outcome = c(rep("money", 12), rep("cigarettes", 12))
) %>%
  arrange(prob)

# Calculate odds against, organize by subject, outcome, odds against
prep_AUC(PD,
  indiff = "value",
  x_axis = "prob",
  groupings = c("sub", "outcome"),
  prob_disc = TRUE
)

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