predicted_probability: Predicted Probabilities

View source: R/pred_prob.R

predicted_probabilityR Documentation

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

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.

Value

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

Note

There are no checks that the conditional probability exists, i.e., suppose you wish to condition on, say, B3 = 2 and B4 = 1, yet there is no instance in which B3 is 2 AND B4 is 1. This will result in an uninformative error.

Examples


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)



BGGM documentation built on Sept. 11, 2024, 5:19 p.m.