caSegmentation: Function caSegmentation divides respondents on clusters

Description Usage Arguments Author(s) References Examples

View source: R/caSegmentation.R

Description

Function caSegmentation divides respondents on n clusters (segments) using k-means method (function kmeans, package stats). There are two data sets used - matrix or vector of preferences and matrix of profiles.

Usage

1

Arguments

y

matrix of preferences

x

matrix of profiles

c

number of clusters (optional), default value c=2

Author(s)

Andrzej Bak andrzej.bak@ue.wroc.pl,

Tomasz Bartlomowicz tomasz.bartlomowicz@ue.wroc.pl

Department of Econometrics and Computer Science, Wroclaw University of Economics, Poland http://keii.ue.wroc.pl/conjoint

References

Bak A., Bartlomowicz T. (2012), Conjoint analysis method and its implementation in conjoint R package, [In:] Pociecha J., Decker R. (Eds.), Data analysis methods and its applications, C.H.Beck, Warszawa, p.239-248.

Bak A. (2009), Analiza Conjoint [Conjoint Analysis], [In:] Walesiak M., Gatnar E. (Eds.), Statystyczna analiza danych z wykorzystaniem programu R [Statistical Data Analysis using R], Wydawnictwo Naukowe PWN, Warszawa, p. 283-317.

Green P.E., Srinivasan V. (1978), Conjoint Analysis in Consumer Research: Issues and Outlook, "Journal of Consumer Research", September, 5, p. 103-123.

SPSS 6.1 Categories (1994), SPSS Inc., Chicago.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#Example 1
library(conjoint)
require(fpc)
data(tea)
segments<-caSegmentation(tprefm,tprof)
print(segments$seg)
plotcluster(segments$util,segments$sclu)

#Example 2
library(conjoint)
require(fpc)
data(tea)
segments<-caSegmentation(tpref,tprof,3)
print(segments$seg)
plotcluster(segments$util,segments$sclu)

#example 3
library(conjoint)
require(fpc)
require(broom)
require(ggplot2)
data(tea)
segments<-caSegmentation(tprefm,tprof,3)
dcf<-discrcoord(segments$util,segments$sclu)
assignments<-augment(segments$segm,dcf$proj[,1:2])
ggplot(assignments)+geom_point(aes(x=X1,y=X2,color= .cluster))+labs(color="Cluster Assignment",
title="K-Means Clustering Results")

#Example 4
library(conjoint)
require(ggfortify)
data(tea)
segments<-caSegmentation(tpref,tprof,3)
print(segments$seg)
util<-as.data.frame(segments$util)
set.seed(123)
ggplot2::autoplot(kmeans(util,3),data=util,label=TRUE,label.size=4,frame=TRUE)

#Example 5
#library(conjoint)
#require(ggfortify)
#require(cluster)
#data(tea)
#segments<-caSegmentation(tpref,tprof,3)
#print(segments$seg)
#util<-as.data.frame(segments$util)
#ggplot2::autoplot(pam(util,3),label=TRUE,label.size=4,frame=TRUE,frame.type='norm')

Example output

Loading required package: fpc
K-means clustering with 2 clusters of sizes 53, 47

Cluster means:
      [,1]     [,2]     [,3]     [,4]     [,5]     [,6]     [,7]     [,8]
1 3.761302 5.725226 4.419566 5.961302 5.151642 3.632189 4.364264 3.177226
2 5.585766 2.854915 1.327255 4.317681 2.637894 3.885362 1.923660 1.707766
      [,9]     [,10]    [,11]     [,12]    [,13]
1 2.494208 2.9163962 5.999868 6.5642642 6.209547
2 3.082234 0.6331702 3.341809 0.6555745 1.153447

Clustering vector:
  [1] 2 1 1 1 1 2 1 2 1 1 1 1 2 2 2 2 1 2 1 2 2 1 2 1 1 2 1 1 1 1 2 1 2 1 1 1 1
 [38] 2 2 2 2 1 2 1 2 1 1 2 2 2 1 2 2 2 1 1 2 1 2 1 2 2 1 1 1 1 2 2 2 1 1 2 2 1
 [75] 1 1 1 2 1 2 1 1 1 1 2 2 2 2 1 2 1 2 1 2 2 1 2 2 1 1

