Skip to contents

Advanced Options for Cognitive Models

Usage

cm_options(
  lb = NULL,
  ub = NULL,
  start = NULL,
  fit = TRUE,
  fit_measure = "loglikelihood",
  fit_args = list(),
  fit_data = NULL,
  solver = "auto",
  solver_args = list()
)

Arguments

lb

Named numeric vector, minimum values that a parameter may take: c(k = -10) lets a parameter k start at -10.

ub

Named numeric vector, maximum value that parameters may take: c(k = 10) lets a parameter k go until 10.

start

Named numeric vector, start value for parameters: c(k = 5) lets a parameter k start at 5 in the optimiuation.

fit

Logical (default TRUE), FALSE disables parameter fitting. Useful for testing models.

fit_measure

A string (default "loglikelihood"), the goodnes of fit measure that is optimized during parameter estimation. Can be one of the types in the function cognitiveutils::gof():

  • "loglikelihood". Uses a binomial PDF in models with discrete data. Uses a normal PDF \(N(\mu, \sigma)\) in models with continuous data: \(\mu\)=predictions, \(\sigma\)=constant, estimated as additional free paramter. To change the PDF set fit_args = list(pdf = "xxx")

  • "mse" is mean-squared error

  • "accuracy" is percent accuracy

fit_args

A named list, additional arguments for fitting, can be arguments to the function cognitiveutils::gof(), such as

  • list(n = 30) assumes each row in data is the mean of 30 observations. Useful to fit aggregated data.

  • list(pdf = "multinom") uses a multinomial PDF in the log-likelihood

  • list(pdf = "truncnorm", a = 0, b = 1) uses a truncated normal PDF in the log-likelihood

fit_data

A data frame, the data to estimate the model parameters from. Needed if the data for the parameter estimation differs from the data in the main data argument in a model.

solver

A string, the alorithm to optinize the free parameters. Run cm_solvers() to list the options. Changing this may cause warnings about ignored options and may cause parameter bounds to be ignored and the model to fail. Examples:

  • "grid" uses a grid search with a regular grid

  • "solnp" uses solnp

  • ... and 21 other solvers such as "optimx", "nloptr", and "nlminb" from ROI, see ROI::ROI_available_solvers()

  • c("grid", "xxx") uses a grid-plus-optimization, where xxx is a solver: A grid search, followed by an optimization with xxx using the n best solutions as start values in the optimization; the overal best parameter result wins; n can be set by changing solver_args$nbest.

solver_args

(optional) A list, additional arguments that are passed directly to the optimization solver

  • list(offset = ) A small number by which to offset the parameters from their boundaries when solver = "grid".

  • list(nsteps = ) A number, number of steps for each parameter in the regular grid, for solver = "grid").

  • list(nbest = ) Number of best solutions used as starting values in a grid-plus-optimization, for solver = c("grid", "xxx").

  • list(control = ) control arguments in the solver (solnp)Rsolnp::solnp() and the ROI solvers