Skip to contents

This helper function returns the covariates and the choices of specific choice occasions.

Usage

get_cov(x, id = NULL, idc = NULL, id_label = NULL, idc_label = NULL)

Arguments

x

Either an object of class RprobitB_data or RprobitB_fit.

id, idc

[integer() | NULL]
Identifiers for deciders and choice occasions.

If NULL, everything is returned.

id_label, idc_label

[character(1) | NULL]
The columns that contain the decider and choice occasion identifier.

If NULL, this information is extracted from x.

Value

A subset of the choice_data data frame specified in prepare_data().

Examples

data <- simulate_choices(
  form = product ~ price,
  N = 10,
  T = 1:10,
  J = 3,
  ranked = TRUE
)
get_cov(data, id = 2)
#>   id idc    price_A    price_B    price_C product
#> 2  2   1 -0.7832629  1.4813826 -0.1431028   C,B,A
#> 3  2   2  1.5774726 -0.1866137 -0.6471860   B,A,C