RprobitB

RprobitB is an R package that can be used to fit latent class mixed multinomial probit (LCMMNP) models to simulated or empirical data.

License

RprobitB is licensed under the GNU General Public License v3.0.

Contact

Author and Maintainer: Lennart Oelschläger

Do you found a bug or request a feature? Please tell us!

Installing RprobitB

To install the latest version of RprobitB, run install.packages("RprobitB") in your R console.

Using RprobitB

To use RprobitB, follow these steps:

  1. Specify the model, see below for details.
  2. Run RprobitB::rpb(<list of model specifications>).
  3. You get on-screen information and model results in an output folder, see the package vignette for details.

Specifying a LCMMNP model in RprobitB

RprobitB specifications are grouped in the named lists

You can either specify none, all, or selected parameters. Unspecified parameters are set to default values.

model

data

If data = NULL, data is simulated from the model defined by model and parm.

To model empirical data, specify

parm

lcus

init

prior

A priori, parm[["alpha"]] ~ Normal(eta,Psi) with

A priori, parm[["s"]] ~ Dirichlet(delta) with

A priori, parm[["b"]][,c] ~ Normal(xi,D) with

A priori, matrix(parm[["Omega"]][,c],nrow=model[["P_r"]],ncol=model[["P_r"]]) ~ Inverse_Wishart(nu,Theta) with

A priori, parm[["Sigma"]] ~ Inverse_Wishart(kappa,E) with

mcmc

norm

RprobitB automatically normalizes with respect to level by computing utility differences, where model[["J"]] is the base alternative. The normalization with respect to scale can be specified:

out

Default specifications of RprobitB

model

data

NULL

parm

Per default, parameters are randomly drawn.

lcus

init

prior

mcmc

norm

out

Example

The code below fits a mixed multinomial probit model with

to simulated data with

The number of latent classes is updated, because do_lcus = TRUE is set. The Gibbs sampler draws R = 20000 samples. By default, the model is named id = "test" and results are saved in rdir = "tempdir()" (the path of the per-session temporary directory).

set.seed(1)

### model specification
model = list("N" = 100, "T" = sample(10:20,100,replace=TRUE), "J" = 3, "P_f" = 1, "P_r" = 2, "C" = 2)
lcus  = list("do_lcus" = TRUE)
mcmc  = list("R" = 20000)

### start estimation (about 3 minutes computation time)
RprobitB::rpb("model" = model, "lcus" = lcus, "mcmc" = mcmc)