| diversion_ratios.choicer_hb | R Documentation |
Computes a J x J matrix of diversion ratios. Entry (i, j) is the fraction of demand lost by alternative j that is captured by alternative i when alternative j becomes less attractive.
## S3 method for class 'choicer_hb'
diversion_ratios(object, elast_var, eps = 0.01, n_draws = 100L, ...)
diversion_ratios(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 diversion ratio matrix with alternative labels.
diversion_ratios(choicer_hb): Posterior-mean diversion ratios for
hierarchical Bayes fits, from the same perturbation engine as
elasticities.choicer_hb(): DR(j \to k) is the fraction of the
share alternative j loses (when its elast_var worsens) that flows to
k — including the outside option. Columns are the perturbed
alternative j, rows the receiving alternative k; the diagonal is 0.
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"))
diversion_ratios(fit)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.