nestedMethods {nestedLogit}R Documentation

Methods for "nestedLogit" and Related Objects

Description

Various methods for processing "nestedLogit" and related objects. Most of these are the standard methods for a model-fitting function.

coef, vcov

Return the coefficients and their variance-covariance matrix respectively.

update

Re-fit a "nestedLogit" model with a change in any of the formula, dichotomies, data, subset, or contrasts, arguments.

predict, fitted

Computes predicted values from a fitted "nestedLogit" model.

confint

Compute point-wise confidence limits for predicted response-category probabilities or logits.

glance

Construct a single row summaries for the dichotomies "nestedLogit" model.

tidy

Summarizes the terms in "nestedLogit" model.

Usage

## S3 method for class 'nestedLogit'
print(x, ...)

## S3 method for class 'nestedLogit'
summary(object, ...)

## S3 method for class 'summary.nestedLogit'
print(x, ...)

## S3 method for class 'dichotomies'
print(x, ...)

## S3 method for class 'nestedLogit'
predict(object, newdata, model = c("nested", "dichotomies"), ...)

## S3 method for class 'predictNestedLogit'
print(x, n = min(10L, nrow(x$p)), ...)

## S3 method for class 'predictNestedLogit'
confint(
  object,
  parm = c("prob", "logit"),
  level = 0.95,
  conf.limits.logit = TRUE,
  ...
)

## S3 method for class 'predictDichotomies'
print(x, n = 10L, ...)

## S3 method for class 'nestedLogit'
fitted(object, model = c("nested", "dichotomies"), ...)

## S3 method for class 'nestedLogit'
coef(object, as.matrix = TRUE, ...)

## S3 method for class 'nestedLogit'
vcov(object, as.matrix = FALSE, ...)

## S3 method for class 'nestedLogit'
update(object, formula, dichotomies, data, subset, contrasts, ...)

## S3 method for class 'dichotomies'
as.matrix(x, ...)

## S3 method for class 'dichotomies'
as.character(x, ...)

## S3 method for class 'continuationDichotomies'
as.matrix(x, ...)

as.dichotomies(x, ...)

## S3 method for class 'matrix'
as.dichotomies(x, ...)

Arguments

x, object

in most cases, an object of class "nestedLogit".

...

arguments to be passed down.

newdata

For the predict method, a data frame containing combinations of values of the predictors at which fitted probabilities (or other quantities) are to be computed.

model

For the predict and fitted methods, either "nested" (the default), in which case fitted probabilities under the nested logit model are returned, or "dichotomies", in which case predict.glm is invoked for each binary logit model fit to the nested dichotomies and a named list of the results is returned.

n

For the print method of predict.nestedLogit or predictDichotomies, an integer or "all" to control how many rows are printed for each of the probabilities of response categories, corresponding logits and their standard errors.

parm

For the confint method, one of "prob" or "logit", indicating whether to generate confidence intervals for probabilities or logits of the responses.

level

Confidence level for the confint method

conf.limits.logit

When parm = "prob" ?????

as.matrix

if TRUE (the default for coef) return coefficients as a matrix with one column for each nested dichotomy, or coefficient covariances as a matrix with one row and column for each combination of dichotomies and coefficients; if FALSE (the default for vcov), return a list of coefficients or coefficient covariances with one element for each dichotomy.

formula

optional updated model formula.

dichotomies

optional updated dichotomies object.

data

optional updated data argument

subset

optional updated subset argument.

contrasts

optional updated contrasts argument.

Details

The predict method provides predicted values for two representations of the model. model = "nested" gives the fitted probabilities for each of the response categories. model = "dichotomies" gives the fitted log odds for each binary logit models in the dichotomies.

Value

Author(s)

John Fox and Michael Friendly

See Also

nestedLogit, plot.nestedLogit, glance.nestedLogit, tidy.nestedLogit

Examples

# define continuation dichotomies for level of education
cont.dichots <- continuationLogits(c("l.t.highschool",
                                     "highschool",
                                     "college",
                                     "graduate"))

# Show dichotomies in various forms
print(cont.dichots)
as.matrix(cont.dichots)
as.character(cont.dichots)

# fit a nested model for the GSS data examining education degree in relation to parent & year
m <- nestedLogit(degree ~ parentdeg + year,
                 cont.dichots,
                 data=GSS)

coef(m)                             # coefficient estimates
sqrt(diag(vcov(m, as.matrix=TRUE))) # standard errors
print(m)
summary(m)

# broom methods
broom::glance(m)
broom::tidy(m)

# predicted probabilities and ploting
predict(m) # fitted probabilities for first few cases;

new <- expand.grid(parentdeg=c("l.t.highschool",  "highschool",
                               "college", "graduate"),
                   year=c(1972, 2016))
fit <- predict(m, newdata=new)
cbind(new, fit) # fitted probabilities at specific values of predictors

# predicted logits for dichotomies
predictions <- predict(m, newdata=new, model="dichotomies")
predictions


[Package nestedLogit version 0.3.2 Index]