func_gamma {binaryRL} | R Documentation |
Function: Utility Function
Description
This function represents an exponent used in calculating utility from reward. Its application varies depending on the specific model:
-
Stevens' Power Law: Here, utility is calculated by raising the reward to the power of
gamma
. This describes how the subjective value (utility) of a reward changes non-linearly with its objective magnitude. -
Kahneman's Prospect Theory: This theory applies exponents differently for gains and losses, and introduces a loss aversion coefficient:
For positive rewards (gains), utility is the reward raised to the power of
gamma[1]
.For negative rewards (losses), utility is calculated by first multiplying the reward by
beta
, and then raising this product to the power ofgamma[2]
. Here,beta
acts as a loss aversion parameter, accounting for the greater psychological impact of losses compared to equivalent gains.
Usage
func_gamma(
i,
L_freq,
R_freq,
L_pick,
R_pick,
L_value,
R_value,
var1 = NA,
var2 = NA,
value,
utility,
reward,
occurrence,
gamma = 1,
alpha,
beta
)
Arguments
i |
The current row number. |
L_freq |
The frequency of left option appearance |
R_freq |
The frequency of right option appearance |
L_pick |
The number of times left option was picked |
R_pick |
The number of times left option was picked |
L_value |
The value of the left option |
R_value |
The value of the right option |
var1 |
[character] Column name of extra variable 1. If your model uses more than just reward and expected value, and you need other information, such as whether the choice frame is Gain or Loss, then you can input the 'Frame' column as var1 into the model.
|
var2 |
[character] Column name of extra variable 2. If one additional variable, var1, does not meet your needs, you can add another additional variable, var2, into your model.
|
value |
The expected value of the stimulus in the subject's mind at this point in time. |
utility |
The subjective value that the subject assigns to the objective reward. |
reward |
The objective reward received by the subject after selecting a stimulus. |
occurrence |
The number of times the same stimulus has been chosen. |
gamma |
[vector] This parameter represents the exponent in utility functions, specifically:
|
alpha |
[vector] Extra parameters that may be used in functions. |
beta |
[vector] Extra parameters that may be used in functions. |
Value
Discount rate and utility
Note
When customizing these functions, please ensure that you do not modify the arguments. Instead, only modify the 'if-else' statements or the internal logic to adapt the function to your needs.
Examples
## Not run:
func_gamma <- function(
# Trial number
i,
# Number of times this option has appeared
L_freq,
R_freq,
# Number of times this option has been chosen
L_pick,
R_pick,
# Current value of this option
L_value,
R_value,
# Extra variables
var1 = NA,
var2 = NA,
# Expected value for this stimulus
value,
# Subjective utility
utility,
# Reward observed after choice
reward,
# Occurrence count for this stimulus
occurrence,
# Free Parameter
gamma = 1,
# Extra parameters
alpha,
beta
){
############################## [ Utility ] ##################################
if (length(gamma) == 1) {
gamma <- as.numeric(gamma)
utility <- sign(reward) * (abs(reward) ^ gamma)
}
############################### [ Error ] ###################################
else {
utility <- "ERROR"
}
return(list(gamma, utility))
}
## End(Not run)