RprobitB_data: Create object of class 'RprobitB_data'.

Description Usage Arguments Value

View source: R/RprobitB_data.R

Description

This function creates an object of class RprobitB_data.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
RprobitB_data(
  data,
  choice_data,
  N,
  T,
  J,
  P_f,
  P_r,
  alternatives,
  form,
  re,
  ASC,
  linear_coeffs,
  standardize,
  simulated,
  choice_available,
  true_parameter
)

Arguments

data

A list with the choice data. The list has N elements. Each element is a list with two elements, X and y, which are the covariates and decisions for a decision maker. More precisely, X is a list of T elements, where each element is a matrix of dimension Jx(P_f+P_r) and contains the characteristics for one choice occasion. y is a vector of length T and contains the labels for the chosen alternatives.

choice_data

A data frame of choice data in "wide" format (i.e. each row represents one choice occasion) with the following requirements:

  • It must contain a column named id which contains unique identifier for each decision maker.

  • It can contain a column named choice with the observed choices, where choice must match the name of the dependent variable in form. Such a column is required for model fitting but not for prediction.

  • For each alternative specific covariate p in form and each choice alternative j in alternatives, choice_data must contain a column named p_j.

  • For each covariate q in form that is constant across alternatives, choice_data must contain a column named q.

N

The number (greater or equal 1) of decision makers.

T

The number (greater or equal 1) of choice occasions or a vector of choice occasions of length N (i.e. a decision maker specific number).

J

The number (greater or equal 2) of choice alternatives.

P_f

The number of covariates connected to a fixed coefficient (can be 0).

P_r

The number of covariates connected to a random coefficient (can be 0).

alternatives

A character vector with the names of the choice alternatives. If not specified, the choice set is defined by the observed choices.

form

A formula object that is used to specify the probit model. The structure is choice ~ A | B | C, where

  • A are names of alternative and choice situation specific covariates with a generic coefficient,

  • B are names of choice situation specific covariates with alternative specific coefficients,

  • and C are names of alternative and choice situation specific covariates with alternative specific coefficients.

Separate multiple covariates of one type by a + sign. By default, alternative specific constants (ASCs) are added to the model (for all except for the last alternative). They can be removed by adding +0 in the second spot. See the vignette vignette("data_management", package = "RprobitB") for more details.

re

A character (vector) of covariates of form with random effects. If re = NULL (the default), there are no random effects. To have random effects for the alternative specific constants, include "ASC" in re.

ASC

A boolean, determining whether the model has ASCs.

linear_coeffs

A data frame with the coefficient names and booleans indicating whether they are connected to random effects.

standardize

A character vector of names of covariates that get standardized. Covariates of type 1 or 3 have to be addressed by <covariate>_<alternative>. If standardize = "all", all covariates get standardized.

simulated

A boolean, if TRUE then data is simulated, otherwise data is empirical.

choice_available

A boolean, if TRUE then data contains observed choices.

true_parameter

An object of class RprobitB_parameters.

Value

An object of class RprobitB_data with the arguments of this function as elements.


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