estimate_twochoiceRL: Estimate behavior in a two-choice decision task

Description Usage Arguments Value Examples

View source: R/estimate_twochoiceRL.R

Description

This function performs parameter estimation to recover behavior in a two-choice decision task

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
estimate_twochoiceRL(
  seed_value = 528,
  data = NULL,
  method = "mle",
  nRes = 5,
  tr_rad = c(1, 5),
  prior_mean = c(NULL, NULL),
  prior_sd = c(NULL, NULL),
  plot = FALSE,
  progress_bar = TRUE
)

Arguments

seed_value

user-specified random value that ensures replication of results. Defaults to 528.

data

simulated two-choice task data

method

parameter estimation technique used; either maximum-likelihood estimation (mle), maximum a posteriori (map) or expectation-maximization with laplace approximation (eml). Defaults to mle.

nRes

number of restarts. Defaults to 5.

tr_rad

starting and maximum allowed trust region radius. Defaults to 1 and 5.

prior_mean

initial prior means of parameters (x1,x2). Set value if method = "map" or "eml".

prior_sd

initial prior standard deviations of parameters (x1,x2). Set value if method = "map" or "eml".

plot

visualize estimation performance between true parameters vs estimated parameters. Defaults to FALSE.

progress_bar

track completion time of estimation procedure. Defaults to TRUE.

Value

A list containing a dataframe of the true and estimated parameter values, the measures of the bias, rmse and pearson correlation of parameters x1 and x2, the posterior hyperparameters (if method = "eml") per iteration, plot (if plot = TRUE) of the relationship between the true and estimated parameter values, and a plot (if method = eml and plot = TRUE) of the posterior hyperparameters per iteration.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# Save simulated task data to a variable, say, data_sim
data_sim <- simulate_twochoiceRL(trials_unique = TRUE)

# Recover behavioral parameters using maximum-likelihood estimation (MLE)
est_mle <- estimate_twochoiceRL(data = data_sim, method = "mle", plot=FALSE)

# View the true and MLE-estimated parameter values
View(est_mle[[1]]$value)

# If plot=TRUE, view correlation plot between the true and MLE-estimated parameter for x1
View(est_mle[[2]])

psuthaharan/twochoiceRL documentation built on Dec. 22, 2021, 9:56 a.m.