CBS_RC {CBSr}  R Documentation 
CBS_RC
Description
Fit either a 1piece or 2piece CBS latent utility function to binary risky choice data.
Usage
CBS_RC(choice, Amt1, Prob1, Amt2, Prob2, 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. 
Prob1 
Vector of positive real numbers between 0 and 1. Probability of winning the reward of choice 1. 
Amt2 
Vector of positive real numbers. Reward amount of choice 2. 
Prob2 
Vector of positive real numbers between 0 and 1. Probability of winning 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
with probability Prob1
and Option 2 is receiving Amt2
with probability Prob2
(e.g., $40 with 53% chance vs. $20 with 90% chance).
One of the two options may be certain (i.e., prob = 1; e.g., $40 with 53% chance vs. $20 for sure).
choice
should be 1 if option 1 is chosen, 0 if option 2 is chosen.
Value
A list containing the following:

type
: either 'CBS1' or 'CBS2' depending on the number of pieces 
LL
: log likelihood of the model 
numparam
: number of total parameters in the model 
scale
: scaling factor of the logit model 
xpos
: x coordinates of the fitted CBS function 
ypos
: y coordinates of the fitted CBS function 
AUC
: area under the curve of the fitted CBS function. Normalized to be between 0 and 1.
Examples
# Fit example Risky choice data with 2piece CBS function.
# Load example data (included with package).
# Each row is a choice between option 1 (Amt with prob) vs option 2 (20 for 100%).
Amount1 = RCdat$Amt1
Prob1 = RCdat$Prob1
Amount2 = 20
Prob2 = 1
Choice = RCdat$Choice
# Fit the model
out = CBS_RC(Choice,Amount1,Prob1,Amount2,Prob2,2)
# Plot the choices (x = Delay, y = relative amount : 20 / risky amount)
plot(Prob1[Choice==1],20/Amount1[Choice==1],type = 'p',col="blue",xlim=c(0, 1), ylim=c(0, 1))
points(Prob1[Choice==0],20/Amount1[Choice==0],type = 'p',col="red")
# Plot the fitted CBS
x = seq(0,1,.01)
lines(x,CBSfunc(out$xpos,out$ypos,x))