## Package 'binaryRL' Version: 0.9.7
head(binaryRL::Mason_2024_G2)
## Subject Block Trial L_choice R_choice L_reward R_reward Sub_Choose Frame
## 1 1 1 1 A B 36 40 B Gain
## 2 1 1 2 A B 36 40 B Gain
## 3 1 1 3 C D -36 -40 D Loss
## 4 1 1 4 D C -40 -36 D Loss
## 5 1 1 5 D C -40 -36 D Loss
## 6 1 1 6 A B 36 40 A Gain
## NetWorth RT
## 1 40 6855
## 2 80 7089
## 3 40 5147
## 4 0 1531
## 5 -40 1859
## 6 -4 1910
TD
binaryRL.res <- binaryRL::run_m(
mode = "replay",
data = binaryRL::Mason_2024_G2,
id = 1,
eta = c(0.123),
tau = c(0.789),
n_params = 2,
n_trials = 360,
priors = NULL
)
summary(binaryRL.res)
## Results of TD Model (replay):
## Estimation Method: NA
## Exploration and Exploitation Trade-off:
## Initial Values: Initial reward received
## Exploration Strategy: off
## Upper-Confidence-Bound: off
## Soft-Max: on
## Model Fit:
## Accuracy: 65%
## Log-Likelihood: -354.86
## Log-Prior Probability: NA
## Log-Posterior Probability: NA
## AIC: 713.72
## BIC: 721.49
## Free Parameters:
## α: NA
## β: NA
## γ: 1
## η: 0.123
## ε: NA
## λ: NA
## π: NA
## τ: 0.789
## [[1]]
## Parameter Value1
## 1 Q1 NA
## 2 threshold 1.000
## 3 lapse 0.020
## 4 alpha NA
## 5 beta NA
## 6 gamma 1.000
## 7 eta 0.123
## 8 epsilon NA
## 9 lambda NA
## 10 pi NA
## 11 tau 0.789
##
## [[2]]
## Metric Value
## 1 Accuracy 65.00
## 2 LogL -354.86
## 3 LogPr NA
## 4 LogPo NA
## 5 AIC 713.72
## 6 BIC 721.49
RSTD
binaryRL.res <- binaryRL::run_m(
mode = "replay",
data = binaryRL::Mason_2024_G2,
id = 1,
n_params = 3,
n_trials = 360,
eta = c(0.123, 0.456),
tau = c(0.789),
priors = NULL
)
summary(binaryRL.res)
## Results of RSTD Model (replay):
## Estimation Method: NA
## Exploration and Exploitation Trade-off:
## Initial Values: Initial reward received
## Exploration Strategy: off
## Upper-Confidence-Bound: off
## Soft-Max: on
## Model Fit:
## Accuracy: 68.33%
## Log-Likelihood: -340.52
## Log-Prior Probability: NA
## Log-Posterior Probability: NA
## AIC: 687.04
## BIC: 698.7
## Free Parameters:
## α: NA
## β: NA
## γ: 1
## η: 0.123, 0.456
## ε: NA
## λ: NA
## π: NA
## τ: 0.789
## [[1]]
## Parameter Value1 Value2
## 1 Q1 NA NA
## 2 threshold 1.000 NA
## 3 lapse 0.020 NA
## 4 alpha NA NA
## 5 beta NA NA
## 6 gamma 1.000 NA
## 7 eta 0.123 0.456
## 8 epsilon NA NA
## 9 lambda NA NA
## 10 pi NA NA
## 11 tau 0.789 NA
##
## [[2]]
## Metric Value
## 1 Accuracy 68.33
## 2 LogL -340.52
## 3 LogPr NA
## 4 LogPo NA
## 5 AIC 687.04
## 6 BIC 698.70
Utility
binaryRL.res <- binaryRL::run_m(
mode = "replay",
data = binaryRL::Mason_2024_G2,
id = 1,
n_params = 3,
n_trials = 360,
eta = c(0.123),
gamma = c(0.456),
tau = c(0.789),
priors = NULL
)
summary(binaryRL.res)
## Results of Utility Model (replay):
## Estimation Method: NA
## Exploration and Exploitation Trade-off:
## Initial Values: Initial reward received
## Exploration Strategy: off
## Upper-Confidence-Bound: off
## Soft-Max: on
## Model Fit:
## Accuracy: 56.94%
## Log-Likelihood: -261.39
## Log-Prior Probability: NA
## Log-Posterior Probability: NA
## AIC: 528.78
## BIC: 540.44
## Free Parameters:
## α: NA
## β: NA
## γ: 0.456
## η: 0.123
## ε: NA
## λ: NA
## π: NA
## τ: 0.789
## [[1]]
## Parameter Value1
## 1 Q1 NA
## 2 threshold 1.000
## 3 lapse 0.020
## 4 alpha NA
## 5 beta NA
## 6 gamma 0.456
## 7 eta 0.123
## 8 epsilon NA
## 9 lambda NA
## 10 pi NA
## 11 tau 0.789
##
## [[2]]
## Metric Value
## 1 Accuracy 56.94
## 2 LogL -261.39
## 3 LogPr NA
## 4 LogPo NA
## 5 AIC 528.78
## 6 BIC 540.44
Prospect
func_prospect <- function(
i, L_freq, R_freq, L_pick, R_pick, L_value, R_value, var1 = NA, var2 = NA,
value, utility, reward, occurrence,
gamma, alpha, beta
){
# Stevens's Power Law
if (length(gamma) == 1) {
gamma <- as.numeric(gamma)
utility <- sign(reward) * (abs(reward) ^ gamma)
}
# Prospect Theory
else if (length(gamma) == 2 & reward < 0) {
gamma <- as.numeric(gamma[1])
beta <- as.numeric(beta)
utility <- beta * sign(reward) * (abs(reward) ^ gamma)
}
else if (length(gamma) == 2 & reward >= 0) {
gamma <- as.numeric(gamma[2])
beta <- 1
utility <- beta * sign(reward) * (abs(reward) ^ gamma)
}
else {
utility <- "ERROR"
}
return(list(gamma, utility))
}
binaryRL.res <- binaryRL::run_m(
mode = "replay",
name = "Prospect",
data = binaryRL::Mason_2024_G2,
id = 1,
n_params = 5,
n_trials = 360,
eta = c(0.5),
gamma = c(0.12, 0.89),
tau = c(0.34),
beta = c(1.56),
util_func = func_prospect,
priors = NULL
)
summary(binaryRL.res)
## Results of Prospect Model (replay):
## Estimation Method: NA
## Exploration and Exploitation Trade-off:
## Initial Values: Initial reward received
## Exploration Strategy: off
## Upper-Confidence-Bound: off
## Soft-Max: on
## Model Fit:
## Accuracy: 56.94%
## Log-Likelihood: -346.63
## Log-Prior Probability: NA
## Log-Posterior Probability: NA
## AIC: 703.26
## BIC: 722.69
## Free Parameters:
## α: NA
## β: 1.56
## γ: 0.12, 0.89
## η: 0.5
## ε: NA
## λ: NA
## π: NA
## τ: 0.34
## [[1]]
## Parameter Value1 Value2
## 1 Q1 NA NA
## 2 threshold 1.00 NA
## 3 lapse 0.02 NA
## 4 alpha NA NA
## 5 beta 1.56 NA
## 6 gamma 0.12 0.89
## 7 eta 0.50 NA
## 8 epsilon NA NA
## 9 lambda NA NA
## 10 pi NA NA
## 11 tau 0.34 NA
##
## [[2]]
## Metric Value
## 1 Accuracy 56.94
## 2 LogL -346.63
## 3 LogPr NA
## 4 LogPo NA
## 5 AIC 703.26
## 6 BIC 722.69