mcmc: Perform Markov chain Monte Carlo simulation for fitting a...

Description Usage Arguments Details Value Examples

View source: R/mcmc.R

Description

This function performs Markov chain Monte Carlo simulation for fitting a (latent class) (mixed) (multinomial) probit model to discrete choice data.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
mcmc(
  data,
  scale = list(parameter = "s", index = 1, value = 1),
  R = 10000,
  B = R/2,
  Q = 1,
  print_progress = TRUE,
  prior = NULL,
  latent_classes = NULL,
  seed = NULL
)

Arguments

data

An object of class RprobitB_data.

scale

A named list of three elements, determining the parameter normalization with respect to the utility scale:

  • parameter: Either "a" (for a linear coefficient of "alpha") or "s" (for a variance of the error-term covariance matrix "Sigma").

  • index: The index of the parameter that gets fixed.

  • value: The value for the fixed parameter.

R

The number of iterations of the Gibbs sampler.

B

The length of the burn-in period, i.e. a non-negative number of samples to be discarded.

Q

The thinning factor for the Gibbs samples, i.e. only every Qth sample is kept.

print_progress

A boolean, determining whether to print the Gibbs sampler progress and the estimated remaining computation time.

prior

A named list of parameters for the prior distributions of the normalized parameters:

  • eta: The mean vector of length P_f of the normal prior for alpha.

  • Psi: The covariance matrix of dimension P_f x P_f of the normal prior for alpha.

  • delta: The concentration parameter of length 1 of the Dirichlet prior for s.

  • xi: The mean vector of length P_r of the normal prior for each b_c.

  • D: The covariance matrix of dimension P_r x P_r of the normal prior for each b_c.

  • nu: The degrees of freedom (a natural number greater than P_r) of the Inverse Wishart prior for each Omega_c.

  • Theta: The scale matrix of dimension P_r x P_r of the Inverse Wishart prior for each Omega_c.

  • kappa: The degrees of freedom (a natural number greater than J-1) of the Inverse Wishart prior for Sigma.

  • E: The scale matrix of dimension J-1 x J-1 of the Inverse Wishart prior for Sigma.

latent_classes

Either NULL or a list of parameters specifying the number and the latent classes:

  • C: The number (greater or equal 1) of latent classes, which is set to 1 per default and is ignored if P_r = 0. If update = TRUE, C equals the initial number of classes.

  • update: A boolean, determining whether to update C. Ignored if P_r = 0. If update = FALSE, all of the following elements are ignored.

  • Cmax: The maximum number of latent classes.

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

  • epsmin: The threshold weight for removing latent classes (between 0 and 1).

  • epsmax: The threshold weight for splitting latent classes (between 0 and 1).

  • distmin: The threshold difference in means for joining latent classes (non-negative).

seed

Set a seed for the Gibbs sampling.

Details

See the vignette "Model fitting" for more details: vignette("model_fitting", package = "RprobitB").

Value

An object of class RprobitB_model.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
## Not run: 
### probit model
p = simulate(form = choice ~ var | 0, N = 100, T = 10, J = 2, seed = 1)
m1 = mcmc(data = p, seed = 1)

### multinomial probit model
mnp = simulate(form = choice ~ var | 0, N = 100, T = 10, J = 3, seed = 1)
m2 = mcmc(data = mnp, seed = 1)

### mixed multinomial probit model
mmnp = simulate(form = choice ~ 0 | var, N = 100, T = 10, J = 3, re = "var",
                seed = 1)
m3 = mcmc(data = mmnp, seed = 1)

### mixed multinomial probit model with 2 latent classes
lcmmnp = simulate(form = choice ~ 0 | var, N = 100, T = 10, J = 3,
                  re = "var", seed = 1, C = 2)
m4 = mcmc(data = lcmmnp, latent_classes = list("C" = 2), seed = 1)

### update of latent classes
m5 = mcmc(data = lcmmnp, latent_classes = list("update" = TRUE), seed = 1)

## End(Not run)

RprobitB documentation built on Nov. 12, 2021, 5:08 p.m.