elasticities: Compute aggregate elasticities

View source: R/methods.R

elasticities.choicer_hbR Documentation

Compute aggregate elasticities

Description

Computes a J x J matrix of aggregate elasticities. Entry (i, j) is the percentage change in the probability of choosing alternative i when the attribute of alternative j changes by 1\

Usage

## S3 method for class 'choicer_hb'
elasticities(object, elast_var, eps = 0.01, n_draws = 100L, ...)

elasticities(object, ...)

Arguments

object

A fitted model object.

elast_var

Structural covariate to perturb (hierarchical Bayes methods).

eps

Relative perturbation size (default 0.01).

n_draws

Number of posterior draws to integrate over.

...

Additional arguments passed to methods.

Value

A J x J elasticity matrix with alternative labels.

Methods (by class)

  • elasticities(choicer_hb): Posterior-mean aggregate arc elasticities for hierarchical Bayes fits: each inside alternative's elast_var is perturbed by eps (default 1%) and shares are recomputed per posterior draw with a common random-coefficient path, giving E_{jk} = (\Delta s_j / s_j) / \epsilon. Rows are responding alternatives (including the outside option), columns the perturbed alternative.

Examples


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


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