Skip to contents

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.

Usage

# 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, ...)

Arguments

object

A fitted model object (choicer_mnl, choicer_mxl, or choicer_nl).

newdata

Optional counterfactual data: a data.frame in the fit-time long format or a list with X, alt_idx, M (plus W for MXL), as in predict(). When NULL (default), the data stored at fit time is used (requires keep_data = TRUE).

n_draws

Number of posterior draws to integrate over (hierarchical Bayes methods; thinned evenly from the kept draws).

...

Additional arguments passed to methods.

Value

Numeric vector with one logsum per choice situation. With a data.frame newdata, choice situations are ordered by id (as in predict()).

Details

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.

Methods (by class)

  • 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.

See also

Examples

# \donttest{
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"))
#> Optimization run time 0h:0m:0s
head(logsum(fit))
#> [1] 1.1893076 1.5710443 1.4462352 0.2674369 0.6492900 1.4766210
# }