model.matrix.logitr: Construct Design Matrices

View source: R/methods.R

model.matrix.logitrR Documentation

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 class 'logitr'
model.matrix(object, ...)

Arguments

object

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

...

further arguments.

Value

A design matrix

Examples

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)

logitr documentation built on Sept. 29, 2023, 5:06 p.m.