Version: | 1.0 |
Date: | 2015-07-01 |
Title: | Paired Comparison Data Analysis |
Author: | Michel Semenou |
Maintainer: | Michel Semenou <michel.semenou@oniris-nantes.fr> |
Depends: | R (≥ 3.1), methods, utils, MASS, graphics, stats |
Description: | Different tools for describing and analysing paired comparison data are presented. Main methods are estimation of products scores according Bradley Terry Luce model. A segmentation of the individual could be conducted on the basis of a mixture distribution approach. The number of classes can be tested by the use of Monte Carlo simulations. This package deals also with multi-criteria paired comparison data. |
License: | GPL-2 |
NeedsCompilation: | no |
Packaged: | 2015-07-01 12:02:24 UTC; Utilisateur |
Repository: | CRAN |
Date/Publication: | 2015-07-01 16:06:23 |
Paired Comparison Data Analysis
Description
Different tools for describing and analysing paired comparison data are presented. Main methods are estimation of products scores according Bradley Terry Luce model. A segmentation of the individual could be conducted on the basis of a mixture distribution approach. The number of classes can be tested by the use of Monte Carlo simulations. This package deals also with multi-criteria paired comparison data.
Details
Package: | CompR |
Type: | Package |
Version: | 1.0 |
Date: | 2015-07-01 |
License: | GPL-2 |
Depends: | methods, MASS, stats, graphics, utils |
Function to estimate products configurations (Bradley's scores) and weights of the
classes is EstimBradley()
.
Function to perform a test concerning the number of classes is ResSimulLvrRatio()
.
Function to obtain a graphical representation of Bradley's scores is Piplot()
.
Author(s)
Michel Semenou
Maintainer: <michel.semenou@oniris-nantes.fr>
See Also
EstimBradley
, ResSimulLvrRatio
, Piplot
Examples
data(Cocktail)
show(Cocktail)
ResCock1<-EstimBradley(Cocktail,Constraint=0,Tcla=1,eps=0.001,eps1=0.001,TestPi=TRUE)
show(ResCock1)
Res_LvrRatio1<-ResSimulLvrRatio(Cocktail,ResCock1,0,3,level=0.05,eps=0.001,eps1=0.001)
getSimu(Res_LvrRatio1)
getTest(Res_LvrRatio1)
Class "BradleyEstim"
Description
A class for Bradley's scores estimation results
Objects from the Class
Objects can be created by the function EstimBradley()
.
Slots
Lvriter
:Object of class
"matrix"
corresponding to the number of iterations of the EM algorithm, LogLikelihoods at the previous step and the current step, and the differences between these 2 LogLikelihoodsLvr
:Object of class
"numeric"
final value of the LogLikelihoodLambda
:Object of class
"matrix"
weights of the different classesPi
:Object of class
"list"
Bradley's scores for each class and each criteriaZh
:Object of class
"matrix"
with the posterior probabilities for each individual to belong to the different classes and the class with the higher probabilityIc
:Object of class
"matrix"
value of the different Information criterion (AIC, BIC, CAIC)Restestglob
:Object of class
"list"
result of testing the whole Bradley's scores equality for each class and each criteriaRestestprod
:Object of class
"list"
result of multiple comparison tests for Bradley's scores in each class and for each criteriaVarcov
:Object of class
"list"
of covaraince matrices of Bradley's scores in each class and for each criteria
Methods
- getIc
signature(object = "BradleyEstim")
- getLambda
signature(object = "BradleyEstim")
- getLvr
signature(object = "BradleyEstim")
- getLvriter
signature(object = "BradleyEstim")
- getPi
signature(object = "BradleyEstim")
- getRestestglob
signature(object = "BradleyEstim")
- getRestestprod
signature(object = "BradleyEstim")
- getVarcov
signature(object = "BradleyEstim")
- getZh
signature(object = "BradleyEstim")
- show
signature(object = "BradleyEstim")
Examples
data(ResCocktail1)
show(ResCocktail1)
Estimation of Bradley's scores
Description
Returns the Bradley's scores of the different items and the value of the LogLikelihood
Usage
C_piBTL(Matpair, Constraint=0, eps1=1e-04, Pi=NULL, TestPi=FALSE, Zht=NULL)
Arguments
Matpair |
Matrix of the cumulative sum of the results of paired comparisons or object of class |
Constraint |
Kind of constraint on Bradley's scores. If |
eps1 |
value to take into account for the convergence criteria of the algorithm of |
Pi |
Initial values for Bradley's scores. If |
TestPi |
Indicate if the user wants to perform a multiple comparison tests on the Bradley's scores. |
Zht |
Indicate the individuals probabilities to belong to the different classes. |
Details
The algorithm is based on a maximum likelihood approach using Dykstra method.
Value
List of following components:
Pi |
Bradley's scores |
lnL |
value of the log-likelihood |
lvrHO |
value of the log-likelihood under the hypothesis of equal values for the Bradley's scores |
lvrH1 |
value of the log-likelihood at the end of the Bradley's scores estimation algorithm |
lRatio |
value of the likelihood ration statistic |
Pvalue |
Pvalue of the test |
H1 |
logical value, FALSE if Bradley's scores should be considered as equal, TRUE otherwise |
VarcovPi |
Matrix of covariances of Bradley's scores |
restestij |
Matrix of the following elements |
Examples
data(Cocktail_Cum)
res<-C_piBTL(Cocktail_Cum,Constraint=0,eps1=1e-04,Pi=NULL,TestPi=TRUE)
res
Create an object of class DataPairComp
Description
return an object of DataPairComp
class
Usage
ClassDataPairComp(Mat, labelprod = NULL, labelcons = NULL, labelcrit = NULL)
Arguments
Mat |
Paired comparison matrix with a number of rows equal to nsubject*nitems and nitems columns. |
labelprod |
names of the different items (default |
labelcons |
names of the different subjects (default |
labelcrit |
name of the criterium (default |
Value
Object of class DataPairComp
with the following elements:
Cons
: corresponding to the label of consummers (default : Number of consummers)
Crit
: name of the different criteria contained
Prod
: names of the different products (default : number of the product)
Paircomp
: list
of number of criteria elements each corresponding to the results of paired comparisons performed by the consummers.
Classification of paired comparison data
Description
Returns the result of consummers classification
Usage
ClassifPaired(Data,Tcla)
Arguments
Data |
Object of class |
Tcla |
Number of classes to use for classification |
Details
The function performs a hierarchical cluster analysis on a set of dissimilarities based on pairwise comparison matrices, using the functions hclust
and cutree
of stats package.
Value
vector with group menberships resulting from the classification with Tcla clusters.
See Also
hclust
, cutree
of stats package
Beverages paired comparison
Description
Paired comparison of 7 beverages by 112 subjects according their preferences
Usage
data(Cocktail)
Format
A DataPairComp
class object with the following elements:
Cons
: corresponding to the label of consummers (default : Number of consummers)
Crit
: name of the different criteria contained
Prod
: names of the different products (default : number of the product)
Paircomp
: list
of number of criteria elements each corresponding to the results of paired comparisons performed by the consummers.
Examples
data(Cocktail)
show(Cocktail)
Beverages paired comparison
Description
Paired comparison of 7 beverages by 112 subjects according their preferences
Usage
data(Cocktail)
Format
A matrix resulting of the cumulative paired comparison results of 7 products by 112 consumers. The (i,j) element correponds to the number of time product i was prefered to product j among all comparisons between these two products.
Examples
data(Cocktail_Cum)
Cocktail_Cum
Class "DataPairComp"
Description
A class for Paired comparison data
Objects from the Class
Objects can be created by calls of the form new("DataPairComp", ...)
, or by the function ImportData()
.
Slots
Cons
:Object of class
"character"
label for the individualsCrit
:Object of class
"character"
label for the criterionProd
:Object of class
"character"
label for the productsPaircomp
:Object of class
"list"
corresponding to the individual results of paired comparisons for each criteria, when products i and j are presented to individual h, the (i,j) element resulting is coded by 1 if i is choosen against j and 0 otherwise
Methods
- getCons
signature(object = "DataPairComp")
- getCrit
signature(object = "DataPairComp")
- getPaircomp
signature(object = "DataPairComp")
- getProd
signature(object = "DataPairComp")
- show
signature(object = "DataPairComp")
See Also
ImportData
Examples
data(Cocktail)
show(Cocktail)
Simulation of paired comparison data
Description
Returns paired comparison data according a given configuration
Usage
DataSimulH0(Data, ResH0)
Arguments
Data |
Object of class |
ResH0 |
Object of class |
Details
The paired comparison data are simulated according the products configuration, the weight of the different classes for the different criteria (stored in the object ResH0
of class BradleyEstim
) obtained on the basis of the results of EstimBradley
function for the paired comparison data contained in the objet Data
of class DataPairComp
Value
Object of class DataPairComp
with the following components:
Cons
: corresponding to the label of consummers
Crit
: names of the different criteria
Prod
: names of the different products
Paircomp
: list
of number of criteria elements each corresponding to the results of simulated paired comparisons performed by the consummers according their belonging to the different classes.
Estimation of Bradley's scores in the different classes of subjects
Description
Estimates Bradley's scores according the desired number of classes.
Usage
EstimBradley(Data, Constraint=0, Tcla=1, eps=1e-04, eps1=1e-04, TestPi=TRUE)
Arguments
Data |
Object of class |
Constraint |
Kind of constraint on Bradley's scores. If |
Tcla |
Number of classes, default=1, no segmentation. |
eps |
value of the convergence criteria for the EM algorithm (default |
eps1 |
value of the criteria convergence for Dykstra algorithm (default |
TestPi |
if |
Details
The estimation is based on maximum likelihood for mixture distributions with E.M. algorithm.
Value
Object of class BradleyEstim
with the following components:
Lvriter |
|
Lvr |
Final value of the log likelihood |
Lambda |
|
Pi |
|
Zh |
|
IC |
value of Information Criterion (AIC,BIC,CAIC) |
Restestglob |
(given if
|
Restestprod |
(given if class identification, criterion identification, product identification i, product identification j, value for the statistic corresponding to H0: equality of the Bradley's scores of products i and j, P value of this test, Rejection or acceptation of H0 for a level of 5%. |
Varcov |
(given if
|
Examples
data(Cocktail)
show(Cocktail)
ResCock1<-EstimBradley(Cocktail,Constraint=0,Tcla=1,eps=0.001,eps1=0.001,TestPi=TRUE)
show(ResCock1)
Import data file
Description
Import the different paired comparison data files in cvs format and create an object
of class DataPairComp
Usage
ImportData(name,labelprod=FALSE,labelconso=NULL, sep =";",dec=".")
Arguments
name |
part of name of the different data files (.csv files) |
labelprod |
indicate the existence of labels of the different products in data files |
labelconso |
vector of label of consummers given by the user (default= |
sep |
the field separator character. Values on each line of the file are separated by this character.(default= |
dec |
the character used in the file for decimal points.(default= |
Value
Object of class DataPairComp
with the following elements:
Cons
: corresponding to the label of consummers (default : Number of consummer)
Crit
: names of the different criteria contained in the name of the different data files
Prod
: names of the different products (default : number of the product)
Paircomp
: list
of number of criteria elements each corresponding to the results of paired comparisons performed by the consummers.
Class "LvrRatio"
Description
A class for Lilkelihood Ration Test results
Objects from the Class
Objects can be created by ResSimulLvrRatio().
Slots
Simu
:Object of class
"matrix"
with the number of classes under H0, Loglikelihoods under H0 and H1, difference between these Loglikelihoods.Test
:Object of class
"matrix"
with the level and the associated quantile after performing Likelihood Ratio test.
Methods
- getSimu
signature(object = "LvrRatio")
- getTest
signature(object = "LvrRatio")
Examples
showClass("LvrRatio")
Graphical representation of the Bradley's scores
Description
Gives a graphical representation of the Bradley's scores.
Usage
Piplot(Pi, SigmaPi = NULL, level=0.05, main = NULL, ylab = "Bradley's scores",
xlab = "Item", labelprod = NULL)
Arguments
Pi |
vector of Bradley's scores |
SigmaPi |
vector of Bradley's scores standard deviation given by the user. |
level |
level to use for the confidence intervals. (default |
main |
Title of the plot.(default |
ylab |
value for |
xlab |
value for |
labelprod |
label vector of the Item. (default |
Details
The representation is based on plot(x) function, with Item on x axis, and Bradley's scores on y axis. If SigmaPi
is provided by user, a 1-level
(default 95%) confidence interval is drawn for each Item.
Value
A graphical representation of bradley's scores.
Examples
data(Cocktail_Cum)
res<-C_piBTL(Cocktail_Cum,Constraint=0,eps1=0.0001,Pi=NULL,TestPi=TRUE)
Res_Pi<-res$Pi
Res_Varcov<-res$VarcovPi
Res_Sigma<-sqrt(diag(Res_Varcov))
Piplot(Res_Pi, SigmaPi = Res_Sigma, level=0.01, main = NULL, ylab = "Bradley's scores",
xlab = "Item", labelprod = NULL)
Result of EstimBradley
function for 1 class and data Cocktail
Description
Result of EstimBradley
function for 1 class and data Cocktail
Usage
data(ResCocktail1)
Format
A BradleyEstim
class object with the following elements:
Examples
data(ResCocktail1)
show(ResCocktail1)
Log Likelihood Ratio Test for Paired comparison data
Description
Returns the result of Log Likelihood Ratio Test of the number of classes for Paired comparison data (T classes versus (T+1) classes)
Usage
ResSimulLvrRatio(Data,ResH0,Constraint,nsimul,level,eps=1e-04,eps1=1e-04)
Arguments
Data |
Object of class |
ResH0 |
Object of class |
Constraint |
Kind of constraint on Bradley's scores. If |
nsimul |
number of Monte Carlo simulations |
level |
level of the Log Likelihood Ratio test defined by the user (default |
eps |
value of the convergence criteria for the EM algorithm (default |
eps1 |
value of the criteria convergence for Dykstra algorithm (default |
Details
The likelihood ratio test is based on a Monte Carlo procedure. A simulation of nsimul
data set is done. We perform estimation of the different parameters for the number of classes defined in the object ResH0
of class BradleyEstim
(corresponding to
the null hymothesis) and for one more class corresponding to the alternative hypothesis.
We obtain a set of Log Likelihoods under the null and alternative hypothesis on the basis of simulated data and so of the Log Likelihood Ratio Statistic.
We replace the observed value of this statistic for the true data set. And we conclude on the acceptation or not of the null hypothesis (no differences between T and T+1 classes).
Value
Object of class LvrRatio
with the following components:
Simu |
Matrix with the number of classes under H0, Loglikelihoods under H0 and H1, difference between these Loglikelihoods. |
Test |
Matrix with the level of the test and the associated quantile |
Examples
data(Cocktail)
ResCock1<-EstimBradley(Cocktail,Constraint=0,Tcla=1,eps=1e-04,eps1=1e-04,TestPi=TRUE)
Res_LvrRatio1<-ResSimulLvrRatio(Cocktail,ResCock1,0,3,level=0.05,eps=0.001,eps1=0.001)
getSimu(Res_LvrRatio1)
getTest(Res_LvrRatio1)
Gets the individuals labels.
Description
Gets the individuals labels.
Usage
getCons(object)
Arguments
object |
An object of class |
Value
vector of the individuals labels.
Examples
data(Cocktail)
Cocktail_Cons<-getCons(Cocktail)
Methods for Function getCons
Description
Methods for function getCons
Methods
signature(object = "DataPairComp")
Gets the criteria's labels.
Description
Gets the criteria's labels.
Usage
getCrit(object)
Arguments
object |
An object of class |
Value
vector of the criteria's labels.
Examples
data(Cocktail)
Cocktail_Crit<-getCrit(Cocktail)
Methods for Function getCrit
Description
Methods for function getCrit
Methods
signature(object = "DataPairComp")
Gets the Information criteria's labels.
Description
Gets the Information criteria's labels (AIC, BIC, CAIC).
Usage
getIc(object)
Arguments
object |
An object of class |
Value
vector of Information criteria.
Examples
data(Cocktail)
ResCock<-EstimBradley(Cocktail,Constraint=0,Tcla=1,eps=1e-04,eps1=1e-04,TestPi=TRUE)
ResCock_Ic<-getIc(ResCock)
Methods for Function getIc
Description
Methods for function getIc
Methods
signature(object = "BradleyEstim")
Gets the weight of the different classes.
Description
Gets the weight of the different classes from the function EstimBradley()
.
Usage
getLambda(object)
Arguments
object |
An object of class |
Value
A vector of the weights of the different classes.
Examples
data(Cocktail)
ResCock<-EstimBradley(Cocktail,Constraint=0,Tcla=1,eps=1e-04,eps1=1e-04,TestPi=TRUE)
ResCock_Lambda<-getLambda(ResCock)
Methods for Function getLambda
Description
Methods for function getLambda
Methods
signature(object = "BradleyEstim")
Gets the final value of loglikelihood.
Description
Gets the final value of loglikelihood from the function EstimBradley()
.
Usage
getLvr(object)
Arguments
object |
An object of class |
Value
Numeric value of the loglikelihood.
Examples
data(Cocktail)
ResCock<-EstimBradley(Cocktail,Constraint=0,Tcla=1,eps=1e-04,eps1=1e-04,TestPi=TRUE)
ResCock_Lvr<-getLvr(ResCock)
Methods for Function getLvr
Description
Methods for function getLvr
Methods
signature(object = "BradleyEstim")
Gets the iteration done until convergence of the loglikelihood estimation of Bradley's scores.
Description
Gets the iteration done until convergence from the function EstimBradley()
Usage
getLvriter(object)
Arguments
object |
An object of class |
Value
A matrix with numbers of iteration rows and 4 columns giving the iteration, the previous value of loglikelihood, the current value of the loglikelihood, and the difference between these loglikelihoods.
Examples
data(Cocktail)
ResCock<-EstimBradley(Cocktail,Constraint=0,Tcla=1,eps=1e-04,eps1=1e-04,TestPi=TRUE)
ResCock_Lvriter<-getLvriter(ResCock)
Methods for Function getLvriter
Description
Methods for function getLvriter
Methods
signature(object = "BradleyEstim")
Gets the individual paired comparisons.
Description
Gets the individual paired comparisons.
Usage
getPaircomp(object)
Arguments
object |
An object of class |
Value
list
of number of criteria elements each corresponding to the results of paired comparisons performed by the consummers.
Examples
data(Cocktail)
Cocktail_Paircomp<-getPaircomp(Cocktail)
Methods for Function getPaircomp
Description
Methods for function getPaircomp
Methods
signature(object = "DataPairComp")
Gets the Bradley's scores.
Description
Gets the Bradley's scores from the function EstimBradley()
.
Usage
getPi(object)
Arguments
object |
An object of class |
Value
A list of the Bradley's scores for the different criteria .
Examples
data(Cocktail)
ResCock<-EstimBradley(Cocktail,Constraint=0,Tcla=1,eps=1e-04,eps1=1e-04,TestPi=TRUE)
ResCock_Pi<-getPi(ResCock)
Methods for Function getPi
Description
Methods for function getPi
Methods
signature(object = "BradleyEstim")
Gets the products labels.
Description
Gets the products labels.
Usage
getProd(object)
Arguments
object |
An object of class |
Value
vector of the products labels.
Examples
data(Cocktail)
Cocktail_Prod<-getProd(Cocktail)
Methods for Function getProd
Description
Methods for function getProd
Methods
signature(object = "DataPairComp")
Gets the result of the test of Bradley's scores equality.
Description
Gets the result of the test of Bradley's scores equality from the function EstimBradley()
.
Usage
getRestestglob(object)
Arguments
object |
An object of class |
Value
list
of five elements:
lvrH0
matrix
of size (Tcla
* number of criteria), giving the value of the log likelihood under the hypothesis of equality of Bradley's scores
lvrH1
matrix
of size (Tcla
* number of criteria), giving the value of the log likelihood under the hypothesis of non equality of Bradley's scores
lRatio
matrix
of size (Tcla
* number of criteria), giving the value of the log likelihood Ratio statistic
Pvalue
matrix
of size (Tcla
* number of criteria), giving the P value of the log likelihood Ratio test
H1
matrix
of size (Tcla
* number of criteria) giving the result of rejection of equality of Bradley's scores
Examples
data(Cocktail)
ResCock<-EstimBradley(Cocktail,Constraint=0,Tcla=1,eps=1e-04,eps1=1e-04,TestPi=TRUE)
ResCock_Restestglob<-getRestestglob(ResCock)
Methods for Function getRestestglob
Description
Methods for function getRestestglob
Methods
signature(object = "BradleyEstim")
Gets the result of the Bradley's scores multiple comparison tests.
Description
Gets the result of the Bradley's scores multiple comparison tests from the
function EstimBradley()
.
Usage
getRestestprod(object)
Arguments
object |
An object of class |
Value
list
of Tcla
elements of type matrix
of size (number of paired comparison * 7),
each column corresponding to:
class identification,
criterion identification,
product identification i,
product identification j,
value for the statistic corresponding to H0: equality of the Bradley's scores of products i and j,
P value of this test,
Rejection or acceptation of H0 for a level of 5%.
Examples
data(Cocktail)
ResCock<-EstimBradley(Cocktail,Constraint=0,Tcla=1,eps=1e-04,eps1=1e-04,TestPi=TRUE)
ResCock_Restestprod<-getRestestprod(ResCock)
Methods for Function getRestestprod
Description
Methods for function getRestestprod
Methods
signature(object = "BradleyEstim")
Gets the results of Likelihood Ratio Test.
Description
Gets the results of Likelihood Ratio Test obtained by Monte-Carlo simulations.
Usage
getSimu(object)
Arguments
object |
An object of class |
Value
A matrix with the number of classes under H0, the values of Loglikelihood under H0 and H1 and the differences between these Loglikelihoods.
Methods for Function getSimu
Description
Methods for function getSimu
Methods
signature(object = "LvrRatio")
Gets the level and the quantile of Likelihood ratio test.
Description
Gets the level and the quantile of Likelihood ratio test from the function ResSimulLvrRatio()
Usage
getTest(object)
Arguments
object |
An object of class |
Value
Matrix with the level and the associated quantile after performing Likelihood Ratio test.
Methods for Function getTest
Description
Methods for function getTest
Methods
signature(object = "LvrRatio")
Gets the Bradley'scores covariance matrices.
Description
Gets the Bradley'scores covariance matrices from the function EstimBradley()
.
Usage
getVarcov(object)
Arguments
object |
An object of class |
Value
list
of Tcla
elements containing Bradley'scores covariance matrices for the different criteria.
Examples
data(Cocktail)
ResCock<-EstimBradley(Cocktail,Constraint=0,Tcla=1,eps=1e-04,eps1=1e-04,TestPi=TRUE)
ResCock_Varcov<-getVarcov(ResCock)
Methods for Function getVarcov
Description
Methods for function getVarcov
Methods
signature(object = "BradleyEstim")
Gets the result of the function EstimBradley()
Description
Gets the posterior probabilities for each individual to belong to the different classes and the class with the higher probability.
Usage
getZh(object)
Arguments
object |
An object of class |
Value
Object of class matrix
with the posterior probabilities for each individual to belong to the different classes and the class with the higher probability.
Examples
data(Cocktail)
ResCock2<-EstimBradley(Cocktail,Constraint=0,Tcla=2,eps=1e-04,eps1=1e-04,TestPi=TRUE)
ResCock2_Zh<-getZh(ResCock2)
Methods for Function getZh
Description
Methods for function getZh
Methods
signature(object = "BradleyEstim")
Methods for Function show
Description
Methods for function show
Methods
signature(object = "BradleyEstim")
signature(object = "DataPairComp")