Skip to contents

tempodisco is an R package for behavioural researchers working with delay discounting data (also known as temporal discounting intertemporal choice data). It implements common tasks such as scoring responses (e.g. computing indifference points from an adjusting amounts procedure, computing the “area under the curve”, or computing kk values as in the Monetary Choice Questionnaire; Frye et al., 2016; Myerson et al., 2001; Kirby et al., 1999), identifying poor-quality data (e.g. failed attention checks and non-systematic responding; Johnson & Bickel, 2008), modelling choice data using multiple discount functions (e.g. hyperbolic, exponential, etc.—see below; Franck et al., 2015), and modelling reaction times using drift diffusion models (Peters & D’Esposito, 2020).

Installation

You can install tempodisco from GitHub with:

# install.packages("devtools")
devtools::install_github("kinleyid/tempodisco")

Getting started

See getting started for example usage.

Overview

A good practice in delay discounting research is to not assume that the same discount function describes every individual (Franck et al., 2015). tempodisco implements the following discount functions and can automatically select the best one for a given individual according to the Bayesian information criterion (Schwartz, 1978):

Name Functional form Other names
exponential (Samuelson, 1937) f(t;k)=ektf(t; k) = e^{-k t}
scaled-exponential (Laibson, 1997) f(t;k,w)=wektf(t; k, w) = w e^{-k t} Quasi-hyperbolic; beta-delta
nonlinear-time-exponential (Ebert & Prelec, 2007) f(t;k,s)=ektsf(t; k, s) = e^{-k t^s} Constant sensitivity
dual-systems-exponential (Ven den Bos & McClure, 2013) f(t;k1,k2,w)=wek1t+(1w)ek2tf(t; k_1, k_2, w) = w e^{-k_1 t} + (1 - w) e^{-k_2 t}
inverse-q-exponential (Green & Myerson, 2004) f(t;k,s)=1(1+kt)sf(t; k, s) = \frac{1}{(1 + k t)^s} Generalized hyperbolic Loewenstin & Prelec; hyperboloid (Green & Myerson, 2004); q-exponential (Han & Takahashi, 2012)
hyperbolic (Mazur, 1987) f(t;k)=11+ktf(t; k) = \frac{1}{1 + kt}
nonlinear-time-hyperbolic (Rachlin, 2006) f(t;k,s)=11+ktsf(t; k, s) = \frac{1}{1 + k t^s} Power-functin (Rachlin, 2006)

These discount functions can be fit to indifference point data (see td_ipm), choice-level data (see td_bcnm), or reaction time data (see td_ddm).

After fitting a model, we can check to see how well it matches the data using the plot() function:

library(tempodisco)
data("td_bc_single_ptpt")
mod <- td_bcnm(td_bc_single_ptpt, discount_function = c('hyperbolic', 'exponential'))
plot(mod, p_lines = c(0.1, 0.9), log = 'x', verbose = F)

See “Visualizing models” for more examples.

Reporting issues and requesting features

If you encounter problems with the software or would like to it to have additional functionality, please open a new issue on the GitHub repository. Try to include as much detail as possible, especially how to reproduce any errors/incorrect results. GitHub has instructions on opening an issue here.

Contributing

If you would like to contribute to tempodisco, you’re more than welcome! Please follow the instructions here on how to contribute to a project on GitHub. Feel free to contact me if you’d like help with any contributions.