fit_model: Fit probit model to choice data

View source: R/fit_model.R

fit_modelR Documentation

Fit probit model to choice data

Description

This function performs MCMC simulation for fitting different types of probit models (binary, multivariate, mixed, latent class, ordered, ranked) to discrete choice data.

Usage

fit_model(
  data,
  scale = "Sigma_1,1 := 1",
  R = 1000,
  B = R/2,
  Q = 1,
  print_progress = getOption("RprobitB_progress", default = TRUE),
  prior = NULL,
  latent_classes = NULL,
  fixed_parameter = list(),
  save_beta_draws = FALSE
)

Arguments

data

An object of class RprobitB_data.

scale

[character(1)]
A character which determines the utility scale. It is of the form ⁠<parameter> := <value>⁠, where ⁠<parameter>⁠ is either the name of a fixed effect or ⁠Sigma_<j>,<j>⁠ for the ⁠<j>⁠th diagonal element of Sigma, and ⁠<value>⁠ is the value of the fixed parameter.

R

[integer(1)]
The number of iterations of the Gibbs sampler.

B

[integer(1)]
The length of the burn-in period.

Q

[integer(1)]
The thinning factor for the Gibbs samples.

print_progress

[logical(1)]
Print the Gibbs sampler progress?

prior

[list]
A named list of parameters for the prior distributions. See the documentation of check_prior for details about which parameters can be specified.

latent_classes

[list() | NULL]
Optionally parameters specifying the number of latent classes and their updating scheme. The values in brackets are the default.

  • C (1): The fixed number (greater or equal 1) of (initial) classes.

  • wb_update (FALSE): Set to TRUE for weight-based class updates.

  • dp_update (FALSE): Set to TRUE for Dirichlet process class updates.

  • Cmax (10): The maximum number of latent classes.

The following specifications are used for the weight-based updating scheme:

  • buffer (50): The number of iterations to wait before the next update.

  • epsmin (0.01): The threshold weight for removing a latent class.

  • epsmax (0.7): The threshold weight for splitting a latent class.

  • deltamin (0.1): The minimum mean distance before merging two classes.

  • deltashift (0.5): The scale for shifting the class means after a split.

fixed_parameter

[list]
A named list with fixed parameter values for alpha, C, s, b, Omega, Sigma, Sigma_full, beta, z, or d for the simulation.

See the vignette on model definition for definitions of these variables.

save_beta_draws

[logical(1)]
Save draws for decider-specific coefficient vectors? Usually not recommended, as it requires a lot of storage space.

Value

An object of class RprobitB_fit.

See Also

  • prepare_data() and simulate_choices() for building an RprobitB_data object

  • update() for estimating nested models

  • transform() for transforming a fitted model

Examples

set.seed(1)
form <- choice ~ var | 0
data <- simulate_choices(form = form, N = 100, T = 10, J = 3, re = "var")
model <- fit_model(data = data, R = 1000)
summary(model)


RprobitB documentation built on Aug. 26, 2025, 1:08 a.m.