Skip to contents

Generates posterior draws of conditional probabilities from a prototype computation, either P(X|C) (feature probabilities given categories) or P(C|X) (category probabilities given feature values). This function is primarily used internally by other functions but can be useful for uncertainty quantification.

Usage

conditionalProbsSample(x, type = c("features", "categories"), s = 500)

Arguments

x

A prototypeComputation object created by compute.

type

Character string specifying the type of conditional probabilities:

"features"

Returns P(X|C) - probability of features given categories

"categories"

Returns P(C|X) - probability of categories given feature values

s

Integer. Number of posterior draws to sample. Default is 500. Higher values provide more stable estimates but increase computation time.

Value

The return structure depends on the type parameter:

For type = "features": A list with one element per category, where each element is an s × K matrix of feature probabilities (K = number of features).

For type = "categories": A list with one element per feature, where each element is an s × n_categories × 2 array showing category probabilities for feature values 0 and 1.

Details

The function implements a sampling-based approach to estimate conditional probabilities:

1. For each observation, sample category assignments based on the computed membership probabilities 2. Repeat this process s times to create multiple datasets 3. Calculate conditional probabilities from each sampled dataset

This approach captures the uncertainty in category assignments and provides a distribution of conditional probability estimates rather than point estimates.

See also

conditionalProbs for point estimates of conditional probabilities, summary.prototypeComputation for summary statistics, compute for creating prototypeComputation objects