cats2ranks: Ordered option selections to ranks

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

Description

Convert ordered option selections to ranks, assigning the mean of unused ranks to unselected options.

Usage

1
 cats2ranks(x,cats=NULL)

Arguments

x

A matrix or data frame of numeric or characters labels for options. Rows are interpreted as cases or respondents and columns are interpreted as the order of option selections, beginning with the highest ranking (usually something like "Most important") and descending.

cats

The range of numbers that represent options. The default is the vector of unique entries in x.

Details

cats2ranks converts ordered option selections to mean ranks. It is useful in the situation where a respondent is asked to select one of a number of options as the most important, another as the second most important, and so on. It counts the number of times each option code appears in each column and calculates the mean ranking of options. It is expected that there will be fewer selections available than there are options, thus creating the opportunity for biased rankings. This can occur when one or more options are not commonly chosen, but are given extreme (usually high) ranks when they are. The function calculates the mean of unallocated ranks and assigns this to all options not chosen by each respondent, correcting for this bias. The correction assumes that the respondent does not differentiate between unranked options, but these are all ranked lower than the options selected.

cats2ranks is especially useful when respondents do not select the same number of options. The mean of unallocated ranks is calculated for each respondent so that all options are entered into the calculation of mean ranks.

Note that cats2ranks interprets each value in x as a nominal level variable and its column index as the rank, while meanranks interprets values as ordinal level (ranks). Thus if a matrix or data frame of ranks is passed to cats2ranks, it will not give the correct mean ranks or relative positions.

Value

A list with four components:

ranks

The matrix of completed ranks.

cats

The vector of options as passed or calculated.

ranksum

The sum of ranks for each option.

rankcount

The number of times each option was selected.

Author(s)

Jim Lemon

See Also

muranks,meanranks

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
 # first a standard 1:m numerically coded selection
 opchoice<-matrix(NA,nrow=40,ncol=5)
 for(i in 1:40) opchoice[i,]<-sample(1:10,5)
 opchoice
 cats2ranks(opchoice)
 # now a messy character choice with missing values
 opchoice<-matrix(NA,nrow=40,ncol=5)
 tencolors<-c("red","green","blue","yellow","magenta","cyan",
  "purple","orange","brown","pink")
 for(i in 1:40) {
  nchoices<-sample(3:5,1)
  opchoice[i,1:nchoices]<-sample(tencolors,nchoices)
 }
 opchoice
 cats2ranks(opchoice)

Example output

      [,1] [,2] [,3] [,4] [,5]
 [1,]    3    2    5    7   10
 [2,]    4    1    8    6   10
 [3,]    6    2    5   10    4
 [4,]    9    1    7   10    4
 [5,]    8    1   10    4    6
 [6,]    9    1    4    2    8
 [7,]    3    9    4    1    7
 [8,]    5    2   10    4    7
 [9,]   10    4    8    9    7
[10,]    7    9    8    4    3
[11,]    1    6    7   10    8
[12,]    6   10    2    1    3
[13,]   10    3    9    8    2
[14,]    5    2    6    8    4
[15,]    7    4    1    2    8
[16,]    1   10    3    8    5
[17,]    7   10    9    2    3
[18,]    3   10    9    4    8
[19,]    7    3    4   10    8
[20,]    5    6   10    8    3
[21,]    2   10    5    4    3
[22,]    7    4    9   10    6
[23,]    6    9    7    4    8
[24,]    1    8    3    4    6
[25,]   10    8    4    1    5
[26,]    4    9   10    1    5
[27,]    2    4    1    7    9
[28,]   10    4    2    9    8
[29,]    8    6    5    2    7
[30,]    5    3    8    1   10
[31,]   10    3    7    5    8
[32,]    7    1   10    9    3
[33,]    4    3    6    7    1
[34,]    9    5    1    3    7
[35,]    2   10    6    4    7
[36,]    8    7    6    9   10
[37,]    6    1    5    7    9
[38,]    9    4    1    6    5
[39,]    3   10    2    4    1
[40,]    2   10    8    3    6

   Mean rank	N
10	4.5	27
4	4.95	25
1	5.42	20
7	5.45	21
8	5.55	22
3	5.65	19
9	5.65	18
2	5.85	16
6	5.85	17
5	6.12	15
      [,1]      [,2]      [,3]      [,4]     [,5]     
 [1,] "blue"    "pink"    "red"     "cyan"   "magenta"
 [2,] "red"     "blue"    "pink"    "purple" "green"  
 [3,] "green"   "brown"   "red"     "yellow" "pink"   
 [4,] "purple"  "yellow"  "brown"   "pink"   NA       
 [5,] "red"     "purple"  "brown"   "orange" NA       
 [6,] "blue"    "orange"  "green"   "brown"  "red"    
 [7,] "red"     "cyan"    "pink"    "purple" "magenta"
 [8,] "brown"   "orange"  "purple"  NA       NA       
 [9,] "blue"    "purple"  "yellow"  NA       NA       
[10,] "pink"    "green"   "purple"  NA       NA       
[11,] "brown"   "pink"    "purple"  "green"  "red"    
[12,] "magenta" "green"   "pink"    "yellow" "purple" 
[13,] "orange"  "cyan"    "green"   "pink"   "blue"   
[14,] "pink"    "brown"   "purple"  "cyan"   NA       
[15,] "green"   "orange"  "blue"    "purple" "brown"  
[16,] "yellow"  "blue"    "pink"    NA       NA       
[17,] "magenta" "green"   "yellow"  "orange" NA       
[18,] "purple"  "brown"   "orange"  "red"    NA       
[19,] "green"   "orange"  "pink"    "cyan"   "brown"  
[20,] "green"   "yellow"  "orange"  "cyan"   NA       
[21,] "yellow"  "purple"  "red"     "green"  "pink"   
[22,] "yellow"  "pink"    "magenta" NA       NA       
[23,] "brown"   "cyan"    "yellow"  "green"  NA       
[24,] "green"   "brown"   "red"     "pink"   NA       
[25,] "magenta" "pink"    "orange"  NA       NA       
[26,] "cyan"    "purple"  "magenta" "orange" "pink"   
[27,] "magenta" "orange"  "yellow"  NA       NA       
[28,] "orange"  "cyan"    "green"   "yellow" NA       
[29,] "green"   "pink"    "blue"    NA       NA       
[30,] "blue"    "cyan"    "brown"   "green"  NA       
[31,] "orange"  "brown"   "cyan"    NA       NA       
[32,] "blue"    "red"     "cyan"    "green"  "pink"   
[33,] "blue"    "magenta" "green"   "red"    "yellow" 
[34,] "brown"   "magenta" "pink"    "cyan"   "red"    
[35,] "red"     "orange"  "green"   "pink"   NA       
[36,] "yellow"  "blue"    "pink"    NA       NA       
[37,] "brown"   "pink"    "green"   NA       NA       
[38,] "brown"   "red"     "orange"  "pink"   "yellow" 
[39,] "yellow"  "cyan"    "red"     "purple" "magenta"
[40,] "orange"  "magenta" "green"   NA       NA       

   Mean rank	N
green	4.8	22
pink	4.86	24
brown	5.3	17
orange	5.36	17
red	5.56	16
yellow	5.62	16
purple	5.76	15
cyan	5.83	14
blue	5.85	12
magenta	6.05	12

crank documentation built on May 1, 2019, 9:39 p.m.

Related to cats2ranks in crank...