residuals.logitr: Extract Model Residuals

View source: R/methods.R

residuals.logitrR Documentation

Extract Model Residuals

Description

Returns model residuals from an object of class logitr.

Usage

## S3 method for class 'logitr'
residuals(object, fitted = NULL, ...)

Arguments

object

is an object of class logitr (a model estimated using the 'logitr()' function).

fitted

Fitted values for an object of class logitr to use in computing residuals. Defaults to NULL.

...

further arguments.

Value

A data frame of the obsID and the residuals (response minus fitted values) extracted from object.

Examples

library(logitr)

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

# Extract the residuals from the model
residuals(mnl_pref)

jhelvy/logitr documentation built on Oct. 3, 2023, 2:33 p.m.