Cross-tabulates the chosen alternative against the modal predicted
alternative (weighted by the frequency weights), with the share correctly
classified and the proportional reduction in error relative to always
predicting the most frequent alternative. Modal classification understates a
model's value for minority alternatives: a case with probability 0.4 on a
rare alternative is classified to the common one even though 0.4 may be far
above its base rate; see the probability-based measures in fit_stats().
Arguments
- object
A
"choicemodel"fit.- newdata
Optional data frame (same layout as the fit) with the response; default the estimation cases. A hold-out set may lack some alternative or covariate level; only the response and the predictors are read from it.
- weights
Optional frequency weights for
newdata(a column name or a vector aligned to its rows); the estimation cases use the fit's weights.- offset
Offset for
newdatawhen the fit has one (seepredict.choicemodel()).
Value
An object of class "pc_classification": a list with table
(observed in rows, predicted in columns), correct, and pre.
See also
Other model comparison:
boot_lr_test(),
compare_models(),
fit_stats(),
lr_test(),
vuong()
Examples
set.seed(1)
d <- rmnl(800, beta = cbind(b = c(0.5, -1, 0.8), c = c(-0.3, 0.6, -0.5)))
classification(mnl(y ~ x1 + x2, data = d))
#> predicted
#> observed a b c
#> a 0 98 89
#> b 0 347 46
#> c 0 73 147
#>
#> Correctly classified: 0.618; proportional reduction in error over the modal alternative: 0.248