RprobitB_data: Create object of class 'RprobitB_data'

View source: R/data_management.R

RprobitB_dataR Documentation

Create object of class RprobitB_data

Description

This function constructs an object of class RprobitB_data.

Usage

RprobitB_data(
  data,
  choice_data,
  N,
  T,
  J,
  P_f,
  P_r,
  alternatives,
  ordered,
  ranked,
  base,
  form,
  re,
  ASC,
  effects,
  standardize,
  simulated,
  choice_available,
  true_parameter,
  res_var_names
)

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.

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). Per default, T = 1.

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. If ordered = TRUE, alternatives is assumed to be specified with the alternatives ordered from worst to best.

ordered

A boolean, FALSE per default. If TRUE, the choice set alternatives is assumed to be ordered from worst to best.

ranked

TBA

base

A character, the name of the base alternative for covariates that are not alternative specific (i.e. type 2 covariates and ASCs). Ignored and set to NULL if the model has no alternative specific covariates (e.g. in the ordered probit model). Per default, base is the last element of alternatives.

form

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

  • choice is the name of the dependent variable (the choices),

  • A are names of alternative and choice situation specific covariates with a coefficient that is constant across alternatives,

  • 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.

Multiple covariates (of one type) are separated by a + sign. By default, alternative specific constants (ASCs) are added to the model. They can be removed by adding +0 in the second spot.

In the ordered probit model (ordered = TRUE), the formula object has the simple structure choice ~ A. ASCs are not estimated.

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 ASCs, include "ASC" in re.

ASC

A boolean, determining whether the model has ASCs.

effects

A data frame with the effect 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.

res_var_names

A names list of reserved variable names in choice_data.

Value

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


RprobitB documentation built on May 29, 2024, 7:59 a.m.