Description Usage Arguments Value Examples
Citation: Myerson, J., Green, L., & Warusawitharana, M. (2001). Area under the curve as a measure of discounting. Journal of the experimental analysis of behavior, 76 2, 235-43 .
1 |
df |
A data frame with one x and one y value on each line. Optionally, leading x and leading y values can be on each line as well. |
x |
Column of data frame containing trial index (i.e., successive delays, cognitive effort, probability). traper function sorts the data by x. The user should normalize data to obtain canonical auc ranging from 0 to 1. |
y |
Column of data frame containing subjective values (or scores). The user should normalize data to obtain canonical auc ranging from 0 to 1. |
x_lead |
The x_lead column should be the x value from the next row. If this parameter is not provided, trap_auc will create this column using the traper function. |
y_lead |
The y_lead column should be the y value from the next row. If this parameter is not provided, trap_auc will create this column using the traper function. |
A list two items: 1) the total area under the curve (your_list$total) and a data frame (your_list$data) where each row contains the data to compute the area of one trapezoid and the area of one trapezoid.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | #Create data frame with successive delays and subjective values
df_test <- data.frame(delay = sample(1:100, 50, replace = FALSE),
value = sample(1:100, 50, replace = TRUE))
#Normalize data in preparation for auc calculation
df_test$delay <- df_test$delay/max(df_test$delay)
df_test$value <- df_test$value/max(df_test$value)
#Reformat data in preparation to compute the trapezoidal auc
df_test_2 <- traper(df_test, x = delay, y = value, rename = TRUE)
#Calculate the area under the curve
output_test_A <- trap_auc(df_test_2, x = delay, y = value,
x_lead = delay_lead, y_lead = value_lead)
#Get area under the curve
output_test_A$total
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.