alternative: Alternative class

alternativeR Documentation

Alternative class

Description

The 'alternative' R6 class serves to define alternatives to be included into choice sets. The object stores information about the available attributes and their possible values. The values may be specified as vectors using 'c()' function or as random declaration using statistical functions of 'r' type. The object is initialized without attributes and should be later populated with them.

Public fields

attributes

A list of attributes definitions

Methods

Public methods


Method add_attributes()

Append a list of 'call' attributes definitions to the attributes.

Usage
alternative$add_attributes(...)
Arguments
...

The attributes should have a name and generation procedure defined (ex: 'Quality = c(0:1)')


Method get_attributes()

Get a vector of available attributes' names

Usage
alternative$get_attributes()
Returns

Character vector with unique attributes names.


Method get_laws()

Get a list of alternatives' generation rules

Usage
alternative$get_laws()
Returns

Get a list of laws associated to alternative's attributes.


Method clone()

The objects of this class are cloneable with this method.

Usage
alternative$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

Examples

alt <- alternative$new()
alt$add_attributes(Quality = c(0, 1), Price = rnorm(mean = 5))
alt$get_attributes()
alt$get_laws()

nikitagusarov/dcesimulatr documentation built on Jan. 7, 2023, 4:27 p.m.