*! version 1.00 16june2022

Title

hmindex--Houtman-Maks Index

Syntax

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

options

axiom(hmindex##options:axiom) axiom for testing data; default is axiom(WGARP)

distribution(hmindex##options:distribution) calculates Houtman-Maks index for every simulated uniformly random data set

simulations(hmindex##options:simulations) number of simulated uniformly random data sets; default is simulations(1000)

seed(hmindex##options:seed) seed in generation of uniformly random data sets; default is seed(12345)

Description

hmindex calculates the Houtman-Maks Index.

For further details, see Demetry and Hjertstrand (2022) "Consistent subsets: Computing the Houtman-Maks index in Stata". Mimeo.

Options

axiom specifies which axiom the user would like to use in testing the data for consistency. The default is axiom(WGARP).
The two axioms that can be tested are WGARP and WARP. To test both axioms at once, specify axiom(all)

distribution computes the Houtman-Maks index for every simulated uniformly random data set

simulations number of simulated uniformly random data sets; default is simulations(1000)

seed specifies the random seed in generation of uniformly random data sets; default is seed(12345)

Stored results

hmindex 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 number of simulations

Scalars

r(GOODS) number of goods in the data

r(OBS) number of observations in the data

r(HM_NUM_axiom) maximal number of observations in the data satisfying the axiom

r(HM_FRAC_axiom) maximal fraction of observations in the data satisfying the axiom (calculated as maximal number of observations satisfying the axiom divided by total number of observations)

r(SIM) number of simulated uniformly random data sets (if option distribution is specified)

Macros

r(AXIOM) axiom(s) being tested

Matrices

r(INDICATOR_axiom) T-dimensional binary array indicating whether the observation is in the consistent set (1) or violator set(0)

r(OBSDROP_axiom) list of observations in the violator set, i.e., what observations that are dropped from the dataset

r(CS_price_axiom) price matrix of the data in the consistent set for the specified axiom, i.e., the price data corresponding to the goods in the consistent set

r(CS_quantity_axiom) quantity matrix of the data in the consistent set for the specified axiom, i.e., the quantity data corresponding to the goods in the consistent set

r(VS_price_axiom) price matrix of the data in the violator set for the specified axiom, i.e., the price data corresponding to the goods in the violator set

r(VS_quantity_axiom) quantity matrix of the data in the violator set for the specified axiom, i.e., the quantity data corresponding to the goods in the violator set

r(SUMSTATS_axiom) summary statistics over all HM-indices calculated for every simulated uniformly random data set: mean (mean), standard deviation (Std. Dev.), minimum (Min), first quartile (Q1), median (Median), third quartile (Q3), and maximum (Max)

r(SIMRESULTS_axiom) HM_NUM and HM_FRAC for every simulated uniformly random data set.

Examples: Loading data and running the command

Install package

. ssc install hmindex

Download example data (from ancillary files)

Note: the file downloads to your current working directory

. net get hmindex

Load example data

. use hmindex_example_data.dta, clear

In the example dataset provided, we have 20 observations of the prices and quantities of two goods.
These have variable names p1 and p2 for prices, and x1 and x2 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 p2, matrix(P)

. mkmat x1 x2, matrix(X)

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

. matlist P

. matlist X

Run command with default settings

. hmindex, price(P) quantity(X)

Number of obs = 20
Number of goods = 2

------------------------------------
Axiom | #HM %HM
-------------+----------------------
WGARP | 15 .75
------------------------------------

This has an approximate runtime of .12 seconds.

Run command with WGARP and WARP

. hmindex, price(P) quantity(X) ax(WGARP WARP)

Number of obs = 20
Number of goods = 2

------------------------------------
Axiom | #HM %HM
-------------+----------------------
WGARP | 15 .75
WARP | 15 .75
------------------------------------

Examples: Interpreting the results

The result shows that 5 observations of the original 20 observations in the data need to
be removed in order for the maximal subset of the data to be consistent with utility maximizing behavior.
That is, removing the 5 observations gives a data set which satisfies WGARP and WARP.
Put differently, the consistent set consists of 15 observations, or 75% of the total number of observations.
The second example shows that this holds irrespective of the axiom being tested.

Examples: Visualizing the HM-Index for all subjects in Choi et al. (2007)

Data and background

The Choi et al. (2007) data consists of portfolio choice allocations in a two-dimensional setting
from 93 experimental subjects, over 50 decision rounds (T = 50). Each subject split her
budget between two Arrow-Debreu securities, with each security paying 1 token if the
corresponding state was realized, and 0 otherwise. The experiment consisted of two treatments.
In the first (symmetric) treatment with 47 subjects, each state of the world occured
with probability 1/2, which were objectively known to the subjects. The second
(asymmetric) treatment was applied to 46 subjects, where they faced states occuring with
probabilities 1/3 and 2/3. All state prices were chosen at random and varied
across all decision rounds and subjects.

Here, we show how to calculate the HM-index for every subject from the actual data. In addition to that,
for each subject, we calculate the HM-index in every simulated uniformly random data set.

From the simulations, we are interested in the mean, minimum, and maximum values of the HM-index, and
how that compares to the HM-index calculated from the actual data.

Code

For the sake of time, we use 10 simulations. See Section 4 in Demetry and Hjertstrand (2022) for
this same exercise but with 1000 simulations.

local subjects = 93
matrix results = J(`T',4,0)
matrix colnames results = "HM" "Mean" "Min" "Max"

local simulations = 10

forvalues subject = 1/`subjects' {

quietly hmindex, price(P`subject') quantity(X`subject') dist sim(`simulations')

matrix sumstats = r(SUMSTATS_WGARP)

matrix results[`subject', 1] = r(HM_NUM_WGARP) /* Actual HM */
matrix results[`subject', 2] = sumstats[1, 1] /* Mean */
matrix results[`subject', 3] = sumstats[3, 1] /* Min */
matrix results[`subject', 4] = sumstats[7, 1] /* Max */

}

We can inspect this matrix containing the results as follows:

. matlist results

However, a more intuitive way to inspect the results may be by visualizing it in a figure.
The following code replicates Figure 1 in Demetry and Hjertstrand (2022):

#delimit ;
twoway rcap Max Min Subject, lstyle(ci) ||
scatter HM Subject, msymbol(T) msize(small) mcolor(red) ||
scatter Mean Subject, mstyle(p1) msize(vsmall) mcolor(dknavy)
ytitle("HM-index") xtitle("Subject")
ylabel(20(5)50) xlabel(1 "1" 10(10)90)
legend(order(2 "Actual HM-index" 3 "Mean HM-index for simulated uniformly random data") rows(2))
name(rcap, replace) scheme(sj) ;
#delimit cr

Interpretation

The red-colored triangle markers represent the calculated HM-index for each subject.
Also for each subject, the connected intervals give the maximum and minimum values of the HM-index calculated from
the simulated uniformly random data, while the black dots give the mean HM-index calculated
over all simulations.

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.