| nestedMethods | R Documentation |
"nestedLogit" and Related ObjectsVarious methods for processing "nestedLogit" and related objects.
Most of these are the standard methods for a model-fitting function.
coef, vcovReturn the coefficients and their variance-covariance matrix respectively.
updateRe-fit a "nestedLogit" model with a change in any of the formula, dichotomies,
data, subset, or contrasts, arguments.
predict, fittedComputes predicted values from a fitted "nestedLogit" model.
confintCompute point-wise confidence limits for predicted response-category probabilities or logits.
glanceConstruct a single row summaries for the dichotomies "nestedLogit" model.
tidySummarizes the terms in "nestedLogit" model.
## 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, ...)
x, object |
in most cases, an object of class |
... |
arguments to be passed down. |
newdata |
For the |
model |
For the |
n |
For the print method of |
parm |
For the |
level |
Confidence level for the |
conf.limits.logit |
When |
as.matrix |
if |
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. |
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.
The coef and vcov methods return either matrices or lists of regression
coefficients and their covariances, respectively.
The update method returns an object of class "nestedLogit" (see nestedLogit)
derived from the original nested-logit model.
The predict and fitted methods return an object of class "predictNested"
or "predictDichotomies", which contain the predicted probabilities, predicted logits,
and other information, such as standard errors of predicted values, and, if supplied,
the newdata on which predictions are based.
The summary method returns an object of class "summary.nestedLogit", which is
a list of summaries of the glm objects that comprise the nested-dichotomies model; the
object is normally printed.
The methods for as.matrix, as.character, and as.dichotomies coerce
various objects to matrices, character vectors, and dichotomies objects.
The various print methods invisibly return their x arguments.
John Fox and Michael Friendly
nestedLogit, plot.nestedLogit,
glance.nestedLogit, tidy.nestedLogit
# 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
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.