extract_av_cols: Extract the availabilites matrix from the dataset using a...

Description Usage Arguments Value Examples

View source: R/helper_functions.R

Description

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

Usage

1

Arguments

data

The dataset used in the model

prefix

The prefix of the availability columns, i.e. avail_

Value

Matrix of availabilities for alternatives and the number of choice observations

Examples

1
2
3
4
5
6
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_')

mixl documentation built on Dec. 11, 2021, 9:07 a.m.