as.data.frame.predictNestedLogit {nestedLogit}R Documentation

Convert a Predicted Objects to a data.frame

Description

These functions provide simple ways to convert the results of predict.nestedLogit to a data frame in a consistent format for plotting and other actions.

Usage

## S3 method for class 'predictNestedLogit'
as.data.frame(x, row.names = NULL, optional = FALSE, ...)

Arguments

x

a "predictNestedLogit" object

row.names

row.names for result (for conformity with generic; not currently used)

optional

logical. If TRUE, setting row names and converting column names (to syntactic names: see make.names is optional

...

other arguments (unused)

Value

Examples

data("Womenlf", package = "carData")
comparisons <- logits(work=dichotomy("not.work", c("parttime", "fulltime")),
                     full=dichotomy("parttime", "fulltime"))

wlf.nested <- nestedLogit(partic ~ hincome + children,
                          dichotomies = comparisons,
                          data=Womenlf)
# get predicted values for a grid of `hincome` and `children`
new <- expand.grid(hincome=seq(0, 45, length=10),
                   children=c("absent", "present"))

pred.nested <- predict(wlf.nested, new)
plotdata <- as.data.frame(pred.nested)
str(plotdata)

# Predicted logit values for the dichotomies
pred.dichot <- predict(wlf.nested, new, model = "dichotomies")
plotlogit <- as.data.frame(pred.dichot)
str(plotlogit)

[Package nestedLogit version 0.3.2 Index]