CBS_ITC {CBSr}R Documentation

CBS_ITC

Description

Fit either a 1-piece or 2-piece CBS latent utility function to binary intertemporal choice data.

Usage

CBS_ITC(choice, Amt1, Delay1, Amt2, Delay2, numpiece, numfit = NULL)

Arguments

choice

Vector of 0s and 1s. 1 if the choice was option 1, 0 if the choice was option 2.

Amt1

Vector of positive real numbers. Reward amount of choice 1.

Delay1

Vector of positive real numbers. Delay until the reward of choice 1.

Amt2

Vector of positive real numbers. Reward amount of choice 2.

Delay2

Vector of positive real numbers. Delay until the reward of choice 2.

numpiece

Either 1 or 2. Number of CBS pieces to use.

numfit

Number of model fits to perform from different starting points. If not provided, numfit = 10*numpiece

Details

The input data has n choices (ideally n > 100) between two reward options. Option 1 is receiving Amt1 in Delay1 and Option 2 is receiving Amt2 in Delay2 (e.g., $40 in 20 days vs. $20 in 3 days). One of the two options may be immediate (i.e., delay = 0; e.g., $40 in 20 days vs. $20 today). choice should be 1 if option 1 is chosen, 0 if option 2 is chosen.

Value

A list containing the following:

Examples

# Fit example ITC data with 2-piece CBS function.
# Load example data (included with package).
# Each row is a choice between option 1 (Amt at Delay) vs option 2 (20 now).
Amount1 = ITCdat$Amt1
Delay1 = ITCdat$Delay1
Amount2 = 20
Delay2 = 0
Choice = ITCdat$Choice

# Fit the model
out = CBS_ITC(Choice,Amount1,Delay1,Amount2,Delay2,2)

# Plot the choices (x = Delay, y = relative amount : 20 / delayed amount)
plot(Delay1[Choice==1],20/Amount1[Choice==1],type = 'p',col="blue",xlim=c(0, 180), ylim=c(0, 1))
points(Delay1[Choice==0],20/Amount1[Choice==0],type = 'p',col="red")

# Plot the fitted CBS
x = 0:out$normD
lines(x,CBSfunc(out$xpos,out$ypos,x),col="black")

[Package CBSr version 1.0.5 Index]