hturner / PlackettLuce

PlackettLuce package for Plackett-Luce models in R
https://hturner.github.io/PlackettLuce/
18 stars 5 forks source link

Predict model with weights #25

Closed kauedesousa closed 6 years ago

kauedesousa commented 6 years ago

library(PlackettLuce)

example("beans", package = "PlackettLuce") G <- grouped_rankings(R, rep(seq_len(nrow(beans)), 4))

weights <- c(rep(0.3, 400), rep(1, 442))

tree <- pltree(G ~ maxTN, data = beans, alpha = 0.05, weights = weights )

plot(tree) #does not work

predict(tree, newdata = beans)

predict fails when model is made with weights and type is "itempar". Works with the other options.

hturner commented 6 years ago

Thanks for the report. The failure comes in computing the variance-covariance matrix, so for now it may be sufficient to use

predict(tree, newdata = beans, vcov = FALSE)

and similarly

itempar(tree, vcov = FALSE)

Unfortunately this isn't a workaround for plot as this doesn't pass on the vcov argument. I will look into why the vcov part isn't working for a proper fix.