Title: | Tools for Computational Revealed Preference Analysis |
---|---|
Description: | Tools to (i) check consistency of a finite set of consumer demand observations with a number of revealed preference axioms at a given efficiency level, (ii) compute goodness-of-fit indices when the data do not obey the axioms, and (iii) compute power against uniformly random behavior. |
Authors: | Khushboo Surana [aut, cre] |
Maintainer: | Khushboo Surana <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.0.9000 |
Built: | 2025-01-24 02:38:07 UTC |
Source: | https://github.com/ksurana21/revpref |
The power of the revealed preference test of a given axiom captures the probability of rejecting the axiom if the data set is generated by irrational behavior. Following Bronars' (1987) approach, we measure power using Becker's (1962) notion of irrational behavior. More specifically, we generate irrational behavior by simulating a consumer who makes consumption choices randomly from his or her budget set such that the budget set is exhausted. The Bronars power index captures the probability of rejecting the null hypothesis that the random choices are utility maximizing. Essentially, Bronars' power index is the number of times a violation is detected in the simulated data sets divided by the number of repetitions.
bronars(p, q, simulation = 1000, model = "GARP", efficiency = 1)
bronars(p, q, simulation = 1000, model = "GARP", efficiency = 1)
p |
A |
q |
A |
simulation |
Specifies the number of repetitions required of the simulated random data. The default value is 1000. |
model |
Specifies which axiom (GARP, SARP, or WARP) should be used to compute the power. The default option is "GARP". |
efficiency |
The efficiency level |
The function returns the power of a given axiom against uniformly random behavior at a given efficiency level.
Becker, Gary S. "Irrational behavior and economic theory." Journal of political economy 70, no. 1 (1962): 1-13.
Bronars, Stephen G. "The power of nonparametric tests of preference maximization." Econometrica: Journal of the Econometric Society (1987): 693-698.
# define a price matrix p = matrix(c(4,4,4,1,9,3,2,8,3,1, 8,4,3,1,9,3,2,8,8,4, 1,4,1,8,9,3,1,8,3,2), nrow = 10, ncol = 3, byrow = TRUE) # define a quantity matrix q = matrix(c( 1.81,0.19,10.51,17.28,2.26,4.13,12.33,2.05,2.99,6.06, 5.19,0.62,11.34,10.33,0.63,4.33,8.08,2.61,4.36,1.34, 9.76,1.37,36.35, 1.02,3.21,4.97,6.20,0.32,8.53,10.92), nrow = 10, ncol = 3, byrow = TRUE) # compute Bronars power index for GARP at full efficiency bronars(p,q) # compute Bronars power index for SARP at e = 0.99 bronars(p,q, model = "SARP", efficiency = 0.99)
# define a price matrix p = matrix(c(4,4,4,1,9,3,2,8,3,1, 8,4,3,1,9,3,2,8,8,4, 1,4,1,8,9,3,1,8,3,2), nrow = 10, ncol = 3, byrow = TRUE) # define a quantity matrix q = matrix(c( 1.81,0.19,10.51,17.28,2.26,4.13,12.33,2.05,2.99,6.06, 5.19,0.62,11.34,10.33,0.63,4.33,8.08,2.61,4.36,1.34, 9.76,1.37,36.35, 1.02,3.21,4.97,6.20,0.32,8.53,10.92), nrow = 10, ncol = 3, byrow = TRUE) # compute Bronars power index for GARP at full efficiency bronars(p,q) # compute Bronars power index for SARP at e = 0.99 bronars(p,q, model = "SARP", efficiency = 0.99)
The nonparametric tests of rationality axioms (garp, sarp
, and warp
) are "sharp" in nature.
This means that the tests will only tell us whether the observed data set passed the rationality axioms.
However, when the data set fails, it is often useful to know how close the observed behavior is to
satisfying the rationality restrictions (see Varian (1990) for an extensive motivation). Over the years, several
measures (called goodness-of-fit indices) have been introduced to evaluate the degree to which the data set is consistent
with the rationality axiom(s). The most popular goodness-of-fit index is the Critical Cost Efficiency Index;
CCEI (also known as the Afriat Efficiency Index; AEI) proposed by Afriat (1973). The CCEI is defined as the maximal value of
the efficiency level such that the data set is consistent with GARP. Intuitively, this measure indicates the degree
to which the set of demand observations is consistent with GARP. This function computes the CCEI following the binary
search algorithm described in Varian (1990). Optionally, the user can specify the axiom (WARP, SARP, or GARP) for which
the CCEI needs to be computed. When no axiom is specified, the function takes the default option as GARP.
ccei(p, q, model = "GARP")
ccei(p, q, model = "GARP")
p |
A |
q |
A |
model |
Specifies which axiom (GARP, SARP, or WARP) should be used to compute the CCEI. The default value is "GARP" which computes the usual CCEI (also known as the Afriat efficiency index, AEI) proposed by Afriat (1973). |
The function returns which is the highest efficiency level at which the data satisfy the
given axiom. For instance, if the given model is "GARP", the function returns the maximal value of the efficiency
level
such that the data satisfy
GARP.
Afriat, Sydney N. "On a system of inequalities in demand analysis: an extension of the classical method." International economic review (1973): 460-472.
Varian, Hal R. "Goodness-of-fit in optimizing models." Journal of Econometrics 46, no. 1-2 (1990): 125-140.
mpi
for the money pump index.
# define a price matrix p = matrix(c(4,4,4,1,9,3,2,8,3,1, 8,4,3,1,9,3,2,8,8,4, 1,4,1,8,9,3,1,8,3,2), nrow = 10, ncol = 3, byrow = TRUE) # define a quantity matrix q = matrix(c( 1.81,0.19,10.51,17.28,2.26,4.13,12.33,2.05,2.99,6.06, 5.19,0.62,11.34,10.33,0.63,4.33,8.08,2.61,4.36,1.34, 9.76,1.37,36.35, 1.02,3.21,4.97,6.20,0.32,8.53,10.92), nrow = 10, ncol = 3, byrow = TRUE) # compute ccei for GARP ccei(p,q, model = "GARP") # compute ccei for SARP ccei(p,q, model = "SARP")
# define a price matrix p = matrix(c(4,4,4,1,9,3,2,8,3,1, 8,4,3,1,9,3,2,8,8,4, 1,4,1,8,9,3,1,8,3,2), nrow = 10, ncol = 3, byrow = TRUE) # define a quantity matrix q = matrix(c( 1.81,0.19,10.51,17.28,2.26,4.13,12.33,2.05,2.99,6.06, 5.19,0.62,11.34,10.33,0.63,4.33,8.08,2.61,4.36,1.34, 9.76,1.37,36.35, 1.02,3.21,4.97,6.20,0.32,8.53,10.92), nrow = 10, ncol = 3, byrow = TRUE) # compute ccei for GARP ccei(p,q, model = "GARP") # compute ccei for SARP ccei(p,q, model = "SARP")
This function allows the user to check whether a given data set is consistent with the Generalized Axiom of Revealed Preference
at efficiency (
GARP) and computes the number of
GARP violations. We say that a data set
satisfies GARP at efficiency level
if
implies
.
It is clear that by setting
, we obtain the standard version of GARP as defined in Varian (1982).
While if
, we allow for some optimization error in the choices to make the data set consistent with GARP.
The smaller the
is, the larger will be the optimization error allowed in the test.
It is well known that GARP is a necessary and sufficient condition for a data set to be rationalized
by a continuous, strictly increasing, and concave preference function (see Afriat (1967) and Varian (1982)).
garp(p, q, efficiency = 1)
garp(p, q, efficiency = 1)
p |
A |
q |
A |
efficiency |
The efficiency level |
The function returns two elements. The first element (passgarp
) is a binary indicator telling us whether
the data set is consistent with GARP at efficiency level . It takes a value 1 if the data set is
GARP
consistent and a value 0 if the data set is
GARP inconsistent. The second element (
nviol
) reports the
number of GARP violations. If the data set is
GARP consistent,
nviol
is 0. Note that the maximum
number of violations in an GARP inconsistent data is
.
For a given efficiency level , we say that:
bundle is directly revealed preferred to bundle
at efficiency level
(denoted as
) if
.
bundle is strictly directly revealed preferred to bundle
at efficiency level
(denoted as
) if
.
bundle is revealed preferred to bundle
at efficiency level
(denoted as
) if there exists a (possibly empty) sequence of observations (
) such that
,
,
.
Afriat, Sydney N. "The construction of utility functions from expenditure data." International economic review 8, no. 1 (1967): 67-77.
Varian, Hal R. "The nonparametric approach to demand analysis." Econometrica: Journal of the Econometric Society (1982): 945-973.
sarp
for the Strong Axiom of Revealed Preference and warp
for
the Weak Axiom of Revealed Preference.
# define a price matrix p = matrix(c(4,4,4,1,9,3,2,8,3,1, 8,4,3,1,9,3,2,8,8,4, 1,4,1,8,9,3,1,8,3,2), nrow = 10, ncol = 3, byrow = TRUE) # define a quantity matrix q = matrix(c( 1.81,0.19,10.51,17.28,2.26,4.13,12.33,2.05,2.99,6.06, 5.19,0.62,11.34,10.33,0.63,4.33,8.08,2.61,4.36,1.34, 9.76,1.37,36.35, 1.02,3.21,4.97,6.20,0.32,8.53,10.92), nrow = 10, ncol = 3, byrow = TRUE) # Test consistency with GARP and compute the number of GARP violations garp(p,q) # Test consistency with GARP and compute the number of GARP violations at e = 0.95 garp(p,q, efficiency = 0.95)
# define a price matrix p = matrix(c(4,4,4,1,9,3,2,8,3,1, 8,4,3,1,9,3,2,8,8,4, 1,4,1,8,9,3,1,8,3,2), nrow = 10, ncol = 3, byrow = TRUE) # define a quantity matrix q = matrix(c( 1.81,0.19,10.51,17.28,2.26,4.13,12.33,2.05,2.99,6.06, 5.19,0.62,11.34,10.33,0.63,4.33,8.08,2.61,4.36,1.34, 9.76,1.37,36.35, 1.02,3.21,4.97,6.20,0.32,8.53,10.92), nrow = 10, ncol = 3, byrow = TRUE) # Test consistency with GARP and compute the number of GARP violations garp(p,q) # Test consistency with GARP and compute the number of GARP violations at e = 0.95 garp(p,q, efficiency = 0.95)
The nonparametric GARP test is "sharp" in nature. This means that the test will only tell us whether the observed data set is consistent with GARP. However, when the data set fails, it is often useful to know how close the observed behavior is to satisfying the rationality restrictions (see Varian (1990) for an extensive motivation). Over the years, several measures (called goodness-of-fit indices) have been introduced to evaluate the degree to which the observed data set is consistent with the rationality axiom. Echenique et al. (2011) proposed the money pump index (MPI) as a measure of the severity of a GARP violation. The MPI is defined as the amount of money that an arbitrageur can pump from the consumer. The higher is the MPI value, the more severe is the violation of rationality. While the MPI measure is conceptually appealing, it may be computationally challenging to determine this index for data sets with a large number of observations. In particular, Smeulders et al. (2013) showed that computing the mean and median MPI is an NP-hard problem. As easy-to-apply alternatives, they proposed the minimum and maximum MPI which can be computed efficiently (in polynomial time). This function implements the algorithm provided by these authors to measure the minimum and maximum MPI values for the given data set.
mpi(p, q)
mpi(p, q)
p |
A |
q |
A |
The function returns two elements. The first element (minimum_MPI
) is the minimum MPI and the second
element (maximum_MPI
) is the maximum MPI.
Echenique, Federico, Sangmok Lee, and Matthew Shum. "The money pump as a measure of revealed preference violations." Journal of Political Economy 119, no. 6 (2011): 1201-1223.
Smeulders, Bart, Laurens Cherchye, Frits CR Spieksma, and Bram De Rock. "The money pump as a measure of revealed preference violations: A comment." Journal of Political Economy 121, no. 6 (2013): 1248-1258.
Varian, Hal R. "Goodness-of-fit in optimizing models." Journal of Econometrics 46, no. 1-2 (1990): 125-140.
ccei
for the critical cost efficiency index.
# define a price matrix p = matrix(c(4,4,4,1,9,3,2,8,3,1, 8,4,3,1,9,3,2,8,8,4, 1,4,1,8,9,3,1,8,3,2), nrow = 10, ncol = 3, byrow = TRUE) # define a quantity matrix q = matrix(c( 1.81,0.19,10.51,17.28,2.26,4.13,12.33,2.05,2.99,6.06, 5.19,0.62,11.34,10.33,0.63,4.33,8.08,2.61,4.36,1.34, 9.76,1.37,36.35, 1.02,3.21,4.97,6.20,0.32,8.53,10.92), nrow = 10, ncol = 3, byrow = TRUE) # compute the minimum and maximum MPI mpi(p,q)
# define a price matrix p = matrix(c(4,4,4,1,9,3,2,8,3,1, 8,4,3,1,9,3,2,8,8,4, 1,4,1,8,9,3,1,8,3,2), nrow = 10, ncol = 3, byrow = TRUE) # define a quantity matrix q = matrix(c( 1.81,0.19,10.51,17.28,2.26,4.13,12.33,2.05,2.99,6.06, 5.19,0.62,11.34,10.33,0.63,4.33,8.08,2.61,4.36,1.34, 9.76,1.37,36.35, 1.02,3.21,4.97,6.20,0.32,8.53,10.92), nrow = 10, ncol = 3, byrow = TRUE) # compute the minimum and maximum MPI mpi(p,q)
This function allows the user to check whether a given data set is consistent with the Strong Axiom of Revealed Preference
at efficiency level (
SARP) and computes the number of
SARP violations.
We say that a data set satisfies SARP at efficiency level
if
implies
(see the definition of
below). It is clear that by setting
, we obtain the standard version of SARP.
While if
, we allow for some optimization error in the choices to make the data set consistent with SARP.
The smaller the
is, the larger will be the optimization error allowed in the test.
It is well known that SARP is a necessary and sufficient condition for a data set to be rationalized
by a continuous, strictly increasing, and strictly concave preference function (see Matzkin and Richter (1991)).
sarp(p, q, efficiency = 1)
sarp(p, q, efficiency = 1)
p |
A |
q |
A |
efficiency |
The efficiency level |
The function returns two elements. The first element (passsarp
) is a binary indicator telling us whether
the data set is consistent with SARP at a given efficiency level . It takes a value 1 if the data set
is
SARP consistent and a value 0 if the data set is
SARP inconsistent.
The second element (
nviol
) reports the number of SARP violations. If the data is
SARP
consistent,
nviol
is 0. Note that the maximum number of violations in an SARP inconsistent data is
.
For a given efficiency level , we say that:
bundle is directly revealed preferred to bundle
at efficiency level
(denoted as
) if
.
bundle is strictly directly revealed preferred to bundle
at efficiency level
(denoted as
) if
.
bundle is revealed preferred to bundle
at efficiency level
(denoted as
) if there exists a (possibly empty) sequence of observations (
) such that
,
,
.
Matzkin, Rosa L., and Marcel K. Richter. "Testing strictly concave rationality." Journal of Economic Theory 53, no. 2 (1991): 287-303.
garp
for the Generalized Axiom of Revealed Preference and warp
for
the Weak Axiom of Revealed Preference.
# define a price matrix p = matrix(c(4,4,4,1,9,3,2,8,3,1, 8,4,3,1,9,3,2,8,8,4, 1,4,1,8,9,3,1,8,3,2), nrow = 10, ncol = 3, byrow = TRUE) # define a quantity matrix q = matrix(c( 1.81,0.19,10.51,17.28,2.26,4.13,12.33,2.05,2.99,6.06, 5.19,0.62,11.34,10.33,0.63,4.33,8.08,2.61,4.36,1.34, 9.76,1.37,36.35, 1.02,3.21,4.97,6.20,0.32,8.53,10.92), nrow = 10, ncol = 3, byrow = TRUE) # Test consistency with SARP and compute the number of SARP violations sarp(p,q) # Test consistency with SARP and compute the number of SARP violations at e = 0.95 sarp(p,q, efficiency = 0.95)
# define a price matrix p = matrix(c(4,4,4,1,9,3,2,8,3,1, 8,4,3,1,9,3,2,8,8,4, 1,4,1,8,9,3,1,8,3,2), nrow = 10, ncol = 3, byrow = TRUE) # define a quantity matrix q = matrix(c( 1.81,0.19,10.51,17.28,2.26,4.13,12.33,2.05,2.99,6.06, 5.19,0.62,11.34,10.33,0.63,4.33,8.08,2.61,4.36,1.34, 9.76,1.37,36.35, 1.02,3.21,4.97,6.20,0.32,8.53,10.92), nrow = 10, ncol = 3, byrow = TRUE) # Test consistency with SARP and compute the number of SARP violations sarp(p,q) # Test consistency with SARP and compute the number of SARP violations at e = 0.95 sarp(p,q, efficiency = 0.95)
This function allows the user to check whether a given data set is consistent with the Weak Axiom of Revealed
Preference at efficiency level (
WARP) and computes the number of
WARP violations.
We say that a data set satisfies WARP at efficiency level
if
and
implies
(see the definition of R^D_e below). The exact WARP, with
, is a necessary and sufficient
condition for a data set to be rationalizable by a continuous, strictly increasing, piecewise strictly concave,
and skew-symmetric preference function (see Aguiar et al. (2020)). Moreover, Rose (1958) showed that for the case
of two goods (
), WARP is equivalent to the Strong Axiom of Revealed Preference (SARP). In other words,
when there are only two consumption categories, transitivity has no empirical bite.
warp(p, q, efficiency = 1)
warp(p, q, efficiency = 1)
p |
A |
q |
A |
efficiency |
The efficiency level |
The function returns two elements. The first element (passwarp
) is a binary indicator telling us
whether the data set is consistent with WARP at a given efficiency level . It takes a value 1 if the data set
is
WARP consistent and a value 0 if the data set is
WARP inconsistent.
The second element (
nviol
) reports the number of WARP violations. If the data set is
WARP
consistent,
nviol
is 0. Note that the maximum number of violations in an WARP inconsistent data is
.
For a given efficiency level , we say that:
bundle is directly revealed preferred to bundle
at efficiency level
(denoted as
) if
.
Aguiar, Victor, Per Hjertstrand, and Roberto Serrano. "A Rationalization of the Weak Axiom of Revealed Preference." (2020).
Rose, Hugh. "Consistency of preference: the two-commodity case." The Review of Economic Studies 25, no. 2 (1958): 124-125.
sarp
for the Strong Axiom of Revealed Preference and garp
for
the Generalized Axiom of Revealed Preference.
# define a price matrix p = matrix(c(4,4,4,1,9,3,2,8,3,1, 8,4,3,1,9,3,2,8,8,4, 1,4,1,8,9,3,1,8,3,2), nrow = 10, ncol = 3, byrow = TRUE) # define a quantity matrix q = matrix(c( 1.81,0.19,10.51,17.28,2.26,4.13,12.33,2.05,2.99,6.06, 5.19,0.62,11.34,10.33,0.63,4.33,8.08,2.61,4.36,1.34, 9.76,1.37,36.35, 1.02,3.21,4.97,6.20,0.32,8.53,10.92), nrow = 10, ncol = 3, byrow = TRUE) # Test consistency with WARP and compute the number of WARP violations warp(p,q) # Test consistency with WARP and compute the number of WARP violations at e = 0.95 warp(p,q, efficiency = 0.95)
# define a price matrix p = matrix(c(4,4,4,1,9,3,2,8,3,1, 8,4,3,1,9,3,2,8,8,4, 1,4,1,8,9,3,1,8,3,2), nrow = 10, ncol = 3, byrow = TRUE) # define a quantity matrix q = matrix(c( 1.81,0.19,10.51,17.28,2.26,4.13,12.33,2.05,2.99,6.06, 5.19,0.62,11.34,10.33,0.63,4.33,8.08,2.61,4.36,1.34, 9.76,1.37,36.35, 1.02,3.21,4.97,6.20,0.32,8.53,10.92), nrow = 10, ncol = 3, byrow = TRUE) # Test consistency with WARP and compute the number of WARP violations warp(p,q) # Test consistency with WARP and compute the number of WARP violations at e = 0.95 warp(p,q, efficiency = 0.95)