Closed Kishor-Kayyar closed 2 years ago
I can't see any issue here. The only thing is that PlackettLuce()
removes line 10 as it has only one element in the ranking.
library("PlackettLuce")
R <- matrix(c(1,2,3,4,5,
1,2,3,5,4,
1,2,4,3,5,
1,2,5,3,4,
1,3,2,4,5,
3,1,2,5,4,
0,2,1,4,5,
2,4,3,1,5,
0,0,0,1,5,
0,0,0,0,1), nrow = 10, ncol = 5, byrow = TRUE)
mod <- PlackettLuce(R)
summary(mod)
I can't see any issue here. The only thing is that
PlackettLuce()
removes line 10 as it has only one element in the ranking.library("PlackettLuce") R <- matrix(c(1,2,3,4,5, 1,2,3,5,4, 1,2,4,3,5, 1,2,5,3,4, 1,3,2,4,5, 3,1,2,5,4, 0,2,1,4,5, 2,4,3,1,5, 0,0,0,1,5, 0,0,0,0,1), nrow = 10, ncol = 5, byrow = TRUE) mod <- PlackettLuce(R) summary(mod)
You did not use the freq I gave with the issue. Once I use the freq of ranks summary fails to run
I am not sure what you mean with the "freq I gave". Please send a reproducible example so I test it here. To do that, write the code in R and put it here in the chat wrapped by three backticks (```) in the top and another three at the end of your code https://www.markdownguide.org/extended-syntax/#fenced-code-blocks
Also when I run sessioninfo::session_info()
I get this info.
─ Session info 👮🏽♀️ 📟 🐡 ───────────────────────────────────────────────────────────────────────────────────
hash: woman police officer: medium skin tone, pager, blowfish
setting value
version R version 4.1.0 (2021-05-18)
os macOS 12.1
system x86_64, darwin17.0
ui RStudio
language (EN)
collate en_US.UTF-8
ctype en_US.UTF-8
date 2022-01-31
rstudio 1.4.1716 Juliet Rose (desktop)
pandoc 2.9.1.1 @ /usr/local/bin/pandoc
─ Packages ─────────────────────────────────────────────────────────────────────────────────────────────────────
package * version date (UTC) lib source
partykit 1.2-15 2021-08-23 [1] CRAN (R 4.1.0)
pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.1.0)
PlackettLuce * 0.4.1 2021-08-16 [1] CRAN (R 4.1.0)
Sorry for incomplete report. I am new to R. Please find the complete code below:
library(PlackettLuce)
rank_list <- matrix(c(1,2,3,4,5,
1,2,3,5,4,
1,2,4,3,5,
1,2,5,3,4,
1,3,2,4,5,
2,3,1,5,4,
3,2,2,4,5,
4,1,2,3,5,
4,4,4,4,5,
5,5,5,5,5), nrow = 10, ncol = 5, byrow = TRUE)
freq <- c(10, 1, 3, 2, 2, 1, 2, 1, 1, 1)
R <- as.rankings(rank_list, input = "orderings")
print(R[as.rankings = FALSE])
mod <- PlackettLuce(R, weights = freq)
coef(mod, log = F)
print(summary(mod))
The cholmod error disappears if I remove the line 3, 2, 2, 4, 5
My #sessioninfo::session_info() is
> sessioninfo::session_info()
- Session info ------------------------------------------------------------------------
setting value
version R version 4.1.2 (2021-11-01)
os Windows 10 x64 (build 18363)
system x86_64, mingw32
ui RStudio
language (EN)
collate English_United States.1252
ctype English_United States.1252
tz Europe/Berlin
date 2022-01-31
rstudio 2021.09.2+382 Ghost Orchid (desktop)
pandoc NA
- Packages ----------------------------------------------------------------------------
PlackettLuce * 0.4.1 2021-08-16 [1] CRAN (R 4.1.2)
I am reusing a prev installation of R and it has a lot of other packages installed.
I get the same error. But this is due to two sources of error. If understand well your rankings, you should use the argument input = "rankings"
instead of input = "ordering"
in the function as.rankings()
. Actually you don't need the function as PlackettLuce()
handles well these kind of matrix (where lines are the observations and columns the rankings). The other issue is that in line num 10 you have all values as a tie. You should remove that. Here an updated version of your code
library(PlackettLuce)
R <- matrix(c(1,2,3,4,5,
1,2,3,5,4,
1,2,4,3,5,
1,2,5,3,4,
1,3,2,4,5,
2,3,1,5,4,
3,2,2,4,5,
4,1,2,3,5,
4,4,4,4,5,
5,5,5,5,5), nrow = 10, ncol = 5, byrow = TRUE)
freq <- c(10, 1, 3, 2, 2, 1, 2, 1, 1, 1)
#R <- as.rankings(R, input = "rankings")
#print(R[as.rankings = FALSE])
R <- R[-10, ]
freq <- freq[-10]
mod <- PlackettLuce(R, weights = freq)
summary(mod)
coef(mod, log = F)
Perfect. This solves my issue.
Thanks a ton! Kishor
I tried to run PlackettLuce with the following rankings: [1,] 1 2 3 4 5 [2,] 1 2 3 5 4 [3,] 1 2 4 3 5 [4,] 1 2 5 3 4 [5,] 1 3 2 4 5 [6,] 3 1 2 5 4 [7,] 0 2 1 4 5 [8,] 2 4 3 1 5 [9,] 0 0 0 1 5 [10,] 0 0 0 0 1 With the freq being [1] 10 1 3 2 2 1 2 1 1 1
I get the following error, when I try to summarize the results:
print(summary(mod)) *Error in X %% as.vector(coefs) : Cholmod error 'X and/or Y have wrong dimensions' at file ../MatrixOps/cholmod_sdmult.c, line 88**
If I remove line [7, ] 0 2 1 4 5, then I get the proper summary.
Do you have any suggestions on how to solve this? It seems some ties (like the one in line 9 and 10) work whereas some others do not.
Thanks for the nice package, Kishor