Title: | Free Sorting Data Analysis |
---|---|
Description: | Provides tools for describing and analysing free sorting data. Main methods are computation of consensus partition and factorial analysis of the dissimilarity matrix between stimuli (using multidimensional scaling approach). |
Authors: | Philippe Courcoux |
Maintainer: | Philippe Courcoux <[email protected]> |
License: | GPL-2 |
Version: | 1.3 |
Built: | 2024-11-28 06:51:39 UTC |
Source: | CRAN |
This package gives several tools for analysing free sorting data.
Package: | FreeSortR |
Type: | Package |
Version: | 1.0 |
Date: | 2014-04-29 |
License: | GPL |
Depends: | methods, smacof |
The function for managing sorting data is SortingPartition()
.Function for computing consensus partition is ConsensusPartition()
. Multidimensional scaling of sorting data may be performed with the function MdsSort()
.
Philippe Courcoux
Maintainer: <[email protected]>
Ph. Courcoux, P. Faye, E.M. Qannari (2014) Determination of the consensus partition and cluster analysis of subjects in a free sorting task experiment. Food Quality and Preference, 32, 107-112.
SortingPartition
, ConsensusPartition
, MdsSort
data(AromaSort) Aroma<-SortingPartition(AromaSort) res<-ConsensusPartition(Aroma) DescriptionPartition(res$Consensus) resMds<-MdsSort(Aroma,ndim=3) plotMds(resMds)
data(AromaSort) Aroma<-SortingPartition(AromaSort) res<-ConsensusPartition(Aroma) DescriptionPartition(res$Consensus) resMds<-MdsSort(Aroma,ndim=3) plotMds(resMds)
Partitions of 16 aromas by 31 subjects (free sorting task)
data(AromaSort)
data(AromaSort)
A data frame with 16 observations (aromas) and 31 variables (subjects).
List of stimuli : Lemon, Grapefruit, Pineapple, Pear, Honey, Butter, Grilledbread, Grilledhazelnut, Strawberry, Raspberry, Cherry, Blackcurrant, Greenpepper, Smoked, Pepper, Licorice.
Ph. Courcoux, P. Faye, E.M. Qannari (2014) Determination of the consensus partition and cluster analysis of subjects in a free sorting task experiment. Food Quality and Preference 32, 107-112
data(AromaSort)
data(AromaSort)
Free sorting of 16 aromas described by 31 subjects. Data are occurences of terms for describing stimuli. Partitions given by the subjects are described in the AromaSort data.
data(AromaTerms)
data(AromaTerms)
A data frame with 16 observations (aromas) and 36 variables (terms). Rownames and colnames refer to stimuli and terms labels.
List of terms : Acid, Smoked ,Heady, Citrus, Lemon, Cake, Milk, Woody, Grain, Low, Redfruit, Grilled, Strong, Fat, Vegetal, Medicine, Chemical, Licorice, Bread, Alcohol, Almond, Caramel, Coal, Unpleasant, Soft, Pepper, Flower, Fresh, Red, Fruit, Natural, Spicy, Sugar, Hot, Pleasant, Candy.
data(AromaTerms)
data(AromaTerms)
Returns the consensus partition among a set of partitions
ConsensusPartition(Part, ngroups = 0, type = "cutree", optim = FALSE, maxiter = 100, plotDendrogram = FALSE, verbose = FALSE)
ConsensusPartition(Part, ngroups = 0, type = "cutree", optim = FALSE, maxiter = 100, plotDendrogram = FALSE, verbose = FALSE)
Part |
Object of class |
ngroups |
Number of groups of the consensus (or |
type |
Method ( |
optim |
Optimisation of the consensus (default is |
maxiter |
Maximum number of iterations for fusion algorithm |
plotDendrogram |
Plot of the dendrogram (if |
verbose |
Print the initialisation results |
The criterion for optimal consensus is the mean adjusted Rand Index between the consensus and the partitions given by the subjects.
If ngroups=0
, consensus is computed between 2 and nstimuli-1 and the best consensus is returned.
For type="cutree"
, the initialisation step is based on cutting the tree generated by clustering the stimuli. For type="fusion"
, the initialisation step is based on the fusion algorithm. In this case, results are more accurate but the algorithm might be time consuming. For type="medoid"
, the consensus is the closest partition to all the partitions given by subjects.
For optim=TRUE
, a transfer step is performed after the initialisation step.
List of following components:
Consensus |
Consensus |
Crit |
Criterion for consensus |
Krieger & Green (1999) J. of Classification, 16:63-89
data(AromaSort) Aroma<-SortingPartition(AromaSort) res<-ConsensusPartition(Aroma,ngroups=0,type="cutree") res ##res<-ConsensusPartition(Aroma,ngroups=0,type="fusion",optim=TRUE) ##res ##res<-ConsensusPartition(Aroma,type="medoid") ##res
data(AromaSort) Aroma<-SortingPartition(AromaSort) res<-ConsensusPartition(Aroma,ngroups=0,type="cutree") res ##res<-ConsensusPartition(Aroma,ngroups=0,type="fusion",optim=TRUE) ##res ##res<-ConsensusPartition(Aroma,type="medoid") ##res
Returns the matrix of cooccurrences between stimuli.
Cooccurrences(Part)
Cooccurrences(Part)
Part |
Object of class |
Returns the matrix of cooccurrences between stimuli (number of times two stimuli have been sorted in the same group).
A matrix of cooccurrences (stimuli x stimuli).
data(AromaSort) Aroma<-SortingPartition(AromaSort) MatCooc<-Cooccurrences(Aroma)
data(AromaSort) Aroma<-SortingPartition(AromaSort) MatCooc<-Cooccurrences(Aroma)
DescriptionPartition()
shows a partition given by a subject.
DescriptionPartition(Part, subject = 1, replicate = 1, Labels=NULL)
DescriptionPartition(Part, subject = 1, replicate = 1, Labels=NULL)
Part |
Object of class |
subject |
Subject identifier (number or label of a subject) |
replicate |
Number of the replicate to show (in the case of multiple partitions) |
Labels |
Labels of the stimuli |
Returns the partition with labels of stimuli bracketted in groups.
data(AromaSort) Aroma<-SortingPartition(AromaSort) DescriptionPartition(Aroma,subject=1)
data(AromaSort) Aroma<-SortingPartition(AromaSort) DescriptionPartition(Aroma,subject=1)
Creates a list of dissimilarity matrices from partitions given by the subjects.
Dissimil(Part)
Dissimil(Part)
Part |
Object of class |
In the case of free sorting data, a list of dissimilarity matrices (the length of the list is equal to the number of subjects).
In the case of multiple sorting, dissimilarity matrix for a subject is the sum of the dissimilarity matrices computed from each of the different partitions given by this subject.
A list of dissimilarity matrices (one matrix for each subject).
data(AromaSort) Aroma<-SortingPartition(AromaSort) ListDiss<-Dissimil(Aroma)
data(AromaSort) Aroma<-SortingPartition(AromaSort) ListDiss<-Dissimil(Aroma)
Creates the matrix of dissimilarities between stimuli.
DissTot(Part)
DissTot(Part)
Part |
Object of class |
The matrix of dissimilarities between stimuli (number of times that two stimuli have not been grouped)
data(AromaSort) Aroma<-SortingPartition(AromaSort) DisTot<-DissTot(Aroma)
data(AromaSort) Aroma<-SortingPartition(AromaSort) DisTot<-DissTot(Aroma)
Gets the Mds config resulting from the function MdsSort()
.
getConfig(object)
getConfig(object)
object |
An object of class |
An array of Mds configuration
data(AromaSort) Aroma<-SortingPartition(AromaSort) resMds<-MdsSort(Aroma,ndim=2) config<-getConfig(resMds)
data(AromaSort) Aroma<-SortingPartition(AromaSort) resMds<-MdsSort(Aroma,ndim=2) config<-getConfig(resMds)
Returns an array of the partitions given by the subjects.
getPartition(object)
getPartition(object)
object |
An object of class |
An array of the stimuli as rows and the partitions as columns.
data(AromaSort) Aroma<-SortingPartition(AromaSort) part<-getPartition(Aroma)
data(AromaSort) Aroma<-SortingPartition(AromaSort) part<-getPartition(Aroma)
Returns the percentage of variance explained by the dimensions of a Mds solution returned by the function MdsSort()
.
getPercent(object)
getPercent(object)
object |
An object of class |
A vector of percentage of variance of the Mds configuration.
data(AromaSort) Aroma<-SortingPartition(AromaSort) resMds<-MdsSort(Aroma,ndim=2) perc<-getPercent(resMds)
data(AromaSort) Aroma<-SortingPartition(AromaSort) resMds<-MdsSort(Aroma,ndim=2) perc<-getPercent(resMds)
Get the Kruskal stress value of the Mds solution returned by the function MdsSort()
.
getStress(object)
getStress(object)
object |
An object of class |
A numeric value of stress.
data(AromaSort) Aroma<-SortingPartition(AromaSort) resMds<-MdsSort(Aroma,ndim=2) stress<-getStress(resMds)
data(AromaSort) Aroma<-SortingPartition(AromaSort) resMds<-MdsSort(Aroma,ndim=2) stress<-getStress(resMds)
MdsDimChoice()
returns a table of stress values of Multidimensionnal scaling for different dimensions. The different dimensions to test are given as an argument of the function.
The Mds is based on smacof algorithm and may be metric or not metric.
MdsDimChoice(Part, dimen = c(2, 4), metric = FALSE, ties = "primary", itmax = 5000, eps = 1e-06)
MdsDimChoice(Part, dimen = c(2, 4), metric = FALSE, ties = "primary", itmax = 5000, eps = 1e-06)
Part |
Part is an object of class |
dimen |
Vector of (minimum and maximum of) dimensions for Mds (default is |
metric |
Metric or non metric Mds (default is |
ties |
Treatment of ties in case of non metric Mds |
itmax |
Maximum number of iterations |
eps |
Epsilon for Mds computation |
Table of Kruskal stress for the chosen dimensions
data(AromaSort) Aroma<-SortingPartition(AromaSort) tabres<-MdsDimChoice(Aroma)
data(AromaSort) Aroma<-SortingPartition(AromaSort) tabres<-MdsDimChoice(Aroma)
Computes the multidimensional scaling of a matrix of dissimilarities between stimuli. Mds is based on smacof algorithm. The Mds configuration is rotated in order to get orthogonal dimensions sorted by decreasing variance.
MdsDiss(MatDissimil, ndim = 2, metric = TRUE, ties = "primary", itmax = 5000, eps = 1e-06)
MdsDiss(MatDissimil, ndim = 2, metric = TRUE, ties = "primary", itmax = 5000, eps = 1e-06)
MatDissimil |
A matrix of dissimilarities |
ndim |
Dimension of the Mds |
metric |
Metric or not metric Mds |
ties |
Treatment of ties in case of non metric Mds |
itmax |
Maximum number of iterations |
eps |
Epsilon for Mds computation |
List of the following components :
Config |
Mds configuration of the stimuli |
Percent |
Percentage of inertia of the dimensions of Mds |
Stress |
Stress of the Mds solution |
data(AromaSort) Aroma<-SortingPartition(AromaSort) ListDissimil<-Dissimil(Aroma) MatDissim<-apply(simplify2array(ListDissimil),c(1,2),'sum') Mdsres<-MdsDiss(MatDissim)
data(AromaSort) Aroma<-SortingPartition(AromaSort) ListDissimil<-Dissimil(Aroma) MatDissim<-apply(simplify2array(ListDissimil),c(1,2),'sum') Mdsres<-MdsDiss(MatDissim)
MdsSort returns the results of the multidimensional scaling of a list of dissimilarities. The Mds is based on smacof algorithm and may be metric or not metric.
Botstrap on subjects allows to draw confidence regions for the stimuli.
MdsSort(Part,ndim=2,nboot=0,metric=FALSE,ties="primary",itmax=5000,eps=1e-06)
MdsSort(Part,ndim=2,nboot=0,metric=FALSE,ties="primary",itmax=5000,eps=1e-06)
Part |
Part is an object of class |
ndim |
Dimension of the Mds (default is |
nboot |
Number of bootstrap samples (default is |
metric |
Metric or non metric Mds (default is |
ties |
Treatment of ties in case of non metric Mds |
itmax |
Number maximum of iterations |
eps |
Epsilon fot Mds computation |
An object of class SortingMds
data(AromaSort) Aroma<-SortingPartition(AromaSort) resMds<-MdsSort(Aroma,ndim=2)
data(AromaSort) Aroma<-SortingPartition(AromaSort) resMds<-MdsSort(Aroma,ndim=2)
Returns the number of groups given by the subjects of a free sorting experiment.
nGroups(object)
nGroups(object)
object |
An object of class |
A vector giving the number of groups made by the subjects
data(AromaSort) Aroma<-SortingPartition(AromaSort) nGroups(Aroma)
data(AromaSort) Aroma<-SortingPartition(AromaSort) nGroups(Aroma)
plotMds returns a plot of the configuration resulting from a Multidimensionnal scaling.
Confidence ellipsoids are plotted if a bootstrap approach has been used in the MdsSort()
step.
plotMds(ResMds, dim=c(1,2), ellipse=FALSE, proba=0.90, col=NULL)
plotMds(ResMds, dim=c(1,2), ellipse=FALSE, proba=0.90, col=NULL)
ResMds |
ResMds is an object of class |
dim |
Vector of dimensions to be plotted (default is |
ellipse |
Indicates if ellipsoids have to be plotted (default if |
proba |
Probability for plotting ellipses (default is |
col |
The color to be used for the text, possibly vectors |
plot of Mds configuration
data(AromaSort) Aroma<-SortingPartition(AromaSort) resMds<-MdsSort(Aroma,ndim=2) plotMds(resMds)
data(AromaSort) Aroma<-SortingPartition(AromaSort) resMds<-MdsSort(Aroma,ndim=2) plotMds(resMds)
plotTerms()
produces a plot of the terms. The rows of array MatTerms
are the stimuli and the columns are the terms.
plotTerms(MatTerms,ResMds,dim=c(1,2),type="correl",add=TRUE)
plotTerms(MatTerms,ResMds,dim=c(1,2),type="correl",add=TRUE)
MatTerms |
Array of occurrences of terms |
ResMds |
Object of class |
dim |
Vector of dimensions to be plotted (default is |
type |
Indicates the type of plotting (default is |
add |
Indicates if the stimuli are added to the plot (if |
If type="correl"
, the correlations between occurrences of terms and dimensions of a Mds configuration are plotted. plotTerms()
returns the correlation matrix.
If type="baryc"
, a barycentric representation of terms is used. If add=TRUE
, the stimuli are added to this plot. plotTerms()
returns the coordinates of terms.
returns a matrix of correlation or a configuration of terms (depending on type
).
data(AromaSort) Aroma<-SortingPartition(AromaSort) resMds<-MdsSort(Aroma,ndim=2) data(AromaTerms) plotTerms(AromaTerms,resMds)
data(AromaSort) Aroma<-SortingPartition(AromaSort) resMds<-MdsSort(Aroma,ndim=2) data(AromaTerms) plotTerms(AromaTerms,resMds)
Computes the Rand Index and the Adjusted Rand Index between two partitions
RandIndex(Partition1, Partition2)
RandIndex(Partition1, Partition2)
Partition1 |
Vector describing the first partition |
Partition2 |
Vector describing the second partition |
Supports incomplete partitions (value 0 is coding for missing stimulus)
List of following components:
Rand |
Rand Index between the partitions |
AdjustedRand |
Adjusted rand Index between the partitions |
Rand (1971) Jasa, 66, 846-850
Hubert & Arabie (1985) J. of Classification, 2, 193-218
Partition1<-c(1,1,1,2,2,2) Partition2<-c(1,1,2,2,2,3) r<-RandIndex(Partition1,Partition2) r # $Rand # [1] 0.6 # $AdjustedRand # [1] 0.1176471
Partition1<-c(1,1,1,2,2,2) Partition2<-c(1,1,2,2,2,3) r<-RandIndex(Partition1,Partition2) r # $Rand # [1] 0.6 # $AdjustedRand # [1] 0.1176471
The function (ReadSortFile()
) reads a csv file of free sorting data.
The file contains stimuli as rows and subjects as columns. For a subject, two stimuli in the same group are coded by the same symbol. First row contains the labels of subjects and first column contains the labels of stimuli.
For each subject, the coding of a group may be a number or a list of terms describing the group (terms have to be separated by a symbol, as a comma).
Returns a matrix of sorting and, if this is adequate, matrices describing the use of terms by subjects.
ReadSortFile(filename, terms=FALSE, septerms=",", sep=";", dec=".")
ReadSortFile(filename, terms=FALSE, septerms=",", sep=";", dec=".")
filename |
File name (and address if necessary) |
terms |
Boolean indicating if groups are coded by terms ( |
septerms |
Symbol for separating terms (default is |
sep |
Symbol for separating data in the csv file (default is |
dec |
Decimal separator (default is |
List of the following components :
MatSort |
Matrix of sorting groups (may be used by the function SortingPartition) |
MatTerms |
Matrix of occurences of the terms used by the subjects |
Stress |
List of terms used by each subject |
# dat<-ReadSortFile ("FSdata.csv") # Sort<-SortingPartition(dat$MatSort)
# dat<-ReadSortFile ("FSdata.csv") # Sort<-SortingPartition(dat$MatSort)
SortingMds
A class for Mds results
Objects are created by the function MdsSort()
.
nstimuli
:Number of stimuli
nsubjects
:Number of subjects
LabStim
:Labels of stimuli
LabSubj
:Labels of subjects
ndim
:Dimension of the Mds
Config
:Array of the configuration of stimuli
Percent
:Vector of inertia of the dimensions
Stress
:Kruskal stress of the configuration
ResBoot
:(optional) Results of bootstrap on the subjects
signature(object = "SortingMds")
signature(object = "SortingMds")
signature(object = "SortingMds")
show(object = "SortingMds")
summary(object = "SortingMds")
data(AromaSort) Aroma<-SortingPartition(AromaSort) resMds<-MdsSort(Aroma,ndim=2,metric=FALSE) summary(resMds)
data(AromaSort) Aroma<-SortingPartition(AromaSort) resMds<-MdsSort(Aroma,ndim=2,metric=FALSE) summary(resMds)
SortingPartition
Returns an object of class SortingPartition
from an array containing the partitions.
The array has stimuli as rows and subjects as columns. For a subject, two stimuli in the same group are coded by the same number.
SortingPartition(DataSort)
SortingPartition(DataSort)
DataSort |
A dataframe containing the partitions of the subjects |
The first row contains the labels of subjects and the first column contains the labels of stimuli.
In the case of multiple sorting task, the different partitions given by the same subject are in columns sharing the same name (but with different subnames: A, A.1, A.2...) in the array.
A value of 0 indicates that the subject did not sort the given stimulus (in case of incomplete design).
An object of class SortingPartition
.
data(AromaSort) Aroma<-SortingPartition(AromaSort) show(Aroma)
data(AromaSort) Aroma<-SortingPartition(AromaSort) show(Aroma)
SortingPartition
A class for free sorting data
Objects can be created from an array by calls of the form SortingPartition()
.
type
: Type of sorting procedure : type="Free"
or type="Multiple"
nstimuli
:Number of stimuli
nsubjects
:Number of subjects
LabStim
:Labels of stimuli
LabSubj
:Labels of subjects
Partition
:List of partitions of the stimuli given by subjects
show(object = "SortingPartition")
summary(object = "SortingPartition")
getPartition(object = "SortingPartition")
nGroups(object = "SortingPartition")
data(AromaSort) Aroma<-SortingPartition(AromaSort) summary(Aroma) show(Aroma) getPartition(Aroma)
data(AromaSort) Aroma<-SortingPartition(AromaSort) summary(Aroma) show(Aroma) getPartition(Aroma)