Closed kauedesousa closed 5 years ago
As far as I can see the printed output from pltree
has not changed - it only shows the negative log-likelihood of the rankings under the tree model (at the terminal nodes).
The null log-likelihood is the likelihood under the model where all choices are equally likely, i.e. where all items have the same worth. So there is no tree in this case.
One option is to fit the standard PlackettLuce model and extract the null log-likelihood from there:
pl0 <- PlackettLuce(G)
pl0$null.loglik
pl0$df.null
Alternatively, you can extract it from the model at the root of the PlackettLuce tree:
library(partykit)
node_party(pl)$info$object$null.loglik
node_party(pl)$info$object$df.null
which will give the same result.
I just realised another possibility is that the print method from partykit has changed, since the print method for "pltree"
objects calls partykit::print.modelparty
. In which case possibly the null likelihood could be defined as the likelihood with no tree, i.e. the likelihood of the model at the root node.
In this case, the answer can be obtained in a similar way, but you can use the logLik
function:
library(partykit)
logLik(node_party(pl)$info$object)
Hopefully one of those is what you are after!
Both
pl0$null.loglik
and
node_party(pl)$info$object$null.loglik
is what I wanted.
thank you!
I recall that version 0.2-4 used to show the logLikNull from a
pltree
object in its print method. However I cannot see it now. Can you show me how to get it from a pltree in v0.2-6?