Skip to content

Canvas: Revealed Preference — WARP visualisation #19

@yueswater

Description

@yueswater

Overview

Given a finite set of observed price–demand pairs ${(p^t, x^t)}_{t=1}^T$, visualise each budget line and chosen bundle, and annotate whether the dataset satisfies the Weak Axiom of Revealed Preference (WARP).

Background (MWG Ch. 2.F)

Direct revealed preference: $x^s \succ^R x^t$ if $x^s$ was chosen when $x^t$ was affordable:

$$p^s \cdot x^t \leq p^s \cdot x^s$$

WARP: if $x^s \succ^R x^t$, then $x^t \not\succ^R x^s$, i.e.:

$$p^t \cdot x^s > p^t \cdot x^t$$

A violation means the two budget lines "cross" in a way that is inconsistent with any well-behaved preference relation.

Proposed visualisation

  1. Draw each budget line $B^t$ (from $p^t$ and $I^t = p^t \cdot x^t$).
  2. Mark each chosen bundle $x^t$ as a point.
  3. For each pair $(s, t)$ where $x^s$ is affordable under $p^t$: draw a dashed line from $x^t$ to $x^s$ on $B^t$ and check the WARP condition.
  4. Colour pairs green if WARP is satisfied, red if violated.
  5. Print a summary: WARP: ✓ satisfied or WARP: ✗ violated (pairs: [(s,t), ...])

API sketch

observations = [
    {"px": 2, "py": 3, "x": 10, "y": 13.3},
    {"px": 3, "py": 2, "x": 8,  "y": 14.0},
]
canvas.plot_revealed_preference(observations)
# Returns WarpResult(satisfied=True/False, violations=[...])

Tasks

  • WarpResult dataclass
  • WARP checker: $O(T^2)$ pairwise test
  • plot_revealed_preference method on Canvas
  • Green/red annotation for each pair
  • Unit tests: one WARP-satisfying dataset, one violation dataset
  • Documentation

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions