*! version 2.00 31january2022

Title

checkax--Testing Axioms of Revealed Preference

Syntax

checkax,
price(mname) quantity(mname) [ options]

options

axiom(checkax##options:axiom) axiom for testing data; default is axiom(eGARP).
Axioms that can be tested: eGARP, eSGARP, eWARP, eWGARP, eSARP, eHARP and eCM.

efficiency(checkax##options:efficiency) efficiency level for testing data, where 0 < efficiency <= 1; default is efficiency(1).

Description

checkax allows the user to test whether consumer demand data satisfy certain revealed preference axioms at a given efficiency level.

checkax is the first in a series of three commands for testing axioms of revealed preference.
The other two commands are aei (which calculates measures of goodness-of-fit when the data violates the axioms) and powerps (which
calculates the power against uniform random behavior and predictive success for the axioms at any given efficienecy level).

For further details on the commands, please see Demetry, Hjertstrand and Polisson (2020) "Testing Axioms of Revealed Preference in Stata". IFN Working Paper No. 1342.

Options

axiom specifies which axiom the user would like to use in testing the data for consistency.
The default is axiom(eGARP). In total, there are six axioms that can be tested: eGARP, eWARP, eWGARP, eSARP, eHARP and eCM.

efficiency specifies the efficiency
level at which the user would like to test the data. The default efficiency level is efficiency(1).
Efficiency must be greater than zero and less than or equal to one.

Stored results

checkax stores the following in r(). Notice that results are suffixed by the axiom being tested except for results that apply to all axioms, i.e. number of goods and observations, and efficiency level.

Scalars

r(PASS_axiom) indicator for whether data pass the axiom or not

r(NUM_VIO_axiom) number of violations

r(FRAC_VIO_axiom) fraction of violations

r(GOODS) number of goods in the data

r(OBS) number of observations in the data

r(EFF) efficiency level at which the axiom is tested

Macros

r(AXIOM) axiom(s) being tested

Examples: Loading data and running the command

Install package

. ssc install rpaxioms

Download example data (from ancillary files)

Note: the downloaded file is in your current working directory

. net get rpaxioms

Load example data

. use rpaxioms_example_data.dta, clear

In the example dataset provided, we have 20 observations of the prices and quantities of five goods.
These have variable names p1, ..., p5 for prices, and x1, ..., x5 for quantities.

In order to use the command, we need to create a matrix for prices
(where each column is a good and each row is an observation).
Likewise, we need to create a matrix for quantities.

Make matrices P and X from variables

. mkmat p1-p5, matrix(P)

. mkmat x1-x5, matrix(X)

We now have two 20x5 matrices; one for prices and one for quantities.

. matlist P

. matlist X

Run command with default settings

. checkax, price(P) quantity(X)

Run command with eGarp and eHARP, at efficiency level 0.95

. checkax, price(P) quantity(X) ax(eGARP eHARP) eff(0.95)

Examples: Interpreting the results

Running the last line above produces the following results:

Number of obs = 20
Number of goods = 5
Efficiency level = .95

-----------------------------------------------
Axiom | Pass #vio %vio
-------------+---------------------------------
eGARP | 0 104 .2737
eHARP | 0 20 1
-----------------------------------------------

Regardless of which (or how many) axiom(s) are tested, in your results window you will always
see the number of observations and goods as well as the efficiency level in the top-right corner.

In the table, you will find four columns - Axiom, Pass, #vio and %vio.
The column Axiom specifies which axioms are being tested.
The column Pass specifies whether the data satisfy respective axiom.
The column #vio specifies the number of violations of respective axiom.
The column %vio specifies the share of violations (as a share of the total possible number of violations).

In this example, we allow a ‘margin of error’ of 5%, meaning that we will only count bundles whose
cost is less than 95% of an observed choice as being revealed worse than that choice.

When checking if GARP is satisfied at this efficiency level, we find that 27.37% of all comparisons
indicate a violation of GARP. Hence, taking this number as fairly large, we may conclude that these
data cannot be rationalized by a continuous, strictly increasing and concave utility function.
Testing the data for HARP, which in addition to continuity, monotonicity and concavity also ensures
that the rationalizing utility function is homothetic, we find that all comparisons (100%) indicate
a violation of HARP. Thus, using the fraction of violations as a measure of the degree of
violations, these results show compelling evidence against that the data can be rationalized by a
well-behaved and homothetic utility function.

Examples: Looping over efficiency levels and storing output

Let's say you want to plot the fraction of violations of eGARP over different efficiency levels - specifically,
between efficiency(0.9) and efficiency(1) at increments of 0.001. Using the same data as in the first example,
we could do the following:

. matrix results = J(101, 2, .)

. local row_nr = 1

. forvalues i = 0.90(0.001)1.00 {

. quietly checkax, price(P) quantity(X) axiom(eGARP) efficiency(`i')

. matrix results[`row_nr', 1] = `r(EFF)'

. matrix results[`row_nr', 2] = `r(FRAC_VIO_eGARP)'

. local row_nr = `row_nr' + 1

. }

. matlist results

Authors

- Marcos Demetry, PhD student at Linnaeus University, Sweden, and affiliated doctoral student at
the Research Institute of Industrial Economics, Sweden.
- Per Hjertstrand, Associate Professor and Research Fellow at the Research Institute
of Industrial Economics, Sweden.
- Matthew Polisson, Senior Lecturer and Researcher at University of Bristol, UK.