Compare Compositional Effects by Modifying Model Parameters
Source:R/compositionalEffects.R
compositionalEffect.RdComputes 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.
Arguments
- baseline
A
prototypeComputationobject, as created bycompute. 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:
wA K-sized numeric vector of attention weights. Must sum to 1 and all values must be non-negative.
gA numeric vector of sensitivity parameters, one per prototype. All values must be non-negative (>= 0).
prototypesA 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:
diffData frame of probability differences (comparison - baseline). Positive values indicate higher probabilities in the modified condition, negative values indicate lower probabilities.
rrData 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:
Taking the baseline computation's data and parameters
Replacing specified parameters with the new values provided in
...Computing a new prototype analysis with
computeComparing 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