extract_av_cols function

Extract the availabilites matrix from the dataset using a column name prefix

Extract the availabilites matrix from the dataset using a column name prefix

extract_av_cols(data, prefix)

Arguments

  • data: The dataset used in the model
  • prefix: The prefix of the availability columns, i.e. avail_

Returns

Matrix of availabilities for alternatives and the number of choice observations

Examples

data("Train", package="mlogit") Train$ID <- Train$id Train$CHOICE <- as.numeric(Train$choice) Train$avail_A <- sample(2, replace=TRUE, size=nrow(Train))-1 Train$avail_B <- sample(2, replace=TRUE, size=nrow(Train))-1 extract_av_cols(Train, 'avail_')
  • Maintainer: Joseph Molloy
  • License: GPL (>= 2)
  • Last published: 2024-02-07