Skip to contents

Computes the difference in conditional probabilities and relative risk ratios between a baseline prototype computation and a modified version where specific parameters are changed. This function provides a streamlined way to analyze how changes in attention weights, sensitivity parameters, or prototype definitions affect the resulting probability distributions and category assignments.

Usage

compositionalEffect(baseline, ..., s = 1000)

Arguments

baseline

A prototypeComputation object, as created by compute. This serves as the baseline condition from which specific parameters will be modified for comparison.

...

Named arguments specifying the parameters to modify. Must be one or more of:

w

A K-sized numeric vector of attention weights. Must sum to 1 and all values must be non-negative.

g

A numeric vector of sensitivity parameters, one per prototype. All values must be non-negative (>= 0).

prototypes

A list of prototype vectors. Each prototype must be a binary vector of the same length as the number of features in the baseline data.

All other parameters (data, distance type) are inherited from the baseline.

s

Integer. Number of draws to sample for probability estimation. Default is 1000. Higher values provide more precision but increase computation time.

Value

A compositionalEffect object (inherits from list) containing two data frames:

diff

Data frame of probability differences (comparison - baseline). Positive values indicate higher probabilities in the modified condition, negative values indicate lower probabilities.

rr

Data frame of relative risk ratios (comparison / baseline). Values > 1 indicate higher relative probability in the modified condition, values < 1 indicate lower relative probability, and values = 1 indicate no change.

Both data frames have rows representing categories and columns representing features.

Details

The function creates a modified prototype computation by:

  1. Taking the baseline computation's data and parameters

  2. Replacing specified parameters with the new values provided in ...

  3. Computing a new prototype analysis with compute

  4. Comparing conditional feature probabilities P(X|C) between baseline and modified versions

The comparison metrics computed are:

  • Difference: modified_prob - baseline_prob

  • Relative Risk: modified_prob / baseline_prob

This approach allows for systematic sensitivity analysis by modifying one parameter at a time while holding others constant.

See also

compute for creating prototypeComputation objects, summary.prototypeComputation for the underlying probability calculations