fit_ideal_adaptor: Fit ideal adaptor

View source: R/fit-IA-stanfit.R

fit_ideal_adaptorR Documentation

Fit ideal adaptor

Description

Infers a prior and posterior distribution of ideal adaptors from the input data using Stan. Currently, three types of ideal adaptor models are available, each using a conjugate prior over Gaussian or multivariate Gaussian categories:

Usage

fit_ideal_adaptor(
  staninput,
  file = NULL,
  file_refit = "never",
  file_compress = T,
  stanvars = NULL,
  backend = "rstan",
  save_pars = NULL,
  basis = NULL,
  chains = 4,
  iter = 2000,
  warmup = 1000,
  init = "random",
  control = NULL,
  silent = 1,
  verbose = F,
  stan_model_args = list(),
  stanmodel = NULL,
  rename = T,
  ...
)

Arguments

staninput

A list of the type returned by make_staninput.

file

Either NULL or a character string. In the latter case, the fitted model object is saved via saveRDS in a file named after the string supplied in file. The .rds extension is added automatically. If the file already exists, the model from that file will be loaded and returned instead of refitting the model. As existing files won't be overwritten, you have to manually remove the file in order to refit and save the model under an existing file name. The file name is stored in the ideal_adaptor_stanfit object for later use. (default: NULL)

file_refit

Modifies when the fit stored via the file argument is re-used. For "never" (default) the fit is always loaded if it exists and fitting is skipped. For "always" the model is always refitted. If set to "on_change", model will be refit if data passed to Stan differ from what is stored in the file. Refit will not be triggered for changes in additional parameters of the fit (e.g., initial values, number of iterations, control arguments, ...).

file_compress

Logical or a character string, specifying one of the compression algorithms supported by saveRDS. If the file argument is provided, this compression will be used when saving the fitted model object.

backend

Character string naming the package to use as the backend for fitting the Stan model. Options are "rstan" (the default) or "cmdstanr". Details on the rstan and cmdstanr packages are available at https://mc-stan.org/rstan/ and https://mc-stan.org/cmdstanr/, respectively.

silent

Verbosity level between 0 and 2. If 1 (the default), most of the informational messages of compiler and sampler are suppressed. If 2, even more messages are suppressed. The actual sampling progress is still printed. Set refresh = 0 to turn this off as well. If using backend = "rstan" you can also set open_progress = FALSE to prevent opening additional progress bars.

stan_model_args

A list of further arguments passed to rstan::stan_model for backend = "rstan" or to cmdstanr::cmdstan_model for backend = "cmdstanr", which allows to change how models are compiled.

stanmodel

Name of stanmodel that should be used. Overrides any default selection.

rename

For internal use only.

...

Additional parameters are passed to sampling.

Details

  • NIW_ideal_adaptor: A Normal-Inverse-Wishart (NIW) prior over the ideal adaptor. This is the default model with multivariate Gaussian categories. Accepts univariate and multivariate input, though the NIX model should be faster for univariate input.

  • NIX_ideal_adaptor: A Normal-Inverse-Chisquare (NIX) prior over the ideal adaptor with with univariate Gaussian categories. Accepts only univariate input.

  • MNIX_ideal_adaptor: Separate NIXs for each of multiple cues that are integrated over during categorization(cue integration) assuming ideal cue weights based on the relative informativity of each cue. Accepts univariate and multivariate input, though the NIX model should be faster for univariate input.

In interpreting the inferred parameters, it should be kept in mind that the inferred scatter matrix (e.g., S_0) for the NIW model) includes variability from internal perceptual and/or external environmental noise, in addition to the motor noise that is reflected in production data. This also implies that, if Sigma_0 is provided by the user it should be arguably convolved with an estimate of perceptual noise. This is particularly important if the data you're fitting contains test phases without exposure (e.g., pre-exposure tests).

Make sure to read the notes about the Sigma_0 argument in the help page on make_staninput. Use methods(class = "ideal_adaptor_stanfit") for an overview on available methods.

Value

An object of class ideal_adaptor_stanfit with the fitted stan model.

See Also

is.ideal_adaptor_stanfit for information about ideal_adaptor_stanfit objects, get_draws to draw samples from the stanfit.


hlplab/MVBeliefUpdatr documentation built on July 5, 2025, 6:42 a.m.