| logsum.choicer_hmnl | R Documentation |
Computes the expected maximum utility ("logsum" or inclusive value) for each choice situation, up to the additive constant of the extreme-value error:
MNL: \log \sum_j \exp(V_{ij}).
MXL: E_\beta[\log \sum_j \exp(V_{ij}(\beta))], simulated by
averaging the log-sum-exp across the deterministic Halton draws
(regenerated from object$draws_info). Taking the log-sum-exp of
draw-averaged utilities would understate the expectation (Jensen's
inequality), so a dedicated kernel (mxl_logsum) is used.
NL: \log \sum_b \exp(\lambda_b I_{ib}) with the nest inclusive
value I_{ib} = \log \sum_{j \in b} \exp(V_{ij}/\lambda_b)
(singleton nests have \lambda_b = 1).
When the model includes an outside option, its normalized utility
V = 0 contributes an \exp(0) term to the sum.
## S3 method for class 'choicer_hmnl'
logsum(object, newdata = NULL, n_draws = 200L, ...)
## S3 method for class 'choicer_hmnp'
logsum(object, newdata = NULL, ...)
logsum(object, newdata = NULL, ...)
## S3 method for class 'choicer_mnl'
logsum(object, newdata = NULL, ...)
## S3 method for class 'choicer_mxl'
logsum(object, newdata = NULL, ...)
## S3 method for class 'choicer_nl'
logsum(object, newdata = NULL, ...)
object |
A fitted model object ( |
newdata |
Optional counterfactual data: a data.frame in the fit-time
long format or a list with |
n_draws |
Number of posterior draws to integrate over (hierarchical Bayes methods; thinned evenly from the kept draws). |
... |
Additional arguments passed to methods. |
Logsum levels depend on the ASC normalization (and, more generally,
on any additive utility normalization), so only logsum differences
between scenarios (e.g. via newdata) are meaningful.
Numeric vector with one logsum per choice situation. With a
data.frame newdata, choice situations are ordered by id (as in
predict()).
logsum(choicer_hmnl): Posterior expected logsum for the hierarchical logit:
per choice situation, \log(1 + \sum_j \exp V_j) against the
outside-option anchor, averaged over posterior draws with one
\beta \sim N(b_r, W_r) draw each. Returns the per-task posterior
mean vector.
logsum(choicer_hmnp): The probit expected maximum has no closed form;
simulated-Emax surplus for the HMNP is on the roadmap.
consumer_surplus
library(data.table)
sim <- simulate_mnl_data(N = 500, J = 3, beta = c(0.8, -0.6), seed = 1,
outside_option = FALSE, vary_choice_set = FALSE)
fit <- run_mnlogit(sim$data, "id", "alt", "choice", c("x1", "x2"))
head(logsum(fit))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.