Title: | Tools for Computational Revealed Preference Analysis |
Version: | 0.1.0 |
Maintainer: | Khushboo Surana <khushboo.surana@york.ac.uk> |
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. |
License: | MIT + file LICENSE |
Encoding: | UTF-8 |
RoxygenNote: | 7.1.1 |
URL: | https://github.com/ksurana21/revpref |
BugReports: | https://github.com/ksurana21/revpref/issues |
Imports: | gtools |
Suggests: | rmarkdown, knitr |
NeedsCompilation: | no |
Packaged: | 2021-07-05 11:03:31 UTC; ks1779 |
Author: | Khushboo Surana |
Repository: | CRAN |
Date/Publication: | 2021-07-07 08:10:02 UTC |
Computes the Bronars power index for a given axiom at a given efficiency level
Description
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.
Usage
bronars(p, q, simulation = 1000, model = "GARP", efficiency = 1)
Arguments
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 |
Value
The function returns the power of a given axiom against uniformly random behavior at a given efficiency level.
References
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.
Examples
# 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)
Computes the critical cost efficiency index
Description
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 e
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.
Usage
ccei(p, q, model = "GARP")
Arguments
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). |
Value
The function returns e^*
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 e
such that the data satisfy e
GARP.
References
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.
See Also
mpi
for the money pump index.
Examples
# 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")
Tests consistency with the Generalized Axiom of Revealed Preference at efficiency e
Description
This function allows the user to check whether a given data set is consistent with the Generalized Axiom of Revealed Preference
at efficiency e
(e
GARP) and computes the number of e
GARP violations. We say that a data set
satisfies GARP at efficiency level e
if q_t R_e q_s
implies ep_s'q_s \le p_s'q_t
.
It is clear that by setting e = 1
, we obtain the standard version of GARP as defined in Varian (1982).
While if e < 1
, we allow for some optimization error in the choices to make the data set consistent with GARP.
The smaller the e
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)).
Usage
garp(p, q, efficiency = 1)
Arguments
p |
A |
q |
A |
efficiency |
The efficiency level |
Value
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 e
. It takes a value 1 if the data set is e
GARP
consistent and a value 0 if the data set is e
GARP inconsistent. The second element (nviol
) reports the
number of e
GARP violations. If the data set is e
GARP consistent, nviol
is 0. Note that the maximum
number of violations in an e
GARP inconsistent data is T(T-1)
.
Definitions
For a given efficiency level 0 \le e \le 1
, we say that:
bundle
q_t
is directly revealed preferred to bundleq_s
at efficiency levele
(denoted asq_t R^D_e q_s
) ifep_t'q_t \ge p_t'q_s
.bundle
q_t
is strictly directly revealed preferred to bundleq_s
at efficiency levele
(denoted asq_t P^D_e q_s
) ifep_t'q_t > p_t'q_s
.bundle
q_t
is revealed preferred to bundleq_s
at efficiency levele
(denoted asq_t R_e q_s
) if there exists a (possibly empty) sequence of observations (t,u,v,\cdots,w,s
) such thatq_t R^D_e q_u
,q_u R^D_e q_v
,\cdots, q_w R^D_e q_s
.
References
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.
See Also
sarp
for the Strong Axiom of Revealed Preference and warp
for
the Weak Axiom of Revealed Preference.
Examples
# 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)
Computes the minimum and maximum money pump index
Description
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.
Usage
mpi(p, q)
Arguments
p |
A |
q |
A |
Value
The function returns two elements. The first element (minimum_MPI
) is the minimum MPI and the second
element (maximum_MPI
) is the maximum MPI.
References
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.
See Also
ccei
for the critical cost efficiency index.
Examples
# 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)
Tests consistency with the Strong Axiom of Revealed Preference at efficiency e
Description
This function allows the user to check whether a given data set is consistent with the Strong Axiom of Revealed Preference
at efficiency level e
(e
SARP) and computes the number of e
SARP violations.
We say that a data set satisfies SARP at efficiency level e
if q_t R_e q_s
implies ep_s'q_s < p_s'q_t
(see the definition of R_e
below). It is clear that by setting e = 1
, we obtain the standard version of SARP.
While if e < 1
, we allow for some optimization error in the choices to make the data set consistent with SARP.
The smaller the e
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)).
Usage
sarp(p, q, efficiency = 1)
Arguments
p |
A |
q |
A |
efficiency |
The efficiency level |
Value
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 e
. It takes a value 1 if the data set
is e
SARP consistent and a value 0 if the data set is e
SARP inconsistent.
The second element (nviol
) reports the number of e
SARP violations. If the data is e
SARP
consistent, nviol
is 0. Note that the maximum number of violations in an e
SARP inconsistent data is
T(T-1)
.
Definitions
For a given efficiency level 0 \le e \le 1
, we say that:
bundle
q_t
is directly revealed preferred to bundleq_s
at efficiency levele
(denoted asq_t R^D_e q_s
) ifep_t'q_t \ge p_t'q_s
.bundle
q_t
is strictly directly revealed preferred to bundleq_s
at efficiency levele
(denoted asq_t P^D_e q_s
) ifep_t'q_t > p_t'q_s
.bundle
q_t
is revealed preferred to bundleq_s
at efficiency levele
(denoted asq_t R_e q_s
) if there exists a (possibly empty) sequence of observations (t,u,v,\cdots,w,s
) such thatq_t R^D_e q_u
,q_u R^D_e q_v
,\cdots, q_w R^D_e q_s
.
References
Matzkin, Rosa L., and Marcel K. Richter. "Testing strictly concave rationality." Journal of Economic Theory 53, no. 2 (1991): 287-303.
See Also
garp
for the Generalized Axiom of Revealed Preference and warp
for
the Weak Axiom of Revealed Preference.
Examples
# 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)
Tests consistency with the Weak Axiom of Revealed Preference at efficiency e
Description
This function allows the user to check whether a given data set is consistent with the Weak Axiom of Revealed
Preference at efficiency level e
(e
WARP) and computes the number of e
WARP violations.
We say that a data set satisfies WARP at efficiency level e
if q_t R^D_e q_s
and q_t \neq q_s
implies ep_s'q_s < p_s'q_t
(see the definition of R^D_e below). The exact WARP, with e = 1
, 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 (N = 2
), 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.
Usage
warp(p, q, efficiency = 1)
Arguments
p |
A |
q |
A |
efficiency |
The efficiency level |
Value
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 e
. It takes a value 1 if the data set
is e
WARP consistent and a value 0 if the data set is e
WARP inconsistent.
The second element (nviol
) reports the number of e
WARP violations. If the data set is e
WARP
consistent, nviol
is 0. Note that the maximum number of violations in an e
WARP inconsistent data is
T(T-1)/2
.
Definitions
For a given efficiency level 0 \le e \le 1
, we say that:
bundle
q_t
is directly revealed preferred to bundleq_s
at efficiency levele
(denoted asq_t R^D_e q_s
) ifep_t'q_t \ge p_t'q_s
.
References
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.
See Also
sarp
for the Strong Axiom of Revealed Preference and garp
for
the Generalized Axiom of Revealed Preference.
Examples
# 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)