Skip to contents

Fit a LATER model to a single dataset or a pair of datasets.

Usage

fit_data(
  data,
  share_a = FALSE,
  share_sigma = FALSE,
  share_sigma_e = FALSE,
  with_early_component = FALSE,
  intercept_form = FALSE,
  use_minmax = FALSE,
  fit_criterion = "likelihood",
  jitter_settings = list(n = 7, prop = 0.5, seed = NA, processes = 2)
)

Arguments

data

A data frame with columns name and promptness.

share_a, share_sigma, share_sigma_e

If FALSE (the default), each dataset has its own parameter. If TRUE, the datasets share the relevant parameter.

with_early_component

If TRUE, the model contains a second 'early' component that is absent when FALSE (the default).

intercept_form

If FALSE (the default), the a parameter describes the mu parameter in the model; if TRUE, the a parameter describes the k parameter in the model (the intercept).

use_minmax

If FALSE (the default), the optimiser targets the sum of the goodness-of-fit values across datasets; if TRUE, it instead targets the maximum of the goodness-of-fit values across datasets.

fit_criterion

String indicating the criterion used to optimise the fit by seeking its minimum.

  • ks: Kolmogorov-Smirnov statistic.

  • likelihood: Negative log-likelihood.

jitter_settings

Settings for running the fitting multiple times with randomly-generated offsets ('jitter') applied to the starting estimates.

  • n: How many jitter iterations to run (default of 7); the total number of fits is n + 1 (because the un-jittered start points are also fit).

  • prop: The maximum jitter offset, as a proportion of the start value (default of 0.5).

  • seed: Seed for the random jitter generator (default is unseeded).

  • processes: Maximum number of CPU processes that can be used (default is 2).

Value

A list of fitting arguments and outcomes.

  • fitted_params is a named list of fitted parameter values.

  • named_fit_params is a data frame with rows given by the dataset names and columns given by the parameter names.

  • loglike is the overall log-likelihood of the fit.

  • aic is the "Akaike's 'An Information Criterion'" value for the model.

  • optim_result is the raw output from stats::optim for the best fit.

  • jitter_optim_results contains the raw output from each call to stats::optim for the different start points.

Examples

# \donttest{
data <- data.frame(name = "test", promptness = rnorm(100, 3, 1))
data_other <- data.frame(name = "test_2", promptness = rnorm(100, 1, 1))
fit_shared_sigma <- fit_data(
  data = rbind(data, data_other), share_sigma = TRUE
)
# }