Description Usage Arguments Details Value Note Author(s) References See Also Examples
View source: R/crawford-pendakur.R
The cpUpper
function computes a Crawford-Pendakur type upper bound on the number of GARP-consistent subpopulations, and performs clustering of the data.
1 2 3 4 5 |
x |
data frame or matrix containing the observed quantities, where each row corresponds to an observation and the columns are types of goods, or an object of class |
p |
data frame or matrix (of same dimensions as x) containing the corresponding prices, |
times |
number of times the algorithm is run (the final result is the best of |
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, |
method |
character string: |
object |
an object of class |
... |
additional arguments passed to the |
For each run of the algorithm, a random permutation of the observations is drawn, and one by one each observation is associated with the biggest cluster that can include it while preserving consistency with the GARP rationality axiom. If no cluster is compatible with a given observation a new cluster is created to accomodate it.
Three methods are available:
"fastfloyd"
(default) uses an iterative variant of the Floyd-Warshall algorithm, in which the check of consistency of the current observation with a given cluster is done in a single step of the Floyd-Warshall algorithm. Much faster than "floyd"
.
"floyd"
uses the algorithm described in Crawford and Pendakur (2013): at each step the complete Floyd-Warshall algorithm is run to check whether each cluster can accomodate the current observation.
cpUpper
returns an object of class upperBound
which contains the following elements:
|
numeric vector with length equal to number of observations, containing the cluster number of each observation, |
|
numeric vector containg the numbers of observations allocated to each cluster, |
|
numeric vector containing the history of numbers of clusters found during multiple runs of the algorithm. |
|
upper bound on the number of types, |
|
Afriat parameter used in the algorithm. |
Warning: cpUpper
can be very slow for large datasets (eg. more than 1000 observations).
Julien Boelaert jubo.stats@gmail.com
Crawford, I. and Pendakur, K. (2013). How many types are there? The Economic Journal, 123(567):77-95.
See cpLower for the lower bound on number of types.
1 2 3 4 |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.