Budgets#

Budget Choices

Budget choices. CCEI measures how much budgets must shrink to remove contradictions.

Budget analysis starts with a sequence of shopping trips. Each trip records the prices that were available and the quantities that were bought. From this, PrefGraph builds a directed graph where an edge from trip A to trip B means the bundle from B was affordable at A’s prices but was not chosen.

GARP checks whether this graph contains preference cycles. CCEI measures how much budgets must shrink before the cycles disappear. MPI finds the costliest cycle. Houtman-Maks counts the fewest trips to drop to eliminate all cycles. Scores closer to 1 indicate behavior that is more consistent with utility maximization.

from prefgraph import BehaviorLog, validate_consistency, compute_integrity_score
import numpy as np

# 3 shopping trips, 2 goods — rows are observations, columns are goods
prices = np.array([[2.0, 1.0], [1.0, 2.0], [1.5, 1.5]])
quantities = np.array([[3.0, 2.0], [2.0, 3.0], [2.5, 2.5]])
log = BehaviorLog(cost_vectors=prices, action_vectors=quantities)

# GARP: does a consistent utility function exist? (True/False)
garp = validate_consistency(log)
# CCEI: how much must budgets shrink to remove contradictions? (0–1)
ccei = compute_integrity_score(log)
print(f"GARP consistent: {garp.is_consistent}")
print(f"CCEI: {ccei.efficiency_index:.4f}")
GARP consistent: False
CCEI: 0.8750

Engine.analyze_arrays() scores thousands of users in one Rust-backed batch call, running GARP, CCEI, MPI, HM, HARP, VEI, and a utility feasibility check. The per-user Functions API adds everything the Engine does not yet batch, including recovered utility vectors, welfare measurement, the Slutsky matrix, separability tests, and spatial preference recovery.

Theory#

Tutorials#

Applications#

Examples#