Learn R Programming

logitr (version 1.1.2)

model.matrix.logitr: Construct Design Matrices

Description

Creates a design (or model) matrix, e.g., by expanding factors to a set of dummy variables (depending on the contrasts) and expanding interactions similarly.

Usage

# S3 method for logitr
model.matrix(object, ...)

Value

A design matrix

Arguments

object

an object of an appropriate class. For the default method, a model formula or a terms object.

...

further arguments.

Examples

Run this code
library(logitr)

# Estimate a preference space model
mnl_pref <- logitr(
  data    = yogurt,
  outcome = "choice",
  obsID   = "obsID",
  pars    = c("price", "feat", "brand")
)

# Get the model.matrix design matrix
model.matrix(mnl_pref)

Run the code above in your browser using DataLab