Within cluster sum of squares by cluster:
[1] 4044.186 2442.875
 (between_SS / total_SS =  30.0 %)

Available components:

[1] "cluster"      "centers"      "totss"        "withinss"     "tot.withinss"
[6] "betweenss"    "size"         "iter"         "ifault"      
K-means clustering with 3 clusters of sizes 28, 32, 40

Cluster means:
      [,1]     [,2]     [,3]     [,4]     [,5]     [,6]     [,7]     [,8]
1 3.608429 5.280036 5.180036 4.372714 4.272893 5.084571 5.227429 5.870571
2 4.426031 5.382906 3.026656 6.713531 6.201656 2.544812 3.751062 1.426625
3 5.480275 2.938100 1.368100 4.540275 1.973100 3.782900 1.382900 0.965750
      [,9]     [,10]    [,11]    [,12]    [,13]
1 3.856286 5.2851429 4.720571 5.991714 5.106000
2 1.757875 0.9967187 6.401625 6.038562 6.644812
3 2.820750 0.1112250 3.450750 0.442900 0.692900

Clustering vector:
  [1] 2 1 2 1 1 3 2 1 2 2 2 2 3 3 3 3 1 3 1 3 3 2 3 1 2 2 1 2 1 1 3 2 1 2 2 2 2
 [38] 3 3 3 3 1 3 1 3 2 2 3 3 3 2 3 3 3 1 2 3 1 3 1 3 3 2 1 1 2 3 3 3 1 2 3 2 1
 [75] 2 1 1 3 2 2 1 2 1 2 3 3 3 3 1 3 1 3 1 3 3 2 3 1 2 2

Within cluster sum of squares by cluster:
[1] 1949.076 1903.595 1605.654
 (between_SS / total_SS =  41.1 %)

Available components:

[1] "cluster"      "centers"      "totss"        "withinss"     "tot.withinss"
[6] "betweenss"    "size"         "iter"         "ifault"      
Loading required package: broom
Loading required package: ggplot2
Loading required package: ggfortify
K-means clustering with 3 clusters of sizes 28, 32, 40

Cluster means:
      [,1]     [,2]     [,3]     [,4]     [,5]     [,6]     [,7]     [,8]
1 3.608429 5.280036 5.180036 4.372714 4.272893 5.084571 5.227429 5.870571
2 4.426031 5.382906 3.026656 6.713531 6.201656 2.544812 3.751062 1.426625
3 5.480275 2.938100 1.368100 4.540275 1.973100 3.782900 1.382900 0.965750
      [,9]     [,10]    [,11]    [,12]    [,13]
1 3.856286 5.2851429 4.720571 5.991714 5.106000
2 1.757875 0.9967187 6.401625 6.038562 6.644812
3 2.820750 0.1112250 3.450750 0.442900 0.692900

Clustering vector:
  [1] 2 1 2 1 1 3 2 1 2 2 2 2 3 3 3 3 1 3 1 3 3 2 3 1 2 2 1 2 1 1 3 2 1 2 2 2 2
 [38] 3 3 3 3 1 3 1 3 2 2 3 3 3 2 3 3 3 1 2 3 1 3 1 3 3 2 1 1 2 3 3 3 1 2 3 2 1
 [75] 2 1 1 3 2 2 1 2 1 2 3 3 3 3 1 3 1 3 1 3 3 2 3 1 2 2

Within cluster sum of squares by cluster:
[1] 1949.076 1903.595 1605.654
 (between_SS / total_SS =  41.1 %)

Available components:

[1] "cluster"      "centers"      "totss"        "withinss"     "tot.withinss"
[6] "betweenss"    "size"         "iter"         "ifault"      

conjoint documentation built on May 1, 2019, 8:05 p.m.