| elasticities.choicer_hb | R Documentation |
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\
## S3 method for class 'choicer_hb'
elasticities(object, elast_var, eps = 0.01, n_draws = 100L, ...)
elasticities(object, ...)
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. |
A J x J elasticity matrix with alternative labels.
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.
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")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.