predict.RprobitB_fit: Predict choices

View source: R/predict.RprobitB_fit.R

predict.RprobitB_fitR Documentation

Predict choices

Description

This function predicts the discrete choice behaviour.

Usage

## S3 method for class 'RprobitB_fit'
predict(object, data = NULL, overview = TRUE, digits = 2, ...)

Arguments

object

An object of class RprobitB_fit.

data

Either

  • NULL, using the data in object,

  • an object of class RprobitB_data, for example the test part generated by train_test,

  • or a data frame of custom choice characteristics. It must have the same structure as choice_data used in prepare_data. Missing columns or NA values are set to 0.

overview

[logical(1)]
Summarize the prediction in a confusion matrix?

digits

[integer(1)]
The number of digits of the returned choice probabilities.

...

Currently not used.

Details

Predictions are made based on the maximum predicted probability for each choice alternative.

See the vignette on choice prediction for a demonstration on how to visualize the model's sensitivity and specificity by means of a receiver operating characteristic (ROC) curve.

Value

Either a table if overview = TRUE or a data frame otherwise.

Examples

set.seed(1)
data <- simulate_choices(form = choice ~ cov, N = 10, T = 10, J = 2)
data <- train_test(data, test_proportion = 0.5)
model <- fit_model(data$train)

predict(model)
predict(model, overview = FALSE)
predict(model, data = data$test)
predict(
  model,
  data = data.frame("cov_A" = c(1, 1, NA, NA), "cov_B" = c(1, NA, 1, NA)),
  overview = FALSE
)


RprobitB documentation built on Aug. 26, 2025, 1:08 a.m.