elasticities.choicer_nl: Elasticities for nested logit model

View source: R/methods.R

elasticities.choicer_nlR Documentation

Elasticities for nested logit model

Description

Elasticities for nested logit model

Usage

## S3 method for class 'choicer_nl'
elasticities(object, elast_var, ...)

Arguments

object

A choicer_nl object fitted with keep_data = TRUE.

elast_var

Variable for elasticity computation: a column name (character) or 1-based index into the design matrix X.

...

Additional arguments (ignored).

Value

A J x J elasticity matrix with alternative labels.

Examples


library(data.table)
set.seed(42)
N <- 50; J <- 4
dt <- data.table(id = rep(1:N, each = J), alt = rep(1:J, N))
dt[, nest := rep(c(1L, 1L, 2L, 2L), N)]
dt[, `:=`(x1 = rnorm(.N), x2 = rnorm(.N))]
dt[, choice := 0L]
dt[, choice := sample(c(1L, rep(0L, J - 1))), by = id]
fit <- run_nestlogit(dt, "id", "alt", "choice", c("x1", "x2"), "nest")
elasticities(fit, "x1")


choicer documentation built on Sept. 5, 2026, 1:07 a.m.