Package 'revpref'

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

Help Index


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 TXNT X N matrix of observed prices where each row corresponds to an observation and each column corresponds to a consumption category. TT is the number of observations and NN is the number of consumption categories.

q

A TXNT X N matrix of observed quantities where each row corresponds to an observation and each column corresponds to a consumption category.TT is the number of observations and NN is the number of consumption categories.

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 ee is a real number between 0 and 1 and allows for a small margin of error. The default value is 1.

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 ee 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 TXNT X N matrix of observed prices where each row corresponds to an observation and each column corresponds to a consumption category. TT is the number of observations and NN is the number of consumption categories.

q

A TXNT X N matrix of observed quantities where each row corresponds to an observation and each column corresponds to a consumption category.TT is the number of observations and NN is the number of consumption categories.

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 ee^* 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 ee such that the data satisfy eeGARP.

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 ee

Description

This function allows the user to check whether a given data set is consistent with the Generalized Axiom of Revealed Preference at efficiency ee (eeGARP) and computes the number of eeGARP violations. We say that a data set satisfies GARP at efficiency level ee if qtReqsq_t R_e q_s implies epsqspsqtep_s'q_s \le p_s'q_t. It is clear that by setting e=1e = 1, we obtain the standard version of GARP as defined in Varian (1982). While if e<1e < 1, we allow for some optimization error in the choices to make the data set consistent with GARP. The smaller the ee 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 TXNT X N matrix of observed prices where each row corresponds to an observation and each column corresponds to a consumption category. TT is the number of observations and NN is the number of consumption categories.

q

A TXNT X N matrix of observed quantities where each row corresponds to an observation and each column corresponds to a consumption category.TT is the number of observations and NN is the number of consumption categories.

efficiency

The efficiency level ee, is a real number between 0 and 1, which allows for a small margin of error when checking for consistency with the axiom. The default value is 1, which corresponds to the test of consistency with the exact GARP.

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 ee. It takes a value 1 if the data set is eeGARP consistent and a value 0 if the data set is eeGARP inconsistent. The second element (nviol) reports the number of eeGARP violations. If the data set is eeGARP consistent, nviol is 0. Note that the maximum number of violations in an eeGARP inconsistent data is T(T1)T(T-1).

Definitions

For a given efficiency level 0e10 \le e \le 1, we say that:

  • bundle qtq_t is directly revealed preferred to bundle qsq_s at efficiency level ee (denoted as qtReDqsq_t R^D_e q_s) if eptqtptqsep_t'q_t \ge p_t'q_s.

  • bundle qtq_t is strictly directly revealed preferred to bundle qsq_s at efficiency level ee (denoted as qtPeDqsq_t P^D_e q_s) if eptqt>ptqsep_t'q_t > p_t'q_s.

  • bundle qtq_t is revealed preferred to bundle qsq_s at efficiency level ee (denoted as qtReqsq_t R_e q_s) if there exists a (possibly empty) sequence of observations (t,u,v,,w,st,u,v,\cdots,w,s) such that qtReDquq_t R^D_e q_u, quReDqvq_u R^D_e q_v, ,qwReDqs\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 TXNT X N matrix of observed prices where each row corresponds to an observation and each column corresponds to a consumption category. TT is the number of observations and NN is the number of consumption categories.

q

A TXNT X N matrix of observed quantities where each row corresponds to an observation and each column corresponds to a consumption category.TT is the number of observations and NN is the number of consumption categories.

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 ee

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 ee (eeSARP) and computes the number of eeSARP violations. We say that a data set satisfies SARP at efficiency level ee if qtReqsq_t R_e q_s implies epsqs<psqtep_s'q_s < p_s'q_t (see the definition of ReR_e below). It is clear that by setting e=1e = 1, we obtain the standard version of SARP. While if e<1e < 1, we allow for some optimization error in the choices to make the data set consistent with SARP. The smaller the ee 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 TXNT X N matrix of observed prices where each row corresponds to an observation and each column corresponds to a consumption category. TT is the number of observations and NN is the number of consumption categories.

q

A TXNT X N matrix of observed quantities where each row corresponds to an observation and each column corresponds to a consumption category.TT is the number of observations and NN is the number of consumption categories.

efficiency

The efficiency level ee, is a real number between 0 and 1, which allows for a small margin of error when checking for consistency with the axiom. The default value is 1, which corresponds to the test of consistency with the exact SARP.

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 ee. It takes a value 1 if the data set is eeSARP consistent and a value 0 if the data set is eeSARP inconsistent. The second element (nviol) reports the number of eeSARP violations. If the data is eeSARP consistent, nviol is 0. Note that the maximum number of violations in an eeSARP inconsistent data is T(T1)T(T-1).

Definitions

For a given efficiency level 0e10 \le e \le 1, we say that:

  • bundle qtq_t is directly revealed preferred to bundle qsq_s at efficiency level ee (denoted as qtReDqsq_t R^D_e q_s) if eptqtptqsep_t'q_t \ge p_t'q_s.

  • bundle qtq_t is strictly directly revealed preferred to bundle qsq_s at efficiency level ee (denoted as qtPeDqsq_t P^D_e q_s) if eptqt>ptqsep_t'q_t > p_t'q_s.

  • bundle qtq_t is revealed preferred to bundle qsq_s at efficiency level ee (denoted as qtReqsq_t R_e q_s) if there exists a (possibly empty) sequence of observations (t,u,v,,w,st,u,v,\cdots,w,s) such that qtReDquq_t R^D_e q_u, quReDqvq_u R^D_e q_v, ,qwReDqs\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 ee

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 ee (eeWARP) and computes the number of eeWARP violations. We say that a data set satisfies WARP at efficiency level ee if qtReDqsq_t R^D_e q_s and qtqsq_t \neq q_s implies epsqs<psqtep_s'q_s < p_s'q_t (see the definition of R^D_e below). The exact WARP, with e=1e = 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=2N = 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 T×NT \times N matrix of observed prices where each row corresponds to an observation and each column corresponds to a consumption category. TT is the number of observations and NN is the number of consumption categories.

q

A T×NT \times N matrix of observed quantities where each row corresponds to an observation and each column corresponds to a consumption category.TT is the number of observations and NN is the number of consumption categories.

efficiency

The efficiency level ee, is a real number between 0 and 1, which allows for a small margin of error when checking for consistency with the axiom. The default value is 1, which corresponds to the test of consistency with the exact WARP.

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 ee. It takes a value 1 if the data set is eeWARP consistent and a value 0 if the data set is eeWARP inconsistent. The second element (nviol) reports the number of eeWARP violations. If the data set is eeWARP consistent, nviol is 0. Note that the maximum number of violations in an eeWARP inconsistent data is T(T1)/2T(T-1)/2.

Definitions

For a given efficiency level 0e10 \le e \le 1, we say that:

  • bundle qtq_t is directly revealed preferred to bundle qsq_s at efficiency level ee (denoted as qtReDqsq_t R^D_e q_s) if eptqtptqsep_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)