Functions for non-parametric tests of compliance with rationality axioms.
Functions checkWarp
, checkSarp
and checkGarp
perform exact tests of the Weak Axiom of Revealed Preferences (WARP), the Strong Axiom of Revealed Preferences (SARP) and the Generalized Axiom of Revealed Preferences (GARP) respectively, to check whether the given data are consistent with utility maximization.
checkWarp(x, p, afriat.par= 1)
checkSarp(x, p, afriat.par= 1, method= c("deep", "floyd"))
checkGarp(x, p, afriat.par= 1, method= c("floyd"))
# S3 method for axiomTest
print(x, ...)
# S3 method for axiomTest
summary(object, ...)
data frame or matrix containing the observed quantities, where each row corresponds to an observation and the columns are types of goods, or an object of class axiomTest
for use with print
,
data frame or matrix (of same dimensions as x) containing the corresponding prices,
the Afriat parameter, real number in [0,1], which allows a certain level of error in the optimization of choices; default is 1, ie. no optimization error allowed,
character string: "deep"
for depth-first search (default for Sarp), "floyd"
for Floyd-Warshall algorithm (can be very slow for large datasets when no violations are present),
an object of class axiomTest
as returned by eg. checkWarp
,
additional arguments passed to the print
and summary
methods (unused).
Functions checkWarp
, checkSarp
and checkGarp
return an object of class axiomTest
which may contain the following elements:
violation
logical value, TRUE
if a violation was found,
path
last path taken during depth-first search,
path.strict
(for deep
method) vector of logical values indicating the strictness of direct preference relations in the last path taken,
violators
vector of indices of axiom-violating observations (only the first violators that were found are reported, this is not a complete list),
strict
vector of logical values indicating whether the preferences between reported violators (or path) are strict or not,
direct.violation
logical value, TRUE
if a violation was found in direct preferences,
type
the violated or non-violated rationality axiom,
method
method used for the non-parametric test,
afriat.par
Afriat parameter used in the algorithm.
Rationality axioms can be summarized as follows:
WARP: if X directly prefered to Y and X is not equal to Y, then Y cannot be directly prefered to X (WARP is a necessary condition for the existence of a single-valued utility-maximizing demand function consistent with the data).
SARP: if X (in)directly prefered to Y and X is not equal to Y, then Y cannot be (in)directly prefered to X (SARP is a necessary and sufficient condition for the existence of a single-valued utility-maximizing demand function consistent with the data).
GARP: if X (in)directly prefered to Y, then Y cannot be strictly directly prefered to X (GARP is a necessary and sufficient condition for the existence of a (possibly multiple-valued) utility-maximizing demand function consistent with the data).
If WARP or GARP are violated, then SARP is also violated.
Testing of WARP is straightforward by pairwise comparison of revealed preferences. GARP is tested using the Floyd-Warshall algorithm to find the transitive closure of the direct preference relationship. SARP can be tested either using the Floyd-Warshall algorithm, or using a depth-first search that systematically explores the preference relationship in search of a violating cycle.
Varian, H. R. (1982) The Nonparametric Approach to Demand Analysis, Econometrica, 50(4):945-973.
Varian, H. R. (1984) Microeconomic Analysis. New York/London: Norton, 2nd edition, pp 141-143.
# NOT RUN {
# Check axioms for GARP-violating data:
data(noGarp)
summary(checkGarp(noGarp$x, noGarp$p))
# Check axioms for SARP-consistent data:
data(okSarp)
summary(checkSarp(okSarp$x, okSarp$p))
# }
Run the code above in your browser using DataLab