pltree-summaries {PlackettLuce} | R Documentation |
Plackett-Luce Tree Summaries
Description
Obtain the coefficients, variance-covariance matrix, AIC, or predictions
from a Plackett-Luce tree fitted by pltree()
.
Usage
## S3 method for class 'pltree'
coef(object, node = NULL, drop = TRUE, ...)
## S3 method for class 'pltree'
vcov(object, node = nodeids(object, terminal = TRUE), ...)
## S3 method for class 'pltree'
AIC(object, newdata = NULL, ...)
## S3 method for class 'pltree'
predict(
object,
newdata = NULL,
type = c("itempar", "rank", "best", "node"),
...
)
Arguments
object |
a fitted model object of class |
node |
a vector of node ids specifying the nodes to summarise, by default the ids of the terminal nodes. |
drop |
if |
... |
additional arguments passed to
|
newdata |
an optional data frame to use instead of the
original data. For |
type |
the type of prediction to return for each group, one of:
|
Details
AIC
computes -2L + 2p
where L
is the
joint likelihood of the observed rankings under the tree model and
p
is the degrees of freedom used to fit the tree model.
Examples
data(beans)
# fit tree based on pairwise comparisons with variety B
pairB <- data.frame(Winner = ifelse(beans$var_b == "Worse",
"Local", beans$variety_b),
Loser = ifelse(beans$var_b == "Worse",
beans$variety_b, "Local"),
stringsAsFactors = FALSE, row.names = NULL)
beans$G <- as.rankings(pairB, input = "orderings",
index = rep(seq(nrow(beans)), 1))
mod <- pltree(G ~ ., data = beans[c("G", "maxTN")])
coef(mod, node = 3)
AIC(mod)
# treat first row from each year as new data
newdata <- beans[!duplicated(beans$year),]
## fitted probabilities
predict(mod, newdata)
## fitted log-abilities, with Local as reference
predict(mod, newdata, log = TRUE, ref = "Local")
## variety ranks
predict(mod, newdata, type = "rank")
## top ranked variety
predict(mod, newdata, type = "best")
## node the trial belongs to
predict(mod, newdata, type = "node")