# directPrefs: Compute direct and indirect revealed preferences. In revealedPrefs: Revealed Preferences and Microeconomic Rationality

## Description

The `directPrefs` function computes direct revealed preferences, the `indirectPrefs` function computes indirect revealed preferences.

## Usage

 ```1 2``` ```directPrefs(x, p, afriat.par= 1) indirectPrefs(x, p, afriat.par= 1) ```

## Arguments

 `x` data frame or matrix containing the observed quantities, where each row corresponds to an observation and the columns are types of goods. `p` data frame or matrix (of same dimensions as x) containing the corresponding prices. `afriat.par` the Afriat parameter, real number in [0,1], which allows a certain level of error in the optimization of choices; default is 1, ie. no optimization error allowed.

## Details

Direct preferences are directly computed from matrix multiplication of prices and quantities. Indirect preferences are computed using a variant of the Floyd-Warshall algorithm.

## Value

A matrix of direct or indirect revealed preferences:

 `prefs[i, j] = 0` if bundle `i` is not revealed prefered to bundle `j` `prefs[i, j] = 1` if bundle `i` is revealed prefered to bundle `j` `prefs[i, j] = 2` if bundle `i` is strictly revealed prefered to bundle `j`

## Author(s)

Julien Boelaert jubo.stats@gmail.com

## References

Varian, H. R. (1984) Microeconomic Analysis. New York/London: Norton, 2nd edition, pp 141-143.

## Examples

 ```1 2 3 4``` ```# Compute direct and indirect preferences of SARP-violating data: data(noSarp) directPrefs(noSarp\$x, noSarp\$p) indirectPrefs(noSarp\$x, noSarp\$p) ```

### Example output

```     [,1] [,2] [,3]
[1,]    1    1    0
[2,]    0    1    1
[3,]    1    0    1
[,1] [,2] [,3]
[1,]    1    1    1
[2,]    1    1    1
[3,]    1    1    1
```

revealedPrefs documentation built on Sept. 5, 2019, 9:04 a.m.