as_cov_names: Re-label alternative specific covariates

View source: R/data_management.R

as_cov_namesR Documentation

Re-label alternative specific covariates

Description

In {RprobitB}, alternative specific covariates must be named in the format "<covariate>_<alternative>". This convenience function generates the format for a given choice_data set.

Usage

as_cov_names(choice_data, cov, alternatives)

Arguments

choice_data

A data.frame of choice data in wide format, i.e. each row represents one choice occasion.

cov

A character vector of the names of alternative specific covariates in choice_data.

alternatives

A (character or numeric) vector of the alternative names.

Value

The choice_data input with updated column names.

Examples

data("Electricity", package = "mlogit")
cov <- c("pf", "cl", "loc", "wk", "tod", "seas")
alternatives <- 1:4
colnames(Electricity)
Electricity <- as_cov_names(Electricity, cov, alternatives)
colnames(Electricity)


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