simGarp: Generate random data consistent with rationality axioms...

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/simulPref.R

Description

Functions for generating random data (prices and quantities) consistent with the chosen rationality axiom.

Usage

1
2
3
4
5
6
simWarp(nobs, ngoods, afriat.par= 1, maxit= 10 * nobs, 
        qmin= 0, qmax= 1, pmin= 0, pmax= 1)
simSarp(nobs, ngoods, afriat.par= 1, maxit= 10 * nobs, 
        qmin= 0, qmax= 1, pmin= 0, pmax= 1)
simGarp(nobs, ngoods, afriat.par= 1, maxit= 10 * nobs, 
        qmin= 0, qmax= 1, pmin= 0, pmax= 1)

Arguments

nobs

the desired number of observations (number of rows in the quantities and prices matrices),

ngoods

the number of goods in the dataset (number of columns in the quantities and prices matrices),

afriat.par

the Afriat parameter, a 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,

maxit

maximum number of iterations (default to 10 times nobs),

qmin

minimum quantities for each good,

qmax

maximum quantities for each good,

pmin

minimum prices for each good,

pmax

maximum prices for each good.

Details

The data are iteratively incremented: at each iteration a new random observation (prices and quantities) is generated, and is accepted only if it is consistent with the previously accepted data, in which case it is added to the data. The random observations (price-quantities couples) are independently generated from uniform distributions in the support defined by qmin, qmax, and pmin, pmax.

For GARP and SARP the depth-first search method is used to check for consistency (a recursive search using only the new candidate observation as starting point), for WARP the candidate observation is pairwise checked against all previously accepted data.

The algorithm stops if the desired number of observations nobs is reached. If the desired number of observations nobs is not reached in maxit iterations, a warning is issued and the function returns the largest dataset attained.

Value

x

numeric matrix of generated quantities,

p

numeric matrix of generated prices,

iter

number of iterations before the algorithm stopped,

nobs

number of generated observations.

Author(s)

Julien Boelaert jubo.stats@gmail.com

References

Varian, H. R. (1982) The Nonparametric Approach to Demand Analysis, Econometrica, 50(4):945-973.

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

See Also

See checkGarp for rationality tests.

Examples

1
2
3
4
# Generate 100 WARP-consistent observations of 5 goods
simdata <- simWarp(100, 5)
summary(checkWarp(simdata$x, simdata$p))
summary(checkGarp(simdata$x, simdata$p))

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