View source: R/model_Utility.R
Utility | R Documentation |
U(R) = {R}^{\gamma}
V_{new} = V_{old} + \eta \cdot (U(R) - V_{old})
Utility(params)
params |
[vector] algorithm packages accept only one argument |
loss [numeric]
algorithm packages accept only one return
## Not run:
Utility <- function(params) {
res <- binaryRL::run_m(
data = data,
id = id,
eta = c(params[1]),
gamma = c(params[2]),
tau = c(params[3]),
priors = priors,
n_params = n_params,
n_trials = n_trials,
mode = mode,
policy = policy
)
assign(x = "binaryRL.res", value = res, envir = binaryRL.env)
loss <- switch(EXPR = estimate, "MLE" = -res$ll, "MAP" = -res$lpo)
switch(EXPR = mode, "fit" = loss, "simulate" = res, "replay" = res)
}
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.