| predict.RprobitB_fit | R Documentation |
Computes occasion-level choice probabilities over the retained posterior draws and predicts the alternative with the largest mean probability.
## S3 method for class 'RprobitB_fit'
predict(
object,
newdata = NULL,
type = c("population", "conditional"),
uncertainty = FALSE,
level = 0.95,
ghk_draws = 500L,
progress = interactive(),
...
)
object |
[ |
newdata |
[ |
type |
[
|
uncertainty |
[ |
level |
[ |
ghk_draws |
[ |
progress |
[ |
... |
Currently not used. |
Conditional prediction is based on the individual-level parameters (Train,
2009, Chapters 11 and 12): the posterior distribution of a decider's
coefficients given their observed choices, which the Gibbs sampler
provides as draws when the model is fitted with
save_individual_draws = TRUE.
A data.frame with one row per choice occasion, identifier columns,
.prediction, and one probability_* column per alternative. If
uncertainty = TRUE, sd_*, lower_*, and upper_* columns are added.
Train2009RprobitB
set.seed(1)
model <- fit(
choice ~ x | 0,
random_effects = "x",
dgp_parameters = list(beta = c(x = 1), Omega = matrix(0.5)),
n_deciders = 20,
iterations = 300,
warmup = 150,
chains = 1,
save_individual_draws = TRUE
)
head(predict(model))
head(predict(model, type = "conditional"))
head(predict(model, uncertainty = TRUE))
### new choice occasions
new_data <- data.frame(deciderID = 21:22, x_A = c(1, -1), x_B = c(0, 0))
predict(model, newdata = new_data)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.