PlackettLuce (version 0.2-9)

pltree-summaries: 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 pltree
coef(object, node = NULL, drop = TRUE, ...)

# S3 method for pltree vcov(object, node = nodeids(object, terminal = TRUE), ...)

# S3 method for pltree AIC(object, newdata = NULL, ...)

# S3 method for pltree predict(object, newdata = NULL, type = c("itempar", "rank", "best", "node"), ...)

Arguments

object

a fitted model object of class "pltree".

node

a vector of node ids specifying the nodes to summarise, by default the ids of the terminal nodes.

drop

if TRUE return the coefficients as a vector when only one node is selected.

...

additional arguments passed to itempar by predict, and to model.frame by AIC.

newdata

an optional data frame to use instead of the original data. For AIC this must include the response variable.

type

the type of prediction to return for each group, one of: "itempar" to give the result of itempar (by default the fitted probability of each item being ranked first out of all objects), "rank" the corresponding rank, "best" the topped ranked item, or "node" the node of the tree the group belongs to.

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

Run this code
# NOT RUN {
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")
# }

Run the code above in your browser using DataCamp Workspace