1

I have a set of data with a set of preference rankings for different items for each participant. A subset of the data sample is included below:

Participant <- c("P1", "P2", "P3", "P4", "P5", "P6", "P7")  
I1 <- c(1.818,2.2727,3.2727,2.4545,2.3636,2.6364,2.7272)
I2 <- c(2.6364,2.8182,3.4545,3.0909,3.3636,2.8182,2.6364)
I3 <- c(3.9191,3.8182,3.6364,2.3636,3.0909,3.8182,3.7273)
I4 <- c(2.7273,2.3636,3.3636,2.4545,1.6364,1.1818,3.3636)
Exp1data <- data.frame(Participant, I1, I2, I3, I4)

The actual data set has 20 participants and preference rankings for 12 items. I tried to use mdpref from the 'pmr' package to analyze the data using this script:

mdpref(Exp1data, rank.vector=TRUE, ndim=2)

I get the following error

Error in `[<-`(`*tmp*`, temp, (nitem + 1 + j), value = 0.164634668997455) : subscript out of bounds

and the graph doesn't look right - I'm not sure if that's linked to the same issue as the error or separate. Can anyone explain the error and how I can fix it? I'm also wondering if I've set the data up right in order to run the mdpref.

Thanks!

Chelsea
  • 11
  • 3
  • Well, I'm guessing that you want to treat I1-I4 as numeric values and you seem to have them coded as characters/factors. It also seems odd to include the individual ID in the analysis but i have no idea where your `mdpref` function is coming from. When using non-base functions, you should be explicit about packages you are using. – MrFlick Feb 25 '15 at 20:37
  • That's my mistake, I imported the data from a .csv file, so the values should be number, but I thought I'd provide the code - I shouldn't have put the numbers in quotations. Also the mdpref function is from the 'pmr' package - I've updated the question. – Chelsea Feb 26 '15 at 02:46
  • The documentation for that function seems pretty poor, but the code clearly expects the last column of the data.frame to have counts. It refers to the structure as a "ranking" dataset. Your sample data doesn't look like the sample data in any of the examples of the package. The rows should represent a an observed permutation of rankings 1:n. – MrFlick Feb 26 '15 at 03:12
  • That makes sense - the numbers I had were the average score for each item, I just translated those into a ranking. But I'm not sure what to put in the last column for the counts - the example shows n <- c(6,5,4,3,2,1) But I'm not sure what those are counts of – Chelsea Feb 26 '15 at 19:41
  • Those are counts of rankings. So if you have three items, and one person ranked them 2,3,1, then that would be one row in the data.frame. The last column would be the total number of people that assigned 2 to the first item, three to the second and 1 to the first. It's not necessary to have aggregated data; the `rankagg()` function can aggregate it for you if you only have the three-column rankings. – MrFlick Feb 26 '15 at 19:45
  • My data actually has 12 items, so the rankings go from 1-12. Sorry - I'm still a little confused about the counts. So the last column would be a number for each row that states how many other people ranked all 12 items the same as the individual in that row? – Chelsea Feb 26 '15 at 20:11
  • Yes. So rather than having a row for each individual, you would have a row for each ranking permutation and the last column is the number of individuals that ranked the 12 items that way. That's the difference between the individual data and the aggregated data. – MrFlick Feb 26 '15 at 20:13

0 Answers0