Learn R Programming

BGGM (version 2.1.5)

predicted_probability: Predicted Probabilities

Description

Compute the predicted probabilities for discrete data, with the possibility of conditional predictive probabilities (i.e., at fixed values of other nodes)

Usage

predicted_probability(object, outcome, Y, ...)

Value

A list containing a matrix with the computed probabilities (a row for each predictive sample and a column for each category).

Arguments

object

An object of class posterior_predict

outcome

Character string. Node for which the probabilities are computed.

Y

Matrix (or data frame) of dimensions n (observations) by p (variables). This must include the column names.

...

Compute conditional probabilities by specifying a column name in Y (besides the outcome) and a fixed value. This can include any number of nodes. See example below. Leave this blank to compute unconditional probabilities for outcome.

Examples

Run this code
# \donttest{
Y <- ptsd
fit <- estimate(as.matrix(Y), iter = 150, type = "mixed")

pred <- posterior_predict(fit, iter = 100)

prob <- predicted_probability(pred,
                              Y = Y,
                              outcome = "B3",
                              B4 = 0,
                              B5 = 0)

# }

Run the code above in your browser using DataLab