tzuliu / ooc

This is a repository for the project of "Ordered Optimal Classification"
MIT License
8 stars 2 forks source link

Error in votemat.dominance.binary[, j] : subscript out of bounds #6

Open MartinsRodrigo opened 3 days ago

MartinsRodrigo commented 3 days ago

Hi, I hope you’re doing well.

I’m trying to use the package, but I’m running into an error that I can’t seem to resolve. It’s strange because I was able to run it successfully with the same data a while ago (as far as I remember).

I’ve attached the data. session.zip

library(ooc)

ooc.result <- ooc(votes_matrix, 
                  dims = 2,
                  polarity = c(1,1))

Preparing to run Optimal Classification...

Checking data...

  All members meet minimum vote requirements.

  Votes dropped:
  ... 10 of 231 total votes dropped.

Running Optimal Classification...

  Generating Start Coordinates...
  Running Edith Algorithm...
  Getting normal vectors...
  Getting legislator coordinates...
  Getting normal vectors...
  Getting legislator coordinates...
  Getting normal vectors...
  Getting legislator coordinates...
  Getting normal vectors...
  Getting legislator coordinates...
  Getting normal vectors...
  Getting legislator coordinates...
  Getting normal vectors...
  Getting legislator coordinates...
  Getting normal vectors...
  Getting legislator coordinates...
  Getting normal vectors...
  Getting legislator coordinates...
  Getting normal vectors...
  Getting legislator coordinates...
  Getting normal vectors...
  Getting legislator coordinates...

Optimal Classification completed successfully. Optimal Classification took 1.29 seconds to execute.

Running Ordered Optimal Classification...

  Getting respondent coordinates...
  Calculating normal vectors...
  Getting respondent coordinates...
  Calculating normal vectors...
  Getting respondent coordinates...
  Calculating normal vectors...
  Getting respondent coordinates...
  Calculating normal vectors...
  Getting respondent coordinates...
  Calculating normal vectors...
  Getting respondent coordinates...
  Calculating normal vectors...
  Getting respondent coordinates...
  Calculating normal vectors...
  Getting respondent coordinates...
  Calculating normal vectors...
  Getting respondent coordinates...
  Calculating normal vectors...
  Getting respondent coordinates...
  Calculating normal vectors...
  Getting respondent coordinates...
  Calculating normal vectors...
  Getting respondent coordinates...
  Calculating normal vectors...
  Getting respondent coordinates...
  Calculating normal vectors...
  Getting respondent coordinates...
  Calculating normal vectors...
  Getting respondent coordinates...
  Calculating normal vectors...
  Getting respondent coordinates...
  Calculating normal vectors...
  Getting respondent coordinates...
  Calculating normal vectors...
  Getting respondent coordinates...
  Calculating normal vectors...
  Getting respondent coordinates...
  Calculating normal vectors...
  Getting respondent coordinates...
  Calculating normal vectors...
  Getting respondent coordinates...
  Calculating normal vectors...
  Getting respondent coordinates...
  Calculating normal vectors...
  Getting respondent coordinates...
  Calculating normal vectors...
  Getting respondent coordinates...
  Calculating normal vectors...
  Getting respondent coordinates...
  Calculating normal vectors...

Error in votemat.dominance.binary[, j] : subscript out of bounds

It seems that the error occurs in the loop that starts with for (j in 1:(sum(ncat) - nvotes)).

I apologize if this is a silly mistake, but I’ve tried various things and haven’t had any success.

Thank you very much for your attention.

christopherdanielhare commented 3 days ago

I suspect the problem is that there are empty categories for some of the votes. For example, the 15th column of the vote matrix includes responses for 1, 2, and 4, but not 3:

`> table(votes[,15])

1 2 4 3 5 40 `

In this case, 4 will need to be recoded as a 3.