Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

recodeData

Recode a data frame to create dummy-coded categorical and interaction variables.


Description

Recodes a list of a dataframe (data) and two vectors (parNames and randPars) with discrete (categorical) variables and interaction variables added to the data frame as well as the parNames and randPars. This function is used internally inside the main logitr() function but is also exported for use in other libraries.

Usage

recodeData(data, parNames, randPars)

Arguments

data

The choice data, formatted as a data.frame object.

parNames

The names of the parameters to be estimated in the model. Must be the same as the column names in the data argument. For WTP space models, do not include price in parNames.

randPars

A named vector whose names are the random parameters and values the distribution: 'n' for normal or 'ln' for log-normal. Defaults to NULL.

Value

A list of a dataframe (data) and two vectors (parNames and randPars) with discrete (categorical) variables and interaction variables added.

Examples

data(yogurt)

result <- recodeData(
    data = yogurt,
    parNames = c("price", "feat", "brand", "price*brand"),
    randPars = c(feat = "n", brand = "n")
)

result$parNames
result$randPars
head(result$data)

logitr

Logit Models w/Preference & WTP Space Utility Parameterizations

v0.1.0
MIT + file LICENSE
Authors
John Helveston [aut, cre, cph] (<https://orcid.org/0000-0002-2657-9191>)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.