Title: | Convert Statistical Objects into Tidy Tibbles |
---|---|
Description: | Summarizes key information about statistical objects in tidy tibbles. This makes it easy to report results, create plots and consistently work with large numbers of models at once. Broom provides three verbs that each provide different types of information about a model. tidy() summarizes information about model components such as coefficients of a regression. glance() reports information about an entire model, such as goodness of fit measures like AIC and BIC. augment() adds information about individual observations to a dataset, such as fitted values or influence measures. |
Authors: | David Robinson [aut], Alex Hayes [aut] , Simon Couch [aut, cre] , Posit Software, PBC [cph, fnd], Indrajeet Patil [ctb] , Derek Chiu [ctb], Matthieu Gomez [ctb], Boris Demeshev [ctb], Dieter Menne [ctb], Benjamin Nutter [ctb], Luke Johnston [ctb], Ben Bolker [ctb], Francois Briatte [ctb], Jeffrey Arnold [ctb], Jonah Gabry [ctb], Luciano Selzer [ctb], Gavin Simpson [ctb], Jens Preussner [ctb], Jay Hesselberth [ctb], Hadley Wickham [ctb], Matthew Lincoln [ctb], Alessandro Gasparini [ctb], Lukasz Komsta [ctb], Frederick Novometsky [ctb], Wilson Freitas [ctb], Michelle Evans [ctb], Jason Cory Brunson [ctb], Simon Jackson [ctb], Ben Whalley [ctb], Karissa Whiting [ctb], Yves Rosseel [ctb], Michael Kuehn [ctb], Jorge Cimentada [ctb], Erle Holgersen [ctb], Karl Dunkle Werner [ctb] , Ethan Christensen [ctb], Steven Pav [ctb], Paul PJ [ctb], Ben Schneider [ctb], Patrick Kennedy [ctb], Lily Medina [ctb], Brian Fannin [ctb], Jason Muhlenkamp [ctb], Matt Lehman [ctb], Bill Denney [ctb] , Nic Crane [ctb], Andrew Bates [ctb], Vincent Arel-Bundock [ctb] , Hideaki Hayashi [ctb], Luis Tobalina [ctb], Annie Wang [ctb], Wei Yang Tham [ctb], Clara Wang [ctb], Abby Smith [ctb] , Jasper Cooper [ctb] , E Auden Krauska [ctb] , Alex Wang [ctb], Malcolm Barrett [ctb] , Charles Gray [ctb] , Jared Wilber [ctb], Vilmantas Gegzna [ctb] , Eduard Szoecs [ctb], Frederik Aust [ctb] , Angus Moore [ctb], Nick Williams [ctb], Marius Barth [ctb] , Bruna Wundervald [ctb] , Joyce Cahoon [ctb] , Grant McDermott [ctb] , Kevin Zarca [ctb], Shiro Kuriwaki [ctb] , Lukas Wallrich [ctb] , James Martherus [ctb] , Chuliang Xiao [ctb] , Joseph Larmarange [ctb], Max Kuhn [ctb], Michal Bojanowski [ctb], Hakon Malmedal [ctb], Clara Wang [ctb], Sergio Oller [ctb], Luke Sonnet [ctb], Jim Hester [ctb], Ben Schneider [ctb], Bernie Gray [ctb] , Mara Averick [ctb], Aaron Jacobs [ctb], Andreas Bender [ctb], Sven Templer [ctb], Paul-Christian Buerkner [ctb], Matthew Kay [ctb], Erwan Le Pennec [ctb], Johan Junkka [ctb], Hao Zhu [ctb], Benjamin Soltoff [ctb], Zoe Wilkinson Saldana [ctb], Tyler Littlefield [ctb], Charles T. Gray [ctb], Shabbh E. Banks [ctb], Serina Robinson [ctb], Roger Bivand [ctb], Riinu Ots [ctb], Nicholas Williams [ctb], Nina Jakobsen [ctb], Michael Weylandt [ctb], Lisa Lendway [ctb], Karl Hailperin [ctb], Josue Rodriguez [ctb], Jenny Bryan [ctb], Chris Jarvis [ctb], Greg Macfarlane [ctb], Brian Mannakee [ctb], Drew Tyre [ctb], Shreyas Singh [ctb], Laurens Geffert [ctb], Hong Ooi [ctb], Henrik Bengtsson [ctb], Eduard Szocs [ctb], David Hugh-Jones [ctb], Matthieu Stigler [ctb], Hugo Tavares [ctb] , R. Willem Vervoort [ctb], Brenton M. Wiernik [ctb], Josh Yamamoto [ctb], Jasme Lee [ctb], Taren Sanders [ctb] , Ilaria Prosdocimi [ctb] , Daniel D. Sjoberg [ctb] , Alex Reinhart [ctb] |
Maintainer: | Simon Couch <[email protected]> |
License: | MIT + file LICENSE |
Version: | 1.0.7.9000 |
Built: | 2024-11-07 21:23:33 UTC |
Source: | https://github.com/tidymodels/broom |
augment_columns
is intended for use in the internals of augment
methods
only and is exported for developers extending the broom package. Please
instead use augment()
to appropriately make use of the functionality
in augment_columns()
.
augment_columns( x, data, newdata = NULL, type, type.predict = type, type.residuals = type, se.fit = TRUE, ... )
augment_columns( x, data, newdata = NULL, type, type.predict = type, type.residuals = type, se.fit = TRUE, ... )
x |
a model |
data |
original data onto which columns should be added |
newdata |
new data to predict on, optional |
type |
Type of prediction and residuals to compute |
type.predict |
Type of prediction to compute; by default
same as |
type.residuals |
Type of residuals to compute; by default
same as |
se.fit |
Value to pass to predict's |
... |
extra arguments (not used) |
Note that, in the case that a residuals()
or influence()
generic is
not implemented for the supplied model x
, the function will fail quietly.
Augment accepts a model object and a dataset and adds
information about each observation in the dataset. Most commonly, this
includes predicted values in the .fitted
column, residuals in the
.resid
column, and standard errors for the fitted values in a .se.fit
column. New columns always begin with a .
prefix to avoid overwriting
columns in the original dataset.
Users may pass data to augment via either the data
argument or the
newdata
argument. If the user passes data to the data
argument,
it must be exactly the data that was used to fit the model
object. Pass datasets to newdata
to augment data that was not used
during model fitting. This still requires that at least all predictor
variable columns used to fit the model are present. If the original outcome
variable used to fit the model is not included in newdata
, then no
.resid
column will be included in the output.
Augment will often behave differently depending on whether data
or
newdata
is given. This is because there is often information
associated with training observations (such as influences or related)
measures that is not meaningfully defined for new observations.
For convenience, many augment methods provide default data
arguments,
so that augment(fit)
will return the augmented training data. In these
cases, augment tries to reconstruct the original data based on the model
object with varying degrees of success.
The augmented dataset is always returned as a tibble::tibble with the
same number of rows as the passed dataset. This means that the passed
data must be coercible to a tibble. If a predictor enters the model as part
of a matrix of covariates, such as when the model formula uses
splines::ns()
, stats::poly()
, or survival::Surv()
, it is represented
as a matrix column.
We are in the process of defining behaviors for models fit with various
na.action
arguments, but make no guarantees about behavior when data is
missing at this time.
## S3 method for class 'betamfx' augment( x, data = model.frame(x$fit), newdata = NULL, type.predict = c("response", "link", "precision", "variance", "quantile"), type.residuals = c("sweighted2", "deviance", "pearson", "response", "weighted", "sweighted"), ... )
## S3 method for class 'betamfx' augment( x, data = model.frame(x$fit), newdata = NULL, type.predict = c("response", "link", "precision", "variance", "quantile"), type.residuals = c("sweighted2", "deviance", "pearson", "response", "weighted", "sweighted"), ... )
x |
A |
data |
A base::data.frame or |
newdata |
A |
type.predict |
Character indicating type of prediction to use. Passed to
the |
type.residuals |
Character indicating type of residuals to use. Passed
to the |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
This augment method wraps augment.betareg()
for
mfx::betamfx()
objects.
A tibble::tibble()
with columns:
.cooksd |
Cooks distance. |
.fitted |
Fitted or predicted value. |
.resid |
The difference between observed and fitted values. |
augment.betareg()
, mfx::betamfx()
Other mfx tidiers:
augment.mfx()
,
glance.betamfx()
,
glance.mfx()
,
tidy.betamfx()
,
tidy.mfx()
library(mfx) # Simulate some data set.seed(12345) n <- 1000 x <- rnorm(n) # Beta outcome y <- rbeta(n, shape1 = plogis(1 + 0.5 * x), shape2 = (abs(0.2 * x))) # Use Smithson and Verkuilen correction y <- (y * (n - 1) + 0.5) / n d <- data.frame(y, x) mod_betamfx <- betamfx(y ~ x | x, data = d) tidy(mod_betamfx, conf.int = TRUE) # Compare with the naive model coefficients of the equivalent betareg call (not run) # tidy(betamfx(y ~ x | x, data = d), conf.int = TRUE) augment(mod_betamfx) glance(mod_betamfx)
library(mfx) # Simulate some data set.seed(12345) n <- 1000 x <- rnorm(n) # Beta outcome y <- rbeta(n, shape1 = plogis(1 + 0.5 * x), shape2 = (abs(0.2 * x))) # Use Smithson and Verkuilen correction y <- (y * (n - 1) + 0.5) / n d <- data.frame(y, x) mod_betamfx <- betamfx(y ~ x | x, data = d) tidy(mod_betamfx, conf.int = TRUE) # Compare with the naive model coefficients of the equivalent betareg call (not run) # tidy(betamfx(y ~ x | x, data = d), conf.int = TRUE) augment(mod_betamfx) glance(mod_betamfx)
Augment accepts a model object and a dataset and adds
information about each observation in the dataset. Most commonly, this
includes predicted values in the .fitted
column, residuals in the
.resid
column, and standard errors for the fitted values in a .se.fit
column. New columns always begin with a .
prefix to avoid overwriting
columns in the original dataset.
Users may pass data to augment via either the data
argument or the
newdata
argument. If the user passes data to the data
argument,
it must be exactly the data that was used to fit the model
object. Pass datasets to newdata
to augment data that was not used
during model fitting. This still requires that at least all predictor
variable columns used to fit the model are present. If the original outcome
variable used to fit the model is not included in newdata
, then no
.resid
column will be included in the output.
Augment will often behave differently depending on whether data
or
newdata
is given. This is because there is often information
associated with training observations (such as influences or related)
measures that is not meaningfully defined for new observations.
For convenience, many augment methods provide default data
arguments,
so that augment(fit)
will return the augmented training data. In these
cases, augment tries to reconstruct the original data based on the model
object with varying degrees of success.
The augmented dataset is always returned as a tibble::tibble with the
same number of rows as the passed dataset. This means that the passed
data must be coercible to a tibble. If a predictor enters the model as part
of a matrix of covariates, such as when the model formula uses
splines::ns()
, stats::poly()
, or survival::Surv()
, it is represented
as a matrix column.
We are in the process of defining behaviors for models fit with various
na.action
arguments, but make no guarantees about behavior when data is
missing at this time.
## S3 method for class 'betareg' augment( x, data = model.frame(x), newdata = NULL, type.predict, type.residuals, ... )
## S3 method for class 'betareg' augment( x, data = model.frame(x), newdata = NULL, type.predict, type.residuals, ... )
x |
A |
data |
A base::data.frame or |
newdata |
A |
type.predict |
Character indicating type of prediction to use. Passed
to the |
type.residuals |
Character indicating type of residuals to use. Passed
to the |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
For additional details on Cook's distance, see
stats::cooks.distance()
.
A tibble::tibble()
with columns:
.cooksd |
Cooks distance. |
.fitted |
Fitted or predicted value. |
.resid |
The difference between observed and fitted values. |
# load libraries for models and data library(betareg) # load dats data("GasolineYield", package = "betareg") # fit model mod <- betareg(yield ~ batch + temp, data = GasolineYield) mod # summarize model fit with tidiers tidy(mod) tidy(mod, conf.int = TRUE) tidy(mod, conf.int = TRUE, conf.level = .99) augment(mod) glance(mod)
# load libraries for models and data library(betareg) # load dats data("GasolineYield", package = "betareg") # fit model mod <- betareg(yield ~ batch + temp, data = GasolineYield) mod # summarize model fit with tidiers tidy(mod) tidy(mod, conf.int = TRUE) tidy(mod, conf.int = TRUE, conf.level = .99) augment(mod) glance(mod)
Augment accepts a model object and a dataset and adds
information about each observation in the dataset. Most commonly, this
includes predicted values in the .fitted
column, residuals in the
.resid
column, and standard errors for the fitted values in a .se.fit
column. New columns always begin with a .
prefix to avoid overwriting
columns in the original dataset.
Users may pass data to augment via either the data
argument or the
newdata
argument. If the user passes data to the data
argument,
it must be exactly the data that was used to fit the model
object. Pass datasets to newdata
to augment data that was not used
during model fitting. This still requires that at least all predictor
variable columns used to fit the model are present. If the original outcome
variable used to fit the model is not included in newdata
, then no
.resid
column will be included in the output.
Augment will often behave differently depending on whether data
or
newdata
is given. This is because there is often information
associated with training observations (such as influences or related)
measures that is not meaningfully defined for new observations.
For convenience, many augment methods provide default data
arguments,
so that augment(fit)
will return the augmented training data. In these
cases, augment tries to reconstruct the original data based on the model
object with varying degrees of success.
The augmented dataset is always returned as a tibble::tibble with the
same number of rows as the passed dataset. This means that the passed
data must be coercible to a tibble. If a predictor enters the model as part
of a matrix of covariates, such as when the model formula uses
splines::ns()
, stats::poly()
, or survival::Surv()
, it is represented
as a matrix column.
We are in the process of defining behaviors for models fit with various
na.action
arguments, but make no guarantees about behavior when data is
missing at this time.
## S3 method for class 'clm' augment( x, data = model.frame(x), newdata = NULL, type.predict = c("prob", "class"), ... )
## S3 method for class 'clm' augment( x, data = model.frame(x), newdata = NULL, type.predict = c("prob", "class"), ... )
x |
A |
data |
A base::data.frame or |
newdata |
A |
type.predict |
Which type of prediction to compute, either |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
tidy, ordinal::clm()
, ordinal::predict.clm()
Other ordinal tidiers:
augment.polr()
,
glance.clm()
,
glance.clmm()
,
glance.polr()
,
glance.svyolr()
,
tidy.clm()
,
tidy.clmm()
,
tidy.polr()
,
tidy.svyolr()
# load libraries for models and data library(ordinal) # fit model fit <- clm(rating ~ temp * contact, data = wine) # summarize model fit with tidiers tidy(fit) tidy(fit, conf.int = TRUE, conf.level = 0.9) tidy(fit, conf.int = TRUE, conf.type = "Wald", exponentiate = TRUE) glance(fit) augment(fit, type.predict = "prob") augment(fit, type.predict = "class") # ...and again with another model specification fit2 <- clm(rating ~ temp, nominal = ~contact, data = wine) tidy(fit2) glance(fit2)
# load libraries for models and data library(ordinal) # fit model fit <- clm(rating ~ temp * contact, data = wine) # summarize model fit with tidiers tidy(fit) tidy(fit, conf.int = TRUE, conf.level = 0.9) tidy(fit, conf.int = TRUE, conf.type = "Wald", exponentiate = TRUE) glance(fit) augment(fit, type.predict = "prob") augment(fit, type.predict = "class") # ...and again with another model specification fit2 <- clm(rating ~ temp, nominal = ~contact, data = wine) tidy(fit2) glance(fit2)
Augment accepts a model object and a dataset and adds
information about each observation in the dataset. Most commonly, this
includes predicted values in the .fitted
column, residuals in the
.resid
column, and standard errors for the fitted values in a .se.fit
column. New columns always begin with a .
prefix to avoid overwriting
columns in the original dataset.
Users may pass data to augment via either the data
argument or the
newdata
argument. If the user passes data to the data
argument,
it must be exactly the data that was used to fit the model
object. Pass datasets to newdata
to augment data that was not used
during model fitting. This still requires that at least all predictor
variable columns used to fit the model are present. If the original outcome
variable used to fit the model is not included in newdata
, then no
.resid
column will be included in the output.
Augment will often behave differently depending on whether data
or
newdata
is given. This is because there is often information
associated with training observations (such as influences or related)
measures that is not meaningfully defined for new observations.
For convenience, many augment methods provide default data
arguments,
so that augment(fit)
will return the augmented training data. In these
cases, augment tries to reconstruct the original data based on the model
object with varying degrees of success.
The augmented dataset is always returned as a tibble::tibble with the
same number of rows as the passed dataset. This means that the passed
data must be coercible to a tibble. If a predictor enters the model as part
of a matrix of covariates, such as when the model formula uses
splines::ns()
, stats::poly()
, or survival::Surv()
, it is represented
as a matrix column.
We are in the process of defining behaviors for models fit with various
na.action
arguments, but make no guarantees about behavior when data is
missing at this time.
## S3 method for class 'coxph' augment( x, data = model.frame(x), newdata = NULL, type.predict = "lp", type.residuals = "martingale", ... )
## S3 method for class 'coxph' augment( x, data = model.frame(x), newdata = NULL, type.predict = "lp", type.residuals = "martingale", ... )
x |
A |
data |
A base::data.frame or |
newdata |
A |
type.predict |
Character indicating type of prediction to use. Passed
to the |
type.residuals |
Character indicating type of residuals to use. Passed
to the |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
When the modeling was performed with na.action = "na.omit"
(as is the typical default), rows with NA in the initial data are omitted
entirely from the augmented data frame. When the modeling was performed
with na.action = "na.exclude"
, one should provide the original data
as a second argument, at which point the augmented data will contain those
rows (typically with NAs in place of the new columns). If the original data
is not provided to augment()
and na.action = "na.exclude"
, a
warning is raised and the incomplete rows are dropped.
A tibble::tibble()
with columns:
.fitted |
Fitted or predicted value. |
.resid |
The difference between observed and fitted values. |
.se.fit |
Standard errors of fitted values. |
Other coxph tidiers:
glance.coxph()
,
tidy.coxph()
Other survival tidiers:
augment.survreg()
,
glance.aareg()
,
glance.cch()
,
glance.coxph()
,
glance.pyears()
,
glance.survdiff()
,
glance.survexp()
,
glance.survfit()
,
glance.survreg()
,
tidy.aareg()
,
tidy.cch()
,
tidy.coxph()
,
tidy.pyears()
,
tidy.survdiff()
,
tidy.survexp()
,
tidy.survfit()
,
tidy.survreg()
# load libraries for models and data library(survival) # fit model cfit <- coxph(Surv(time, status) ~ age + sex, lung) # summarize model fit with tidiers tidy(cfit) tidy(cfit, exponentiate = TRUE) lp <- augment(cfit, lung) risks <- augment(cfit, lung, type.predict = "risk") expected <- augment(cfit, lung, type.predict = "expected") glance(cfit) # also works on clogit models resp <- levels(logan$occupation) n <- nrow(logan) indx <- rep(1:n, length(resp)) logan2 <- data.frame( logan[indx, ], id = indx, tocc = factor(rep(resp, each = n)) ) logan2$case <- (logan2$occupation == logan2$tocc) cl <- clogit(case ~ tocc + tocc:education + strata(id), logan2) tidy(cl) glance(cl) library(ggplot2) ggplot(lp, aes(age, .fitted, color = sex)) + geom_point() ggplot(risks, aes(age, .fitted, color = sex)) + geom_point() ggplot(expected, aes(time, .fitted, color = sex)) + geom_point()
# load libraries for models and data library(survival) # fit model cfit <- coxph(Surv(time, status) ~ age + sex, lung) # summarize model fit with tidiers tidy(cfit) tidy(cfit, exponentiate = TRUE) lp <- augment(cfit, lung) risks <- augment(cfit, lung, type.predict = "risk") expected <- augment(cfit, lung, type.predict = "expected") glance(cfit) # also works on clogit models resp <- levels(logan$occupation) n <- nrow(logan) indx <- rep(1:n, length(resp)) logan2 <- data.frame( logan[indx, ], id = indx, tocc = factor(rep(resp, each = n)) ) logan2$case <- (logan2$occupation == logan2$tocc) cl <- clogit(case ~ tocc + tocc:education + strata(id), logan2) tidy(cl) glance(cl) library(ggplot2) ggplot(lp, aes(age, .fitted, color = sex)) + geom_point() ggplot(risks, aes(age, .fitted, color = sex)) + geom_point() ggplot(expected, aes(time, .fitted, color = sex)) + geom_point()
Augment accepts a model object and a dataset and adds
information about each observation in the dataset. Most commonly, this
includes predicted values in the .fitted
column, residuals in the
.resid
column, and standard errors for the fitted values in a .se.fit
column. New columns always begin with a .
prefix to avoid overwriting
columns in the original dataset.
Users may pass data to augment via either the data
argument or the
newdata
argument. If the user passes data to the data
argument,
it must be exactly the data that was used to fit the model
object. Pass datasets to newdata
to augment data that was not used
during model fitting. This still requires that at least all predictor
variable columns used to fit the model are present. If the original outcome
variable used to fit the model is not included in newdata
, then no
.resid
column will be included in the output.
Augment will often behave differently depending on whether data
or
newdata
is given. This is because there is often information
associated with training observations (such as influences or related)
measures that is not meaningfully defined for new observations.
For convenience, many augment methods provide default data
arguments,
so that augment(fit)
will return the augmented training data. In these
cases, augment tries to reconstruct the original data based on the model
object with varying degrees of success.
The augmented dataset is always returned as a tibble::tibble with the
same number of rows as the passed dataset. This means that the passed
data must be coercible to a tibble. If a predictor enters the model as part
of a matrix of covariates, such as when the model formula uses
splines::ns()
, stats::poly()
, or survival::Surv()
, it is represented
as a matrix column.
We are in the process of defining behaviors for models fit with various
na.action
arguments, but make no guarantees about behavior when data is
missing at this time.
## S3 method for class 'decomposed.ts' augment(x, ...)
## S3 method for class 'decomposed.ts' augment(x, ...)
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble with one row for each observation in the original times series:
.seasonal |
The seasonal component of the decomposition. |
.trend |
The trend component of the decomposition. |
.remainder |
The remainder, or "random" component of the decomposition. |
.weight |
The final robust weights ( |
.seasadj |
The seasonally adjusted (or "deseasonalised") series. |
Other decompose tidiers:
augment.stl()
# time series of temperatures in Nottingham, 1920-1939: nottem # perform seasonal decomposition on the data with both decompose # and stl: d1 <- decompose(nottem) d2 <- stl(nottem, s.window = "periodic", robust = TRUE) # compare the original series to its decompositions. cbind( tidy(nottem), augment(d1), augment(d2) ) # visually compare seasonal decompositions in tidy data frames. library(tibble) library(dplyr) library(tidyr) library(ggplot2) decomps <- tibble( # turn the ts objects into data frames. series = list(as.data.frame(nottem), as.data.frame(nottem)), # add the models in, one for each row. decomp = c("decompose", "stl"), model = list(d1, d2) ) %>% rowwise() %>% # pull out the fitted data using broom::augment. mutate(augment = list(broom::augment(model))) %>% ungroup() %>% # unnest the data frames into a tidy arrangement of # the series next to its seasonal decomposition, grouped # by the method (stl or decompose). group_by(decomp) %>% unnest(c(series, augment)) %>% mutate(index = 1:n()) %>% ungroup() %>% select(decomp, index, x, adjusted = .seasadj) ggplot(decomps) + geom_line(aes(x = index, y = x), colour = "black") + geom_line(aes( x = index, y = adjusted, colour = decomp, group = decomp ))
# time series of temperatures in Nottingham, 1920-1939: nottem # perform seasonal decomposition on the data with both decompose # and stl: d1 <- decompose(nottem) d2 <- stl(nottem, s.window = "periodic", robust = TRUE) # compare the original series to its decompositions. cbind( tidy(nottem), augment(d1), augment(d2) ) # visually compare seasonal decompositions in tidy data frames. library(tibble) library(dplyr) library(tidyr) library(ggplot2) decomps <- tibble( # turn the ts objects into data frames. series = list(as.data.frame(nottem), as.data.frame(nottem)), # add the models in, one for each row. decomp = c("decompose", "stl"), model = list(d1, d2) ) %>% rowwise() %>% # pull out the fitted data using broom::augment. mutate(augment = list(broom::augment(model))) %>% ungroup() %>% # unnest the data frames into a tidy arrangement of # the series next to its seasonal decomposition, grouped # by the method (stl or decompose). group_by(decomp) %>% unnest(c(series, augment)) %>% mutate(index = 1:n()) %>% ungroup() %>% select(decomp, index, x, adjusted = .seasadj) ggplot(decomps) + geom_line(aes(x = index, y = x), colour = "black") + geom_line(aes( x = index, y = adjusted, colour = decomp, group = decomp ))
Augment accepts a model object and a dataset and adds
information about each observation in the dataset. Most commonly, this
includes predicted values in the .fitted
column, residuals in the
.resid
column, and standard errors for the fitted values in a .se.fit
column. New columns always begin with a .
prefix to avoid overwriting
columns in the original dataset.
Users may pass data to augment via either the data
argument or the
newdata
argument. If the user passes data to the data
argument,
it must be exactly the data that was used to fit the model
object. Pass datasets to newdata
to augment data that was not used
during model fitting. This still requires that at least all predictor
variable columns used to fit the model are present. If the original outcome
variable used to fit the model is not included in newdata
, then no
.resid
column will be included in the output.
Augment will often behave differently depending on whether data
or
newdata
is given. This is because there is often information
associated with training observations (such as influences or related)
measures that is not meaningfully defined for new observations.
For convenience, many augment methods provide default data
arguments,
so that augment(fit)
will return the augmented training data. In these
cases, augment tries to reconstruct the original data based on the model
object with varying degrees of success.
The augmented dataset is always returned as a tibble::tibble with the
same number of rows as the passed dataset. This means that the passed
data must be coercible to a tibble. If a predictor enters the model as part
of a matrix of covariates, such as when the model formula uses
splines::ns()
, stats::poly()
, or survival::Surv()
, it is represented
as a matrix column.
We are in the process of defining behaviors for models fit with various
na.action
arguments, but make no guarantees about behavior when data is
missing at this time.
## S3 method for class 'drc' augment( x, data = NULL, newdata = NULL, se_fit = FALSE, conf.int = FALSE, conf.level = 0.95, ... )
## S3 method for class 'drc' augment( x, data = NULL, newdata = NULL, se_fit = FALSE, conf.int = FALSE, conf.level = 0.95, ... )
x |
A |
data |
A base::data.frame or |
newdata |
A |
se_fit |
Logical indicating whether or not a |
conf.int |
Logical indicating whether or not to include a confidence
interval in the tidied output. Defaults to |
conf.level |
The confidence level to use for the confidence interval
if |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with columns:
.cooksd |
Cooks distance. |
.fitted |
Fitted or predicted value. |
.lower |
Lower bound on interval for fitted values. |
.resid |
The difference between observed and fitted values. |
.se.fit |
Standard errors of fitted values. |
.upper |
Upper bound on interval for fitted values. |
Other drc tidiers:
glance.drc()
,
tidy.drc()
# load libraries for models and data library(drc) # fit model mod <- drm(dead / total ~ conc, type, weights = total, data = selenium, fct = LL.2(), type = "binomial" ) # summarize model fit with tidiers tidy(mod) tidy(mod, conf.int = TRUE) glance(mod) augment(mod, selenium)
# load libraries for models and data library(drc) # fit model mod <- drm(dead / total ~ conc, type, weights = total, data = selenium, fct = LL.2(), type = "binomial" ) # summarize model fit with tidiers tidy(mod) tidy(mod, conf.int = TRUE) glance(mod) augment(mod, selenium)
Augment accepts a model object and a dataset and adds
information about each observation in the dataset. Most commonly, this
includes predicted values in the .fitted
column, residuals in the
.resid
column, and standard errors for the fitted values in a .se.fit
column. New columns always begin with a .
prefix to avoid overwriting
columns in the original dataset.
Users may pass data to augment via either the data
argument or the
newdata
argument. If the user passes data to the data
argument,
it must be exactly the data that was used to fit the model
object. Pass datasets to newdata
to augment data that was not used
during model fitting. This still requires that at least all predictor
variable columns used to fit the model are present. If the original outcome
variable used to fit the model is not included in newdata
, then no
.resid
column will be included in the output.
Augment will often behave differently depending on whether data
or
newdata
is given. This is because there is often information
associated with training observations (such as influences or related)
measures that is not meaningfully defined for new observations.
For convenience, many augment methods provide default data
arguments,
so that augment(fit)
will return the augmented training data. In these
cases, augment tries to reconstruct the original data based on the model
object with varying degrees of success.
The augmented dataset is always returned as a tibble::tibble with the
same number of rows as the passed dataset. This means that the passed
data must be coercible to a tibble. If a predictor enters the model as part
of a matrix of covariates, such as when the model formula uses
splines::ns()
, stats::poly()
, or survival::Surv()
, it is represented
as a matrix column.
We are in the process of defining behaviors for models fit with various
na.action
arguments, but make no guarantees about behavior when data is
missing at this time.
## S3 method for class 'factanal' augment(x, data, ...)
## S3 method for class 'factanal' augment(x, data, ...)
x |
A |
data |
A base::data.frame or |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
When data
is not supplied augment.factanal
returns one
row for each observation, with a factor score column added for each factor
X, (.fsX
). This is because stats::factanal()
, unlike other
stats methods like stats::lm()
, does not retain the original data.
When data
is supplied, augment.factanal
returns one row for
each observation, with a factor score column added for each factor X,
(.fsX
).
Other factanal tidiers:
glance.factanal()
,
tidy.factanal()
Augment accepts a model object and a dataset and adds
information about each observation in the dataset. Most commonly, this
includes predicted values in the .fitted
column, residuals in the
.resid
column, and standard errors for the fitted values in a .se.fit
column. New columns always begin with a .
prefix to avoid overwriting
columns in the original dataset.
Users may pass data to augment via either the data
argument or the
newdata
argument. If the user passes data to the data
argument,
it must be exactly the data that was used to fit the model
object. Pass datasets to newdata
to augment data that was not used
during model fitting. This still requires that at least all predictor
variable columns used to fit the model are present. If the original outcome
variable used to fit the model is not included in newdata
, then no
.resid
column will be included in the output.
Augment will often behave differently depending on whether data
or
newdata
is given. This is because there is often information
associated with training observations (such as influences or related)
measures that is not meaningfully defined for new observations.
For convenience, many augment methods provide default data
arguments,
so that augment(fit)
will return the augmented training data. In these
cases, augment tries to reconstruct the original data based on the model
object with varying degrees of success.
The augmented dataset is always returned as a tibble::tibble with the
same number of rows as the passed dataset. This means that the passed
data must be coercible to a tibble. If a predictor enters the model as part
of a matrix of covariates, such as when the model formula uses
splines::ns()
, stats::poly()
, or survival::Surv()
, it is represented
as a matrix column.
We are in the process of defining behaviors for models fit with various
na.action
arguments, but make no guarantees about behavior when data is
missing at this time.
## S3 method for class 'felm' augment(x, data = model.frame(x), ...)
## S3 method for class 'felm' augment(x, data = model.frame(x), ...)
x |
A |
data |
A base::data.frame or |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with columns:
.fitted |
Fitted or predicted value. |
.resid |
The difference between observed and fitted values. |
Other felm tidiers:
tidy.felm()
# load libraries for models and data library(lfe) # use built-in `airquality` dataset head(airquality) # no FEs; same as lm() est0 <- felm(Ozone ~ Temp + Wind + Solar.R, airquality) # summarize model fit with tidiers tidy(est0) augment(est0) # add month fixed effects est1 <- felm(Ozone ~ Temp + Wind + Solar.R | Month, airquality) # summarize model fit with tidiers tidy(est1) tidy(est1, fe = TRUE) augment(est1) glance(est1) # the "se.type" argument can be used to switch out different standard errors # types on the fly. In turn, this can be useful exploring the effect of # different error structures on model inference. tidy(est1, se.type = "iid") tidy(est1, se.type = "robust") # add clustered SEs (also by month) est2 <- felm(Ozone ~ Temp + Wind + Solar.R | Month | 0 | Month, airquality) # summarize model fit with tidiers tidy(est2, conf.int = TRUE) tidy(est2, conf.int = TRUE, se.type = "cluster") tidy(est2, conf.int = TRUE, se.type = "robust") tidy(est2, conf.int = TRUE, se.type = "iid")
# load libraries for models and data library(lfe) # use built-in `airquality` dataset head(airquality) # no FEs; same as lm() est0 <- felm(Ozone ~ Temp + Wind + Solar.R, airquality) # summarize model fit with tidiers tidy(est0) augment(est0) # add month fixed effects est1 <- felm(Ozone ~ Temp + Wind + Solar.R | Month, airquality) # summarize model fit with tidiers tidy(est1) tidy(est1, fe = TRUE) augment(est1) glance(est1) # the "se.type" argument can be used to switch out different standard errors # types on the fly. In turn, this can be useful exploring the effect of # different error structures on model inference. tidy(est1, se.type = "iid") tidy(est1, se.type = "robust") # add clustered SEs (also by month) est2 <- felm(Ozone ~ Temp + Wind + Solar.R | Month | 0 | Month, airquality) # summarize model fit with tidiers tidy(est2, conf.int = TRUE) tidy(est2, conf.int = TRUE, se.type = "cluster") tidy(est2, conf.int = TRUE, se.type = "robust") tidy(est2, conf.int = TRUE, se.type = "iid")
Augment accepts a model object and a dataset and adds
information about each observation in the dataset. Most commonly, this
includes predicted values in the .fitted
column, residuals in the
.resid
column, and standard errors for the fitted values in a .se.fit
column. New columns always begin with a .
prefix to avoid overwriting
columns in the original dataset.
Users may pass data to augment via either the data
argument or the
newdata
argument. If the user passes data to the data
argument,
it must be exactly the data that was used to fit the model
object. Pass datasets to newdata
to augment data that was not used
during model fitting. This still requires that at least all predictor
variable columns used to fit the model are present. If the original outcome
variable used to fit the model is not included in newdata
, then no
.resid
column will be included in the output.
Augment will often behave differently depending on whether data
or
newdata
is given. This is because there is often information
associated with training observations (such as influences or related)
measures that is not meaningfully defined for new observations.
For convenience, many augment methods provide default data
arguments,
so that augment(fit)
will return the augmented training data. In these
cases, augment tries to reconstruct the original data based on the model
object with varying degrees of success.
The augmented dataset is always returned as a tibble::tibble with the
same number of rows as the passed dataset. This means that the passed
data must be coercible to a tibble. If a predictor enters the model as part
of a matrix of covariates, such as when the model formula uses
splines::ns()
, stats::poly()
, or survival::Surv()
, it is represented
as a matrix column.
We are in the process of defining behaviors for models fit with various
na.action
arguments, but make no guarantees about behavior when data is
missing at this time.
## S3 method for class 'fixest' augment( x, data = NULL, newdata = NULL, type.predict = c("link", "response"), type.residuals = c("response", "deviance", "pearson", "working"), ... )
## S3 method for class 'fixest' augment( x, data = NULL, newdata = NULL, type.predict = c("link", "response"), type.residuals = c("response", "deviance", "pearson", "working"), ... )
x |
A |
data |
A base::data.frame or |
newdata |
A |
type.predict |
Passed to |
type.residuals |
Passed to |
... |
Additional arguments passed to |
A tibble::tibble()
with columns:
.fitted |
Fitted or predicted value. |
.resid |
The difference between observed and fitted values. |
Important note: fixest
models do not include a copy of the input
data, so you must provide it manually.
augment.fixest only works for fixest::feols()
, fixest::feglm()
, and
fixest::femlm()
models. It does not work with results from
fixest::fenegbin()
, fixest::feNmlm()
, or fixest::fepois()
.
augment()
, fixest::feglm()
, fixest::femlm()
, fixest::feols()
Other fixest tidiers:
tidy.fixest()
# load libraries for models and data library(fixest) gravity <- feols( log(Euros) ~ log(dist_km) | Origin + Destination + Product + Year, trade ) tidy(gravity) glance(gravity) augment(gravity, trade) # to get robust or clustered SEs, users can either: # 1) specify the arguments directly in the `tidy()` call tidy(gravity, conf.int = TRUE, cluster = c("Product", "Year")) tidy(gravity, conf.int = TRUE, se = "threeway") # 2) or, feed tidy() a summary.fixest object that has already accepted # these arguments gravity_summ <- summary(gravity, cluster = c("Product", "Year")) tidy(gravity_summ, conf.int = TRUE) # approach (1) is preferred.
# load libraries for models and data library(fixest) gravity <- feols( log(Euros) ~ log(dist_km) | Origin + Destination + Product + Year, trade ) tidy(gravity) glance(gravity) augment(gravity, trade) # to get robust or clustered SEs, users can either: # 1) specify the arguments directly in the `tidy()` call tidy(gravity, conf.int = TRUE, cluster = c("Product", "Year")) tidy(gravity, conf.int = TRUE, se = "threeway") # 2) or, feed tidy() a summary.fixest object that has already accepted # these arguments gravity_summ <- summary(gravity, cluster = c("Product", "Year")) tidy(gravity_summ, conf.int = TRUE) # approach (1) is preferred.
Augment accepts a model object and a dataset and adds
information about each observation in the dataset. Most commonly, this
includes predicted values in the .fitted
column, residuals in the
.resid
column, and standard errors for the fitted values in a .se.fit
column. New columns always begin with a .
prefix to avoid overwriting
columns in the original dataset.
Users may pass data to augment via either the data
argument or the
newdata
argument. If the user passes data to the data
argument,
it must be exactly the data that was used to fit the model
object. Pass datasets to newdata
to augment data that was not used
during model fitting. This still requires that at least all predictor
variable columns used to fit the model are present. If the original outcome
variable used to fit the model is not included in newdata
, then no
.resid
column will be included in the output.
Augment will often behave differently depending on whether data
or
newdata
is given. This is because there is often information
associated with training observations (such as influences or related)
measures that is not meaningfully defined for new observations.
For convenience, many augment methods provide default data
arguments,
so that augment(fit)
will return the augmented training data. In these
cases, augment tries to reconstruct the original data based on the model
object with varying degrees of success.
The augmented dataset is always returned as a tibble::tibble with the
same number of rows as the passed dataset. This means that the passed
data must be coercible to a tibble. If a predictor enters the model as part
of a matrix of covariates, such as when the model formula uses
splines::ns()
, stats::poly()
, or survival::Surv()
, it is represented
as a matrix column.
We are in the process of defining behaviors for models fit with various
na.action
arguments, but make no guarantees about behavior when data is
missing at this time.
## S3 method for class 'gam' augment( x, data = model.frame(x), newdata = NULL, type.predict, type.residuals, ... )
## S3 method for class 'gam' augment( x, data = model.frame(x), newdata = NULL, type.predict, type.residuals, ... )
x |
A |
data |
A base::data.frame or |
newdata |
A |
type.predict |
Character indicating type of prediction to use. Passed
to the |
type.residuals |
Character indicating type of residuals to use. Passed
to the |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
For additional details on Cook's distance, see
stats::cooks.distance()
.
A tibble::tibble()
with columns:
.cooksd |
Cooks distance. |
.fitted |
Fitted or predicted value. |
.hat |
Diagonal of the hat matrix. |
.resid |
The difference between observed and fitted values. |
.se.fit |
Standard errors of fitted values. |
.sigma |
Estimated residual standard deviation when corresponding observation is dropped from model. |
# load libraries for models and data library(mgcv) # fit model g <- gam(mpg ~ s(hp) + am + qsec, data = mtcars) # summarize model fit with tidiers tidy(g) tidy(g, parametric = TRUE) glance(g) augment(g)
# load libraries for models and data library(mgcv) # fit model g <- gam(mpg ~ s(hp) + am + qsec, data = mtcars) # summarize model fit with tidiers tidy(g) tidy(g, parametric = TRUE) glance(g) augment(g)
Augment accepts a model object and a dataset and adds
information about each observation in the dataset. Most commonly, this
includes predicted values in the .fitted
column, residuals in the
.resid
column, and standard errors for the fitted values in a .se.fit
column. New columns always begin with a .
prefix to avoid overwriting
columns in the original dataset.
Users may pass data to augment via either the data
argument or the
newdata
argument. If the user passes data to the data
argument,
it must be exactly the data that was used to fit the model
object. Pass datasets to newdata
to augment data that was not used
during model fitting. This still requires that at least all predictor
variable columns used to fit the model are present. If the original outcome
variable used to fit the model is not included in newdata
, then no
.resid
column will be included in the output.
Augment will often behave differently depending on whether data
or
newdata
is given. This is because there is often information
associated with training observations (such as influences or related)
measures that is not meaningfully defined for new observations.
For convenience, many augment methods provide default data
arguments,
so that augment(fit)
will return the augmented training data. In these
cases, augment tries to reconstruct the original data based on the model
object with varying degrees of success.
The augmented dataset is always returned as a tibble::tibble with the
same number of rows as the passed dataset. This means that the passed
data must be coercible to a tibble. If a predictor enters the model as part
of a matrix of covariates, such as when the model formula uses
splines::ns()
, stats::poly()
, or survival::Surv()
, it is represented
as a matrix column.
We are in the process of defining behaviors for models fit with various
na.action
arguments, but make no guarantees about behavior when data is
missing at this time.
## S3 method for class 'glm' augment( x, data = model.frame(x), newdata = NULL, type.predict = c("link", "response", "terms"), type.residuals = c("deviance", "pearson"), se_fit = FALSE, ... )
## S3 method for class 'glm' augment( x, data = model.frame(x), newdata = NULL, type.predict = c("link", "response", "terms"), type.residuals = c("deviance", "pearson"), se_fit = FALSE, ... )
x |
A |
data |
A base::data.frame or |
newdata |
A |
type.predict |
Passed to |
type.residuals |
Passed to |
se_fit |
Logical indicating whether or not a |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
If the weights for any of the observations in the model are 0, then columns ".infl" and ".hat" in the result will be 0 for those observations.
A .resid
column is not calculated when data is specified via
the newdata
argument.
A tibble::tibble()
with columns:
.cooksd |
Cooks distance. |
.fitted |
Fitted or predicted value. |
.hat |
Diagonal of the hat matrix. |
.resid |
The difference between observed and fitted values. |
.se.fit |
Standard errors of fitted values. |
.sigma |
Estimated residual standard deviation when corresponding observation is dropped from model. |
.std.resid |
Standardised residuals. |
Other lm tidiers:
augment.lm()
,
glance.glm()
,
glance.lm()
,
glance.summary.lm()
,
glance.svyglm()
,
tidy.glm()
,
tidy.lm()
,
tidy.lm.beta()
,
tidy.mlm()
,
tidy.summary.lm()
Augment accepts a model object and a dataset and adds
information about each observation in the dataset. Most commonly, this
includes predicted values in the .fitted
column, residuals in the
.resid
column, and standard errors for the fitted values in a .se.fit
column. New columns always begin with a .
prefix to avoid overwriting
columns in the original dataset.
Users may pass data to augment via either the data
argument or the
newdata
argument. If the user passes data to the data
argument,
it must be exactly the data that was used to fit the model
object. Pass datasets to newdata
to augment data that was not used
during model fitting. This still requires that at least all predictor
variable columns used to fit the model are present. If the original outcome
variable used to fit the model is not included in newdata
, then no
.resid
column will be included in the output.
Augment will often behave differently depending on whether data
or
newdata
is given. This is because there is often information
associated with training observations (such as influences or related)
measures that is not meaningfully defined for new observations.
For convenience, many augment methods provide default data
arguments,
so that augment(fit)
will return the augmented training data. In these
cases, augment tries to reconstruct the original data based on the model
object with varying degrees of success.
The augmented dataset is always returned as a tibble::tibble with the
same number of rows as the passed dataset. This means that the passed
data must be coercible to a tibble. If a predictor enters the model as part
of a matrix of covariates, such as when the model formula uses
splines::ns()
, stats::poly()
, or survival::Surv()
, it is represented
as a matrix column.
We are in the process of defining behaviors for models fit with various
na.action
arguments, but make no guarantees about behavior when data is
missing at this time.
## S3 method for class 'glmrob' augment( x, data = model.frame(x), newdata = NULL, type.predict = c("link", "response"), type.residuals = c("deviance", "pearson"), se_fit = FALSE, ... )
## S3 method for class 'glmrob' augment( x, data = model.frame(x), newdata = NULL, type.predict = c("link", "response"), type.residuals = c("deviance", "pearson"), se_fit = FALSE, ... )
x |
A |
data |
A base::data.frame or |
newdata |
A |
type.predict |
Character indicating type of prediction to use. Passed
to the |
type.residuals |
Character indicating type of residuals to use. Passed
to the |
se_fit |
Logical indicating whether or not a |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
For tidiers for robust models from the MASS package see
tidy.rlm()
.
A tibble::tibble()
with columns:
.fitted |
Fitted or predicted value. |
.resid |
The difference between observed and fitted values. |
Other robustbase tidiers:
augment.lmrob()
,
glance.lmrob()
,
tidy.glmrob()
,
tidy.lmrob()
if (requireNamespace("robustbase", quietly = TRUE)) { # load libraries for models and data library(robustbase) data(coleman) set.seed(0) m <- lmrob(Y ~ ., data = coleman) tidy(m) augment(m) glance(m) data(carrots) Rfit <- glmrob(cbind(success, total - success) ~ logdose + block, family = binomial, data = carrots, method = "Mqle", control = glmrobMqle.control(tcc = 1.2) ) tidy(Rfit) augment(Rfit) }
if (requireNamespace("robustbase", quietly = TRUE)) { # load libraries for models and data library(robustbase) data(coleman) set.seed(0) m <- lmrob(Y ~ ., data = coleman) tidy(m) augment(m) glance(m) data(carrots) Rfit <- glmrob(cbind(success, total - success) ~ logdose + block, family = binomial, data = carrots, method = "Mqle", control = glmrobMqle.control(tcc = 1.2) ) tidy(Rfit) augment(Rfit) }
Augment accepts a model object and a dataset and adds
information about each observation in the dataset. Most commonly, this
includes predicted values in the .fitted
column, residuals in the
.resid
column, and standard errors for the fitted values in a .se.fit
column. New columns always begin with a .
prefix to avoid overwriting
columns in the original dataset.
Users may pass data to augment via either the data
argument or the
newdata
argument. If the user passes data to the data
argument,
it must be exactly the data that was used to fit the model
object. Pass datasets to newdata
to augment data that was not used
during model fitting. This still requires that at least all predictor
variable columns used to fit the model are present. If the original outcome
variable used to fit the model is not included in newdata
, then no
.resid
column will be included in the output.
Augment will often behave differently depending on whether data
or
newdata
is given. This is because there is often information
associated with training observations (such as influences or related)
measures that is not meaningfully defined for new observations.
For convenience, many augment methods provide default data
arguments,
so that augment(fit)
will return the augmented training data. In these
cases, augment tries to reconstruct the original data based on the model
object with varying degrees of success.
The augmented dataset is always returned as a tibble::tibble with the
same number of rows as the passed dataset. This means that the passed
data must be coercible to a tibble. If a predictor enters the model as part
of a matrix of covariates, such as when the model formula uses
splines::ns()
, stats::poly()
, or survival::Surv()
, it is represented
as a matrix column.
We are in the process of defining behaviors for models fit with various
na.action
arguments, but make no guarantees about behavior when data is
missing at this time.
## S3 method for class 'glmRob' augment(x, ...)
## S3 method for class 'glmRob' augment(x, ...)
x |
Unused. |
... |
Unused. |
Augment accepts a model object and a dataset and adds
information about each observation in the dataset. Most commonly, this
includes predicted values in the .fitted
column, residuals in the
.resid
column, and standard errors for the fitted values in a .se.fit
column. New columns always begin with a .
prefix to avoid overwriting
columns in the original dataset.
Users may pass data to augment via either the data
argument or the
newdata
argument. If the user passes data to the data
argument,
it must be exactly the data that was used to fit the model
object. Pass datasets to newdata
to augment data that was not used
during model fitting. This still requires that at least all predictor
variable columns used to fit the model are present. If the original outcome
variable used to fit the model is not included in newdata
, then no
.resid
column will be included in the output.
Augment will often behave differently depending on whether data
or
newdata
is given. This is because there is often information
associated with training observations (such as influences or related)
measures that is not meaningfully defined for new observations.
For convenience, many augment methods provide default data
arguments,
so that augment(fit)
will return the augmented training data. In these
cases, augment tries to reconstruct the original data based on the model
object with varying degrees of success.
The augmented dataset is always returned as a tibble::tibble with the
same number of rows as the passed dataset. This means that the passed
data must be coercible to a tibble. If a predictor enters the model as part
of a matrix of covariates, such as when the model formula uses
splines::ns()
, stats::poly()
, or survival::Surv()
, it is represented
as a matrix column.
We are in the process of defining behaviors for models fit with various
na.action
arguments, but make no guarantees about behavior when data is
missing at this time.
## S3 method for class 'htest' augment(x, ...)
## S3 method for class 'htest' augment(x, ...)
x |
An |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
See stats::chisq.test()
for more details on
how residuals are computed.
A tibble::tibble()
with exactly one row and columns:
.observed |
Observed count. |
.prop |
Proportion of the total. |
.row.prop |
Row proportion (2 dimensions table only). |
.col.prop |
Column proportion (2 dimensions table only). |
.expected |
Expected count under the null hypothesis. |
.resid |
Pearson residuals. |
.std.resid |
Standardized residual. |
augment()
, stats::chisq.test()
Other htest tidiers:
tidy.htest()
,
tidy.pairwise.htest()
,
tidy.power.htest()
tt <- t.test(rnorm(10)) tidy(tt) # the glance output will be the same for each of the below tests glance(tt) tt <- t.test(mpg ~ am, data = mtcars) tidy(tt) wt <- wilcox.test(mpg ~ am, data = mtcars, conf.int = TRUE, exact = FALSE) tidy(wt) ct <- cor.test(mtcars$wt, mtcars$mpg) tidy(ct) chit <- chisq.test(xtabs(Freq ~ Sex + Class, data = as.data.frame(Titanic))) tidy(chit) augment(chit)
tt <- t.test(rnorm(10)) tidy(tt) # the glance output will be the same for each of the below tests glance(tt) tt <- t.test(mpg ~ am, data = mtcars) tidy(tt) wt <- wilcox.test(mpg ~ am, data = mtcars, conf.int = TRUE, exact = FALSE) tidy(wt) ct <- cor.test(mtcars$wt, mtcars$mpg) tidy(ct) chit <- chisq.test(xtabs(Freq ~ Sex + Class, data = as.data.frame(Titanic))) tidy(chit) augment(chit)
Augment accepts a model object and a dataset and adds
information about each observation in the dataset. Most commonly, this
includes predicted values in the .fitted
column, residuals in the
.resid
column, and standard errors for the fitted values in a .se.fit
column. New columns always begin with a .
prefix to avoid overwriting
columns in the original dataset.
Users may pass data to augment via either the data
argument or the
newdata
argument. If the user passes data to the data
argument,
it must be exactly the data that was used to fit the model
object. Pass datasets to newdata
to augment data that was not used
during model fitting. This still requires that at least all predictor
variable columns used to fit the model are present. If the original outcome
variable used to fit the model is not included in newdata
, then no
.resid
column will be included in the output.
Augment will often behave differently depending on whether data
or
newdata
is given. This is because there is often information
associated with training observations (such as influences or related)
measures that is not meaningfully defined for new observations.
For convenience, many augment methods provide default data
arguments,
so that augment(fit)
will return the augmented training data. In these
cases, augment tries to reconstruct the original data based on the model
object with varying degrees of success.
The augmented dataset is always returned as a tibble::tibble with the
same number of rows as the passed dataset. This means that the passed
data must be coercible to a tibble. If a predictor enters the model as part
of a matrix of covariates, such as when the model formula uses
splines::ns()
, stats::poly()
, or survival::Surv()
, it is represented
as a matrix column.
We are in the process of defining behaviors for models fit with various
na.action
arguments, but make no guarantees about behavior when data is
missing at this time.
## S3 method for class 'ivreg' augment(x, data = model.frame(x), newdata = NULL, ...)
## S3 method for class 'ivreg' augment(x, data = model.frame(x), newdata = NULL, ...)
x |
An |
data |
A base::data.frame or |
newdata |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
This tidier currently only supports ivreg
-classed objects
outputted by the AER
package. The ivreg
package also outputs
objects of class ivreg
, and will be supported in a later release.
A tibble::tibble()
with columns:
.fitted |
Fitted or predicted value. |
.resid |
The difference between observed and fitted values. |
Other ivreg tidiers:
glance.ivreg()
,
tidy.ivreg()
# load libraries for models and data library(AER) # load data data("CigarettesSW", package = "AER") # fit model ivr <- ivreg( log(packs) ~ income | population, data = CigarettesSW, subset = year == "1995" ) # summarize model fit with tidiers tidy(ivr) tidy(ivr, conf.int = TRUE) tidy(ivr, conf.int = TRUE, instruments = TRUE) augment(ivr) augment(ivr, data = CigarettesSW) augment(ivr, newdata = CigarettesSW) glance(ivr)
# load libraries for models and data library(AER) # load data data("CigarettesSW", package = "AER") # fit model ivr <- ivreg( log(packs) ~ income | population, data = CigarettesSW, subset = year == "1995" ) # summarize model fit with tidiers tidy(ivr) tidy(ivr, conf.int = TRUE) tidy(ivr, conf.int = TRUE, instruments = TRUE) augment(ivr) augment(ivr, data = CigarettesSW) augment(ivr, newdata = CigarettesSW) glance(ivr)
Augment accepts a model object and a dataset and adds
information about each observation in the dataset. Most commonly, this
includes predicted values in the .fitted
column, residuals in the
.resid
column, and standard errors for the fitted values in a .se.fit
column. New columns always begin with a .
prefix to avoid overwriting
columns in the original dataset.
Users may pass data to augment via either the data
argument or the
newdata
argument. If the user passes data to the data
argument,
it must be exactly the data that was used to fit the model
object. Pass datasets to newdata
to augment data that was not used
during model fitting. This still requires that at least all predictor
variable columns used to fit the model are present. If the original outcome
variable used to fit the model is not included in newdata
, then no
.resid
column will be included in the output.
Augment will often behave differently depending on whether data
or
newdata
is given. This is because there is often information
associated with training observations (such as influences or related)
measures that is not meaningfully defined for new observations.
For convenience, many augment methods provide default data
arguments,
so that augment(fit)
will return the augmented training data. In these
cases, augment tries to reconstruct the original data based on the model
object with varying degrees of success.
The augmented dataset is always returned as a tibble::tibble with the
same number of rows as the passed dataset. This means that the passed
data must be coercible to a tibble. If a predictor enters the model as part
of a matrix of covariates, such as when the model formula uses
splines::ns()
, stats::poly()
, or survival::Surv()
, it is represented
as a matrix column.
We are in the process of defining behaviors for models fit with various
na.action
arguments, but make no guarantees about behavior when data is
missing at this time.
## S3 method for class 'kmeans' augment(x, data, ...)
## S3 method for class 'kmeans' augment(x, data, ...)
x |
A |
data |
A base::data.frame or |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with columns:
.cluster |
Cluster assignment. |
Other kmeans tidiers:
glance.kmeans()
,
tidy.kmeans()
library(cluster) library(modeldata) library(dplyr) data(hpc_data) x <- hpc_data[, 2:5] fit <- pam(x, k = 4) tidy(fit) glance(fit) augment(fit, x)
library(cluster) library(modeldata) library(dplyr) data(hpc_data) x <- hpc_data[, 2:5] fit <- pam(x, k = 4) tidy(fit) glance(fit) augment(fit, x)
Augment accepts a model object and a dataset and adds
information about each observation in the dataset. Most commonly, this
includes predicted values in the .fitted
column, residuals in the
.resid
column, and standard errors for the fitted values in a .se.fit
column. New columns always begin with a .
prefix to avoid overwriting
columns in the original dataset.
Users may pass data to augment via either the data
argument or the
newdata
argument. If the user passes data to the data
argument,
it must be exactly the data that was used to fit the model
object. Pass datasets to newdata
to augment data that was not used
during model fitting. This still requires that at least all predictor
variable columns used to fit the model are present. If the original outcome
variable used to fit the model is not included in newdata
, then no
.resid
column will be included in the output.
Augment will often behave differently depending on whether data
or
newdata
is given. This is because there is often information
associated with training observations (such as influences or related)
measures that is not meaningfully defined for new observations.
For convenience, many augment methods provide default data
arguments,
so that augment(fit)
will return the augmented training data. In these
cases, augment tries to reconstruct the original data based on the model
object with varying degrees of success.
The augmented dataset is always returned as a tibble::tibble with the
same number of rows as the passed dataset. This means that the passed
data must be coercible to a tibble. If a predictor enters the model as part
of a matrix of covariates, such as when the model formula uses
splines::ns()
, stats::poly()
, or survival::Surv()
, it is represented
as a matrix column.
We are in the process of defining behaviors for models fit with various
na.action
arguments, but make no guarantees about behavior when data is
missing at this time.
## S3 method for class 'lm' augment( x, data = model.frame(x), newdata = NULL, se_fit = FALSE, interval = c("none", "confidence", "prediction"), conf.level = 0.95, ... )
## S3 method for class 'lm' augment( x, data = model.frame(x), newdata = NULL, se_fit = FALSE, interval = c("none", "confidence", "prediction"), conf.level = 0.95, ... )
x |
An |
data |
A base::data.frame or |
newdata |
A |
se_fit |
Logical indicating whether or not a |
interval |
Character indicating the type of confidence interval columns
to be added to the augmented output. Passed on to |
conf.level |
The confidence level to use for the interval created if
|
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
When the modeling was performed with na.action = "na.omit"
(as is the typical default), rows with NA in the initial data are omitted
entirely from the augmented data frame. When the modeling was performed
with na.action = "na.exclude"
, one should provide the original data
as a second argument, at which point the augmented data will contain those
rows (typically with NAs in place of the new columns). If the original data
is not provided to augment()
and na.action = "na.exclude"
, a
warning is raised and the incomplete rows are dropped.
Some unusual lm
objects, such as rlm
from MASS, may omit
.cooksd
and .std.resid
. gam
from mgcv omits .sigma
.
When newdata
is supplied, only returns .fitted
, .resid
and
.se.fit
columns.
A tibble::tibble()
with columns:
.cooksd |
Cooks distance. |
.fitted |
Fitted or predicted value. |
.hat |
Diagonal of the hat matrix. |
.lower |
Lower bound on interval for fitted values. |
.resid |
The difference between observed and fitted values. |
.se.fit |
Standard errors of fitted values. |
.sigma |
Estimated residual standard deviation when corresponding observation is dropped from model. |
.std.resid |
Standardised residuals. |
.upper |
Upper bound on interval for fitted values. |
augment()
, stats::predict.lm()
Other lm tidiers:
augment.glm()
,
glance.glm()
,
glance.lm()
,
glance.summary.lm()
,
glance.svyglm()
,
tidy.glm()
,
tidy.lm()
,
tidy.lm.beta()
,
tidy.mlm()
,
tidy.summary.lm()
library(ggplot2) library(dplyr) mod <- lm(mpg ~ wt + qsec, data = mtcars) tidy(mod) glance(mod) # coefficient plot d <- tidy(mod, conf.int = TRUE) ggplot(d, aes(estimate, term, xmin = conf.low, xmax = conf.high, height = 0)) + geom_point() + geom_vline(xintercept = 0, lty = 4) + geom_errorbarh() # aside: There are tidy() and glance() methods for lm.summary objects too. # this can be useful when you want to conserve memory by converting large lm # objects into their leaner summary.lm equivalents. s <- summary(mod) tidy(s, conf.int = TRUE) glance(s) augment(mod) augment(mod, mtcars, interval = "confidence") # predict on new data newdata <- mtcars %>% head(6) %>% mutate(wt = wt + 1) augment(mod, newdata = newdata) # ggplot2 example where we also construct 95% prediction interval # simpler bivariate model since we're plotting in 2D mod2 <- lm(mpg ~ wt, data = mtcars) au <- augment(mod2, newdata = newdata, interval = "prediction") ggplot(au, aes(wt, mpg)) + geom_point() + geom_line(aes(y = .fitted)) + geom_ribbon(aes(ymin = .lower, ymax = .upper), col = NA, alpha = 0.3) # predict on new data without outcome variable. Output does not include .resid newdata <- newdata %>% select(-mpg) augment(mod, newdata = newdata) au <- augment(mod, data = mtcars) ggplot(au, aes(.hat, .std.resid)) + geom_vline(size = 2, colour = "white", xintercept = 0) + geom_hline(size = 2, colour = "white", yintercept = 0) + geom_point() + geom_smooth(se = FALSE) plot(mod, which = 6) ggplot(au, aes(.hat, .cooksd)) + geom_vline(xintercept = 0, colour = NA) + geom_abline(slope = seq(0, 3, by = 0.5), colour = "white") + geom_smooth(se = FALSE) + geom_point() # column-wise models a <- matrix(rnorm(20), nrow = 10) b <- a + rnorm(length(a)) result <- lm(b ~ a) tidy(result)
library(ggplot2) library(dplyr) mod <- lm(mpg ~ wt + qsec, data = mtcars) tidy(mod) glance(mod) # coefficient plot d <- tidy(mod, conf.int = TRUE) ggplot(d, aes(estimate, term, xmin = conf.low, xmax = conf.high, height = 0)) + geom_point() + geom_vline(xintercept = 0, lty = 4) + geom_errorbarh() # aside: There are tidy() and glance() methods for lm.summary objects too. # this can be useful when you want to conserve memory by converting large lm # objects into their leaner summary.lm equivalents. s <- summary(mod) tidy(s, conf.int = TRUE) glance(s) augment(mod) augment(mod, mtcars, interval = "confidence") # predict on new data newdata <- mtcars %>% head(6) %>% mutate(wt = wt + 1) augment(mod, newdata = newdata) # ggplot2 example where we also construct 95% prediction interval # simpler bivariate model since we're plotting in 2D mod2 <- lm(mpg ~ wt, data = mtcars) au <- augment(mod2, newdata = newdata, interval = "prediction") ggplot(au, aes(wt, mpg)) + geom_point() + geom_line(aes(y = .fitted)) + geom_ribbon(aes(ymin = .lower, ymax = .upper), col = NA, alpha = 0.3) # predict on new data without outcome variable. Output does not include .resid newdata <- newdata %>% select(-mpg) augment(mod, newdata = newdata) au <- augment(mod, data = mtcars) ggplot(au, aes(.hat, .std.resid)) + geom_vline(size = 2, colour = "white", xintercept = 0) + geom_hline(size = 2, colour = "white", yintercept = 0) + geom_point() + geom_smooth(se = FALSE) plot(mod, which = 6) ggplot(au, aes(.hat, .cooksd)) + geom_vline(xintercept = 0, colour = NA) + geom_abline(slope = seq(0, 3, by = 0.5), colour = "white") + geom_smooth(se = FALSE) + geom_point() # column-wise models a <- matrix(rnorm(20), nrow = 10) b <- a + rnorm(length(a)) result <- lm(b ~ a) tidy(result)
Augment accepts a model object and a dataset and adds
information about each observation in the dataset. Most commonly, this
includes predicted values in the .fitted
column, residuals in the
.resid
column, and standard errors for the fitted values in a .se.fit
column. New columns always begin with a .
prefix to avoid overwriting
columns in the original dataset.
Users may pass data to augment via either the data
argument or the
newdata
argument. If the user passes data to the data
argument,
it must be exactly the data that was used to fit the model
object. Pass datasets to newdata
to augment data that was not used
during model fitting. This still requires that at least all predictor
variable columns used to fit the model are present. If the original outcome
variable used to fit the model is not included in newdata
, then no
.resid
column will be included in the output.
Augment will often behave differently depending on whether data
or
newdata
is given. This is because there is often information
associated with training observations (such as influences or related)
measures that is not meaningfully defined for new observations.
For convenience, many augment methods provide default data
arguments,
so that augment(fit)
will return the augmented training data. In these
cases, augment tries to reconstruct the original data based on the model
object with varying degrees of success.
The augmented dataset is always returned as a tibble::tibble with the
same number of rows as the passed dataset. This means that the passed
data must be coercible to a tibble. If a predictor enters the model as part
of a matrix of covariates, such as when the model formula uses
splines::ns()
, stats::poly()
, or survival::Surv()
, it is represented
as a matrix column.
We are in the process of defining behaviors for models fit with various
na.action
arguments, but make no guarantees about behavior when data is
missing at this time.
## S3 method for class 'lmrob' augment(x, data = model.frame(x), newdata = NULL, se_fit = FALSE, ...)
## S3 method for class 'lmrob' augment(x, data = model.frame(x), newdata = NULL, se_fit = FALSE, ...)
x |
A |
data |
A base::data.frame or |
newdata |
A |
se_fit |
Logical indicating whether or not a |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
For tidiers for robust models from the MASS package see
tidy.rlm()
.
A tibble::tibble()
with columns:
.fitted |
Fitted or predicted value. |
.resid |
The difference between observed and fitted values. |
Other robustbase tidiers:
augment.glmrob()
,
glance.lmrob()
,
tidy.glmrob()
,
tidy.lmrob()
if (requireNamespace("robustbase", quietly = TRUE)) { # load libraries for models and data library(robustbase) data(coleman) set.seed(0) m <- lmrob(Y ~ ., data = coleman) tidy(m) augment(m) glance(m) data(carrots) Rfit <- glmrob(cbind(success, total - success) ~ logdose + block, family = binomial, data = carrots, method = "Mqle", control = glmrobMqle.control(tcc = 1.2) ) tidy(Rfit) augment(Rfit) }
if (requireNamespace("robustbase", quietly = TRUE)) { # load libraries for models and data library(robustbase) data(coleman) set.seed(0) m <- lmrob(Y ~ ., data = coleman) tidy(m) augment(m) glance(m) data(carrots) Rfit <- glmrob(cbind(success, total - success) ~ logdose + block, family = binomial, data = carrots, method = "Mqle", control = glmrobMqle.control(tcc = 1.2) ) tidy(Rfit) augment(Rfit) }
Augment accepts a model object and a dataset and adds
information about each observation in the dataset. Most commonly, this
includes predicted values in the .fitted
column, residuals in the
.resid
column, and standard errors for the fitted values in a .se.fit
column. New columns always begin with a .
prefix to avoid overwriting
columns in the original dataset.
Users may pass data to augment via either the data
argument or the
newdata
argument. If the user passes data to the data
argument,
it must be exactly the data that was used to fit the model
object. Pass datasets to newdata
to augment data that was not used
during model fitting. This still requires that at least all predictor
variable columns used to fit the model are present. If the original outcome
variable used to fit the model is not included in newdata
, then no
.resid
column will be included in the output.
Augment will often behave differently depending on whether data
or
newdata
is given. This is because there is often information
associated with training observations (such as influences or related)
measures that is not meaningfully defined for new observations.
For convenience, many augment methods provide default data
arguments,
so that augment(fit)
will return the augmented training data. In these
cases, augment tries to reconstruct the original data based on the model
object with varying degrees of success.
The augmented dataset is always returned as a tibble::tibble with the
same number of rows as the passed dataset. This means that the passed
data must be coercible to a tibble. If a predictor enters the model as part
of a matrix of covariates, such as when the model formula uses
splines::ns()
, stats::poly()
, or survival::Surv()
, it is represented
as a matrix column.
We are in the process of defining behaviors for models fit with various
na.action
arguments, but make no guarantees about behavior when data is
missing at this time.
## S3 method for class 'lmRob' augment(x, data = model.frame(x), newdata = NULL, ...)
## S3 method for class 'lmRob' augment(x, data = model.frame(x), newdata = NULL, ...)
x |
A |
data |
A base::data.frame or |
newdata |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
For tidiers for robust models from the MASS package see
tidy.rlm()
.
Other robust tidiers:
glance.glmRob()
,
glance.lmRob()
,
tidy.glmRob()
,
tidy.lmRob()
# load modeling library library(robust) # fit model m <- lmRob(mpg ~ wt, data = mtcars) # summarize model fit with tidiers tidy(m) augment(m) glance(m)
# load modeling library library(robust) # fit model m <- lmRob(mpg ~ wt, data = mtcars) # summarize model fit with tidiers tidy(m) augment(m) glance(m)
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'loess' augment(x, data = model.frame(x), newdata = NULL, se_fit = FALSE, ...)
## S3 method for class 'loess' augment(x, data = model.frame(x), newdata = NULL, se_fit = FALSE, ...)
x |
A |
data |
A base::data.frame or |
newdata |
A |
se_fit |
Logical indicating whether or not a |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
When the modeling was performed with na.action = "na.omit"
(as is the typical default), rows with NA in the initial data are omitted
entirely from the augmented data frame. When the modeling was performed
with na.action = "na.exclude"
, one should provide the original data
as a second argument, at which point the augmented data will contain those
rows (typically with NAs in place of the new columns). If the original data
is not provided to augment()
and na.action = "na.exclude"
, a
warning is raised and the incomplete rows are dropped.
Note that loess
objects by default will not predict on data
outside of a bounding hypercube defined by the training data unless the
original loess
object was fit with
control = loess.control(surface = \"direct\"))
. See
stats::predict.loess()
for details.
A tibble::tibble()
with columns:
.fitted |
Fitted or predicted value. |
.resid |
The difference between observed and fitted values. |
.se.fit |
Standard errors of fitted values. |
augment()
, stats::loess()
, stats::predict.loess()
lo <- loess( mpg ~ hp + wt, mtcars, control = loess.control(surface = "direct") ) augment(lo) # with all columns of original data augment(lo, mtcars) # with a new dataset augment(lo, newdata = head(mtcars))
lo <- loess( mpg ~ hp + wt, mtcars, control = loess.control(surface = "direct") ) augment(lo) # with all columns of original data augment(lo, mtcars) # with a new dataset augment(lo, newdata = head(mtcars))
Augment accepts a model object and a dataset and adds
information about each observation in the dataset. Most commonly, this
includes predicted values in the .fitted
column, residuals in the
.resid
column, and standard errors for the fitted values in a .se.fit
column. New columns always begin with a .
prefix to avoid overwriting
columns in the original dataset.
Users may pass data to augment via either the data
argument or the
newdata
argument. If the user passes data to the data
argument,
it must be exactly the data that was used to fit the model
object. Pass datasets to newdata
to augment data that was not used
during model fitting. This still requires that at least all predictor
variable columns used to fit the model are present. If the original outcome
variable used to fit the model is not included in newdata
, then no
.resid
column will be included in the output.
Augment will often behave differently depending on whether data
or
newdata
is given. This is because there is often information
associated with training observations (such as influences or related)
measures that is not meaningfully defined for new observations.
For convenience, many augment methods provide default data
arguments,
so that augment(fit)
will return the augmented training data. In these
cases, augment tries to reconstruct the original data based on the model
object with varying degrees of success.
The augmented dataset is always returned as a tibble::tibble with the
same number of rows as the passed dataset. This means that the passed
data must be coercible to a tibble. If a predictor enters the model as part
of a matrix of covariates, such as when the model formula uses
splines::ns()
, stats::poly()
, or survival::Surv()
, it is represented
as a matrix column.
We are in the process of defining behaviors for models fit with various
na.action
arguments, but make no guarantees about behavior when data is
missing at this time.
## S3 method for class 'Mclust' augment(x, data = NULL, ...)
## S3 method for class 'Mclust' augment(x, data = NULL, ...)
x |
An |
data |
A base::data.frame or |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with columns:
.class |
Predicted class. |
.uncertainty |
The uncertainty associated with the classification. Equal to one minus the model class probability. |
Other mclust tidiers:
tidy.Mclust()
# load library for models and data library(mclust) # load data manipulation libraries library(dplyr) library(tibble) library(purrr) library(tidyr) set.seed(27) centers <- tibble( cluster = factor(1:3), # number points in each cluster num_points = c(100, 150, 50), # x1 coordinate of cluster center x1 = c(5, 0, -3), # x2 coordinate of cluster center x2 = c(-1, 1, -2) ) points <- centers %>% mutate( x1 = map2(num_points, x1, rnorm), x2 = map2(num_points, x2, rnorm) ) %>% select(-num_points, -cluster) %>% unnest(c(x1, x2)) # fit model m <- Mclust(points) # summarize model fit with tidiers tidy(m) augment(m, points) glance(m)
# load library for models and data library(mclust) # load data manipulation libraries library(dplyr) library(tibble) library(purrr) library(tidyr) set.seed(27) centers <- tibble( cluster = factor(1:3), # number points in each cluster num_points = c(100, 150, 50), # x1 coordinate of cluster center x1 = c(5, 0, -3), # x2 coordinate of cluster center x2 = c(-1, 1, -2) ) points <- centers %>% mutate( x1 = map2(num_points, x1, rnorm), x2 = map2(num_points, x2, rnorm) ) %>% select(-num_points, -cluster) %>% unnest(c(x1, x2)) # fit model m <- Mclust(points) # summarize model fit with tidiers tidy(m) augment(m, points) glance(m)
Augment accepts a model object and a dataset and adds
information about each observation in the dataset. Most commonly, this
includes predicted values in the .fitted
column, residuals in the
.resid
column, and standard errors for the fitted values in a .se.fit
column. New columns always begin with a .
prefix to avoid overwriting
columns in the original dataset.
Users may pass data to augment via either the data
argument or the
newdata
argument. If the user passes data to the data
argument,
it must be exactly the data that was used to fit the model
object. Pass datasets to newdata
to augment data that was not used
during model fitting. This still requires that at least all predictor
variable columns used to fit the model are present. If the original outcome
variable used to fit the model is not included in newdata
, then no
.resid
column will be included in the output.
Augment will often behave differently depending on whether data
or
newdata
is given. This is because there is often information
associated with training observations (such as influences or related)
measures that is not meaningfully defined for new observations.
For convenience, many augment methods provide default data
arguments,
so that augment(fit)
will return the augmented training data. In these
cases, augment tries to reconstruct the original data based on the model
object with varying degrees of success.
The augmented dataset is always returned as a tibble::tibble with the
same number of rows as the passed dataset. This means that the passed
data must be coercible to a tibble. If a predictor enters the model as part
of a matrix of covariates, such as when the model formula uses
splines::ns()
, stats::poly()
, or survival::Surv()
, it is represented
as a matrix column.
We are in the process of defining behaviors for models fit with various
na.action
arguments, but make no guarantees about behavior when data is
missing at this time.
## S3 method for class 'mfx' augment( x, data = model.frame(x$fit), newdata = NULL, type.predict = c("link", "response", "terms"), type.residuals = c("deviance", "pearson"), se_fit = FALSE, ... ) ## S3 method for class 'logitmfx' augment( x, data = model.frame(x$fit), newdata = NULL, type.predict = c("link", "response", "terms"), type.residuals = c("deviance", "pearson"), se_fit = FALSE, ... ) ## S3 method for class 'negbinmfx' augment( x, data = model.frame(x$fit), newdata = NULL, type.predict = c("link", "response", "terms"), type.residuals = c("deviance", "pearson"), se_fit = FALSE, ... ) ## S3 method for class 'poissonmfx' augment( x, data = model.frame(x$fit), newdata = NULL, type.predict = c("link", "response", "terms"), type.residuals = c("deviance", "pearson"), se_fit = FALSE, ... ) ## S3 method for class 'probitmfx' augment( x, data = model.frame(x$fit), newdata = NULL, type.predict = c("link", "response", "terms"), type.residuals = c("deviance", "pearson"), se_fit = FALSE, ... )
## S3 method for class 'mfx' augment( x, data = model.frame(x$fit), newdata = NULL, type.predict = c("link", "response", "terms"), type.residuals = c("deviance", "pearson"), se_fit = FALSE, ... ) ## S3 method for class 'logitmfx' augment( x, data = model.frame(x$fit), newdata = NULL, type.predict = c("link", "response", "terms"), type.residuals = c("deviance", "pearson"), se_fit = FALSE, ... ) ## S3 method for class 'negbinmfx' augment( x, data = model.frame(x$fit), newdata = NULL, type.predict = c("link", "response", "terms"), type.residuals = c("deviance", "pearson"), se_fit = FALSE, ... ) ## S3 method for class 'poissonmfx' augment( x, data = model.frame(x$fit), newdata = NULL, type.predict = c("link", "response", "terms"), type.residuals = c("deviance", "pearson"), se_fit = FALSE, ... ) ## S3 method for class 'probitmfx' augment( x, data = model.frame(x$fit), newdata = NULL, type.predict = c("link", "response", "terms"), type.residuals = c("deviance", "pearson"), se_fit = FALSE, ... )
x |
A |
data |
A base::data.frame or |
newdata |
A |
type.predict |
Passed to |
type.residuals |
Passed to |
se_fit |
Logical indicating whether or not a |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
This generic augment method wraps augment.glm()
for applicable
objects from the mfx
package.
A tibble::tibble()
with columns:
.cooksd |
Cooks distance. |
.fitted |
Fitted or predicted value. |
.hat |
Diagonal of the hat matrix. |
.resid |
The difference between observed and fitted values. |
.se.fit |
Standard errors of fitted values. |
.sigma |
Estimated residual standard deviation when corresponding observation is dropped from model. |
.std.resid |
Standardised residuals. |
augment.glm()
, mfx::logitmfx()
, mfx::negbinmfx()
,
mfx::poissonmfx()
, mfx::probitmfx()
Other mfx tidiers:
augment.betamfx()
,
glance.betamfx()
,
glance.mfx()
,
tidy.betamfx()
,
tidy.mfx()
# load libraries for models and data library(mfx) # get the marginal effects from a logit regression mod_logmfx <- logitmfx(am ~ cyl + hp + wt, atmean = TRUE, data = mtcars) tidy(mod_logmfx, conf.int = TRUE) # compare with the naive model coefficients of the same logit call tidy( glm(am ~ cyl + hp + wt, family = binomial, data = mtcars), conf.int = TRUE ) augment(mod_logmfx) glance(mod_logmfx) # another example, this time using probit regression mod_probmfx <- probitmfx(am ~ cyl + hp + wt, atmean = TRUE, data = mtcars) tidy(mod_probmfx, conf.int = TRUE) augment(mod_probmfx) glance(mod_probmfx)
# load libraries for models and data library(mfx) # get the marginal effects from a logit regression mod_logmfx <- logitmfx(am ~ cyl + hp + wt, atmean = TRUE, data = mtcars) tidy(mod_logmfx, conf.int = TRUE) # compare with the naive model coefficients of the same logit call tidy( glm(am ~ cyl + hp + wt, family = binomial, data = mtcars), conf.int = TRUE ) augment(mod_logmfx) glance(mod_logmfx) # another example, this time using probit regression mod_probmfx <- probitmfx(am ~ cyl + hp + wt, atmean = TRUE, data = mtcars) tidy(mod_probmfx, conf.int = TRUE) augment(mod_probmfx) glance(mod_probmfx)
Augment accepts a model object and a dataset and adds
information about each observation in the dataset. Most commonly, this
includes predicted values in the .fitted
column, residuals in the
.resid
column, and standard errors for the fitted values in a .se.fit
column. New columns always begin with a .
prefix to avoid overwriting
columns in the original dataset.
Users may pass data to augment via either the data
argument or the
newdata
argument. If the user passes data to the data
argument,
it must be exactly the data that was used to fit the model
object. Pass datasets to newdata
to augment data that was not used
during model fitting. This still requires that at least all predictor
variable columns used to fit the model are present. If the original outcome
variable used to fit the model is not included in newdata
, then no
.resid
column will be included in the output.
Augment will often behave differently depending on whether data
or
newdata
is given. This is because there is often information
associated with training observations (such as influences or related)
measures that is not meaningfully defined for new observations.
For convenience, many augment methods provide default data
arguments,
so that augment(fit)
will return the augmented training data. In these
cases, augment tries to reconstruct the original data based on the model
object with varying degrees of success.
The augmented dataset is always returned as a tibble::tibble with the
same number of rows as the passed dataset. This means that the passed
data must be coercible to a tibble. If a predictor enters the model as part
of a matrix of covariates, such as when the model formula uses
splines::ns()
, stats::poly()
, or survival::Surv()
, it is represented
as a matrix column.
We are in the process of defining behaviors for models fit with various
na.action
arguments, but make no guarantees about behavior when data is
missing at this time.
## S3 method for class 'mjoint' augment(x, data = x$data, ...)
## S3 method for class 'mjoint' augment(x, data = x$data, ...)
x |
An |
data |
A base::data.frame or |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
See joineRML::fitted.mjoint()
and joineRML::residuals.mjoint()
for
more information on the difference between population-level and
individual-level fitted values and residuals.
If fitting a joint model with a single longitudinal process,
make sure you are using a named list
to define the formula
for the fixed and random effects of the longitudinal submodel.
A tibble::tibble()
with one row for each original observation
with addition columns:
.fitted_j_0 |
population-level fitted values for the j-th longitudinal process |
.fitted_j_1 |
individuals-level fitted values for the j-th longitudinal process |
.resid_j_0 |
population-level residuals for the j-th longitudinal process |
.resid_j_1 |
individual-level residuals for the j-th longitudinal process |
# broom only skips running these examples because the example models take a # while to generate—they should run just fine, though! ## Not run: # load libraries for models and data library(joineRML) # fit a joint model with bivariate longitudinal outcomes data(heart.valve) hvd <- heart.valve[!is.na(heart.valve$log.grad) & !is.na(heart.valve$log.lvmi) & heart.valve$num <= 50, ] fit <- mjoint( formLongFixed = list( "grad" = log.grad ~ time + sex + hs, "lvmi" = log.lvmi ~ time + sex ), formLongRandom = list( "grad" = ~ 1 | num, "lvmi" = ~ time | num ), formSurv = Surv(fuyrs, status) ~ age, data = hvd, inits = list("gamma" = c(0.11, 1.51, 0.80)), timeVar = "time" ) # extract the survival fixed effects tidy(fit) # extract the longitudinal fixed effects tidy(fit, component = "longitudinal") # extract the survival fixed effects with confidence intervals tidy(fit, ci = TRUE) # extract the survival fixed effects with confidence intervals based # on bootstrapped standard errors bSE <- bootSE(fit, nboot = 5, safe.boot = TRUE) tidy(fit, boot_se = bSE, ci = TRUE) # augment original data with fitted longitudinal values and residuals hvd2 <- augment(fit) # extract model statistics glance(fit) ## End(Not run)
# broom only skips running these examples because the example models take a # while to generate—they should run just fine, though! ## Not run: # load libraries for models and data library(joineRML) # fit a joint model with bivariate longitudinal outcomes data(heart.valve) hvd <- heart.valve[!is.na(heart.valve$log.grad) & !is.na(heart.valve$log.lvmi) & heart.valve$num <= 50, ] fit <- mjoint( formLongFixed = list( "grad" = log.grad ~ time + sex + hs, "lvmi" = log.lvmi ~ time + sex ), formLongRandom = list( "grad" = ~ 1 | num, "lvmi" = ~ time | num ), formSurv = Surv(fuyrs, status) ~ age, data = hvd, inits = list("gamma" = c(0.11, 1.51, 0.80)), timeVar = "time" ) # extract the survival fixed effects tidy(fit) # extract the longitudinal fixed effects tidy(fit, component = "longitudinal") # extract the survival fixed effects with confidence intervals tidy(fit, ci = TRUE) # extract the survival fixed effects with confidence intervals based # on bootstrapped standard errors bSE <- bootSE(fit, nboot = 5, safe.boot = TRUE) tidy(fit, boot_se = bSE, ci = TRUE) # augment original data with fitted longitudinal values and residuals hvd2 <- augment(fit) # extract model statistics glance(fit) ## End(Not run)
Augment accepts a model object and a dataset and adds
information about each observation in the dataset. Most commonly, this
includes predicted values in the .fitted
column, residuals in the
.resid
column, and standard errors for the fitted values in a .se.fit
column. New columns always begin with a .
prefix to avoid overwriting
columns in the original dataset.
Users may pass data to augment via either the data
argument or the
newdata
argument. If the user passes data to the data
argument,
it must be exactly the data that was used to fit the model
object. Pass datasets to newdata
to augment data that was not used
during model fitting. This still requires that at least all predictor
variable columns used to fit the model are present. If the original outcome
variable used to fit the model is not included in newdata
, then no
.resid
column will be included in the output.
Augment will often behave differently depending on whether data
or
newdata
is given. This is because there is often information
associated with training observations (such as influences or related)
measures that is not meaningfully defined for new observations.
For convenience, many augment methods provide default data
arguments,
so that augment(fit)
will return the augmented training data. In these
cases, augment tries to reconstruct the original data based on the model
object with varying degrees of success.
The augmented dataset is always returned as a tibble::tibble with the
same number of rows as the passed dataset. This means that the passed
data must be coercible to a tibble. If a predictor enters the model as part
of a matrix of covariates, such as when the model formula uses
splines::ns()
, stats::poly()
, or survival::Surv()
, it is represented
as a matrix column.
We are in the process of defining behaviors for models fit with various
na.action
arguments, but make no guarantees about behavior when data is
missing at this time.
## S3 method for class 'mlogit' augment(x, data = x$model, ...)
## S3 method for class 'mlogit' augment(x, data = x$model, ...)
x |
an object returned from |
data |
Not currently used |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
At the moment this only works on the estimation dataset. Need to set it up to predict on another dataset.
A tibble::tibble()
with columns:
.fitted |
Fitted or predicted value. |
.probability |
Class probability of modal class. |
.resid |
The difference between observed and fitted values. |
Other mlogit tidiers:
glance.mlogit()
,
tidy.mlogit()
# load libraries for models and data library(mlogit) data("Fishing", package = "mlogit") Fish <- dfidx(Fishing, varying = 2:9, shape = "wide", choice = "mode") # fit model m <- mlogit(mode ~ price + catch | income, data = Fish) # summarize model fit with tidiers tidy(m) augment(m) glance(m)
# load libraries for models and data library(mlogit) data("Fishing", package = "mlogit") Fish <- dfidx(Fishing, varying = 2:9, shape = "wide", choice = "mode") # fit model m <- mlogit(mode ~ price + catch | income, data = Fish) # summarize model fit with tidiers tidy(m) augment(m) glance(m)
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'nlrq' augment(x, data = NULL, newdata = NULL, ...)
## S3 method for class 'nlrq' augment(x, data = NULL, newdata = NULL, ...)
x |
A |
data |
A base::data.frame or |
newdata |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Other quantreg tidiers:
augment.rq()
,
augment.rqs()
,
glance.nlrq()
,
glance.rq()
,
tidy.nlrq()
,
tidy.rq()
,
tidy.rqs()
# fit model n <- nls(mpg ~ k * e^wt, data = mtcars, start = list(k = 1, e = 2)) # summarize model fit with tidiers + visualization tidy(n) augment(n) glance(n) library(ggplot2) ggplot(augment(n), aes(wt, mpg)) + geom_point() + geom_line(aes(y = .fitted)) newdata <- head(mtcars) newdata$wt <- newdata$wt + 1 augment(n, newdata = newdata)
# fit model n <- nls(mpg ~ k * e^wt, data = mtcars, start = list(k = 1, e = 2)) # summarize model fit with tidiers + visualization tidy(n) augment(n) glance(n) library(ggplot2) ggplot(augment(n), aes(wt, mpg)) + geom_point() + geom_line(aes(y = .fitted)) newdata <- head(mtcars) newdata$wt <- newdata$wt + 1 augment(n, newdata = newdata)
Augment accepts a model object and a dataset and adds
information about each observation in the dataset. Most commonly, this
includes predicted values in the .fitted
column, residuals in the
.resid
column, and standard errors for the fitted values in a .se.fit
column. New columns always begin with a .
prefix to avoid overwriting
columns in the original dataset.
Users may pass data to augment via either the data
argument or the
newdata
argument. If the user passes data to the data
argument,
it must be exactly the data that was used to fit the model
object. Pass datasets to newdata
to augment data that was not used
during model fitting. This still requires that at least all predictor
variable columns used to fit the model are present. If the original outcome
variable used to fit the model is not included in newdata
, then no
.resid
column will be included in the output.
Augment will often behave differently depending on whether data
or
newdata
is given. This is because there is often information
associated with training observations (such as influences or related)
measures that is not meaningfully defined for new observations.
For convenience, many augment methods provide default data
arguments,
so that augment(fit)
will return the augmented training data. In these
cases, augment tries to reconstruct the original data based on the model
object with varying degrees of success.
The augmented dataset is always returned as a tibble::tibble with the
same number of rows as the passed dataset. This means that the passed
data must be coercible to a tibble. If a predictor enters the model as part
of a matrix of covariates, such as when the model formula uses
splines::ns()
, stats::poly()
, or survival::Surv()
, it is represented
as a matrix column.
We are in the process of defining behaviors for models fit with various
na.action
arguments, but make no guarantees about behavior when data is
missing at this time.
## S3 method for class 'nls' augment(x, data = NULL, newdata = NULL, ...)
## S3 method for class 'nls' augment(x, data = NULL, newdata = NULL, ...)
x |
An |
data |
A base::data.frame or |
newdata |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
augment.nls does not currently support confidence intervals due to a lack of support in stats::predict.nls().
A tibble::tibble()
with columns:
.fitted |
Fitted or predicted value. |
.resid |
The difference between observed and fitted values. |
tidy, stats::nls()
, stats::predict.nls()
Other nls tidiers:
glance.nls()
,
tidy.nls()
# fit model n <- nls(mpg ~ k * e^wt, data = mtcars, start = list(k = 1, e = 2)) # summarize model fit with tidiers + visualization tidy(n) augment(n) glance(n) library(ggplot2) ggplot(augment(n), aes(wt, mpg)) + geom_point() + geom_line(aes(y = .fitted)) newdata <- head(mtcars) newdata$wt <- newdata$wt + 1 augment(n, newdata = newdata)
# fit model n <- nls(mpg ~ k * e^wt, data = mtcars, start = list(k = 1, e = 2)) # summarize model fit with tidiers + visualization tidy(n) augment(n) glance(n) library(ggplot2) ggplot(augment(n), aes(wt, mpg)) + geom_point() + geom_line(aes(y = .fitted)) newdata <- head(mtcars) newdata$wt <- newdata$wt + 1 augment(n, newdata = newdata)
Augment accepts a model object and a dataset and adds
information about each observation in the dataset. Most commonly, this
includes predicted values in the .fitted
column, residuals in the
.resid
column, and standard errors for the fitted values in a .se.fit
column. New columns always begin with a .
prefix to avoid overwriting
columns in the original dataset.
Users may pass data to augment via either the data
argument or the
newdata
argument. If the user passes data to the data
argument,
it must be exactly the data that was used to fit the model
object. Pass datasets to newdata
to augment data that was not used
during model fitting. This still requires that at least all predictor
variable columns used to fit the model are present. If the original outcome
variable used to fit the model is not included in newdata
, then no
.resid
column will be included in the output.
Augment will often behave differently depending on whether data
or
newdata
is given. This is because there is often information
associated with training observations (such as influences or related)
measures that is not meaningfully defined for new observations.
For convenience, many augment methods provide default data
arguments,
so that augment(fit)
will return the augmented training data. In these
cases, augment tries to reconstruct the original data based on the model
object with varying degrees of success.
The augmented dataset is always returned as a tibble::tibble with the
same number of rows as the passed dataset. This means that the passed
data must be coercible to a tibble. If a predictor enters the model as part
of a matrix of covariates, such as when the model formula uses
splines::ns()
, stats::poly()
, or survival::Surv()
, it is represented
as a matrix column.
We are in the process of defining behaviors for models fit with various
na.action
arguments, but make no guarantees about behavior when data is
missing at this time.
## S3 method for class 'pam' augment(x, data = NULL, ...)
## S3 method for class 'pam' augment(x, data = NULL, ...)
x |
An |
data |
A base::data.frame or |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with columns:
.cluster |
Cluster assignment. |
.fitted |
Fitted or predicted value. |
.resid |
The difference between observed and fitted values. |
Other pam tidiers:
glance.pam()
,
tidy.pam()
# load libraries for models and data library(dplyr) library(ggplot2) library(cluster) library(modeldata) data(hpc_data) x <- hpc_data[, 2:5] p <- pam(x, k = 4) # summarize model fit with tidiers + visualization tidy(p) glance(p) augment(p, x) augment(p, x) %>% ggplot(aes(compounds, input_fields)) + geom_point(aes(color = .cluster)) + geom_text(aes(label = cluster), data = tidy(p), size = 10)
# load libraries for models and data library(dplyr) library(ggplot2) library(cluster) library(modeldata) data(hpc_data) x <- hpc_data[, 2:5] p <- pam(x, k = 4) # summarize model fit with tidiers + visualization tidy(p) glance(p) augment(p, x) augment(p, x) %>% ggplot(aes(compounds, input_fields)) + geom_point(aes(color = .cluster)) + geom_text(aes(label = cluster), data = tidy(p), size = 10)
Augment accepts a model object and a dataset and adds
information about each observation in the dataset. Most commonly, this
includes predicted values in the .fitted
column, residuals in the
.resid
column, and standard errors for the fitted values in a .se.fit
column. New columns always begin with a .
prefix to avoid overwriting
columns in the original dataset.
Users may pass data to augment via either the data
argument or the
newdata
argument. If the user passes data to the data
argument,
it must be exactly the data that was used to fit the model
object. Pass datasets to newdata
to augment data that was not used
during model fitting. This still requires that at least all predictor
variable columns used to fit the model are present. If the original outcome
variable used to fit the model is not included in newdata
, then no
.resid
column will be included in the output.
Augment will often behave differently depending on whether data
or
newdata
is given. This is because there is often information
associated with training observations (such as influences or related)
measures that is not meaningfully defined for new observations.
For convenience, many augment methods provide default data
arguments,
so that augment(fit)
will return the augmented training data. In these
cases, augment tries to reconstruct the original data based on the model
object with varying degrees of success.
The augmented dataset is always returned as a tibble::tibble with the
same number of rows as the passed dataset. This means that the passed
data must be coercible to a tibble. If a predictor enters the model as part
of a matrix of covariates, such as when the model formula uses
splines::ns()
, stats::poly()
, or survival::Surv()
, it is represented
as a matrix column.
We are in the process of defining behaviors for models fit with various
na.action
arguments, but make no guarantees about behavior when data is
missing at this time.
## S3 method for class 'plm' augment(x, data = model.frame(x), ...)
## S3 method for class 'plm' augment(x, data = model.frame(x), ...)
x |
A |
data |
A base::data.frame or |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with columns:
.fitted |
Fitted or predicted value. |
.resid |
The difference between observed and fitted values. |
Other plm tidiers:
glance.plm()
,
tidy.plm()
# load libraries for models and data library(plm) # load data data("Produc", package = "plm") # fit model zz <- plm(log(gsp) ~ log(pcap) + log(pc) + log(emp) + unemp, data = Produc, index = c("state", "year") ) # summarize model fit with tidiers summary(zz) tidy(zz) tidy(zz, conf.int = TRUE) tidy(zz, conf.int = TRUE, conf.level = 0.9) augment(zz) glance(zz)
# load libraries for models and data library(plm) # load data data("Produc", package = "plm") # fit model zz <- plm(log(gsp) ~ log(pcap) + log(pc) + log(emp) + unemp, data = Produc, index = c("state", "year") ) # summarize model fit with tidiers summary(zz) tidy(zz) tidy(zz, conf.int = TRUE) tidy(zz, conf.int = TRUE, conf.level = 0.9) augment(zz) glance(zz)
Augment accepts a model object and a dataset and adds
information about each observation in the dataset. Most commonly, this
includes predicted values in the .fitted
column, residuals in the
.resid
column, and standard errors for the fitted values in a .se.fit
column. New columns always begin with a .
prefix to avoid overwriting
columns in the original dataset.
Users may pass data to augment via either the data
argument or the
newdata
argument. If the user passes data to the data
argument,
it must be exactly the data that was used to fit the model
object. Pass datasets to newdata
to augment data that was not used
during model fitting. This still requires that at least all predictor
variable columns used to fit the model are present. If the original outcome
variable used to fit the model is not included in newdata
, then no
.resid
column will be included in the output.
Augment will often behave differently depending on whether data
or
newdata
is given. This is because there is often information
associated with training observations (such as influences or related)
measures that is not meaningfully defined for new observations.
For convenience, many augment methods provide default data
arguments,
so that augment(fit)
will return the augmented training data. In these
cases, augment tries to reconstruct the original data based on the model
object with varying degrees of success.
The augmented dataset is always returned as a tibble::tibble with the
same number of rows as the passed dataset. This means that the passed
data must be coercible to a tibble. If a predictor enters the model as part
of a matrix of covariates, such as when the model formula uses
splines::ns()
, stats::poly()
, or survival::Surv()
, it is represented
as a matrix column.
We are in the process of defining behaviors for models fit with various
na.action
arguments, but make no guarantees about behavior when data is
missing at this time.
## S3 method for class 'poLCA' augment(x, data = NULL, ...)
## S3 method for class 'poLCA' augment(x, data = NULL, ...)
x |
A |
data |
A base::data.frame or |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
If the data
argument is given, those columns are included in
the output (only rows for which predictions could be made).
Otherwise, the y
element of the poLCA object, which contains the
manifest variables used to fit the model, are used, along with any
covariates, if present, in x
.
Note that while the probability of all the classes (not just the predicted
modal class) can be found in the posterior
element, these are not
included in the augmented output.
A tibble::tibble()
with columns:
.class |
Predicted class. |
.probability |
Class probability of modal class. |
Other poLCA tidiers:
glance.poLCA()
,
tidy.poLCA()
# load libraries for models and data library(poLCA) library(dplyr) # generate data data(values) f <- cbind(A, B, C, D) ~ 1 # fit model M1 <- poLCA(f, values, nclass = 2, verbose = FALSE) M1 # summarize model fit with tidiers + visualization tidy(M1) augment(M1) glance(M1) library(ggplot2) ggplot(tidy(M1), aes(factor(class), estimate, fill = factor(outcome))) + geom_bar(stat = "identity", width = 1) + facet_wrap(~variable) # three-class model with a single covariate. data(election) f2a <- cbind( MORALG, CARESG, KNOWG, LEADG, DISHONG, INTELG, MORALB, CARESB, KNOWB, LEADB, DISHONB, INTELB ) ~ PARTY nes2a <- poLCA(f2a, election, nclass = 3, nrep = 5, verbose = FALSE) td <- tidy(nes2a) td ggplot(td, aes(outcome, estimate, color = factor(class), group = class)) + geom_line() + facet_wrap(~variable, nrow = 2) + theme(axis.text.x = element_text(angle = 90, hjust = 1)) au <- augment(nes2a) au count(au, .class) # if the original data is provided, it leads to NAs in new columns # for rows that weren't predicted au2 <- augment(nes2a, data = election) au2 dim(au2)
# load libraries for models and data library(poLCA) library(dplyr) # generate data data(values) f <- cbind(A, B, C, D) ~ 1 # fit model M1 <- poLCA(f, values, nclass = 2, verbose = FALSE) M1 # summarize model fit with tidiers + visualization tidy(M1) augment(M1) glance(M1) library(ggplot2) ggplot(tidy(M1), aes(factor(class), estimate, fill = factor(outcome))) + geom_bar(stat = "identity", width = 1) + facet_wrap(~variable) # three-class model with a single covariate. data(election) f2a <- cbind( MORALG, CARESG, KNOWG, LEADG, DISHONG, INTELG, MORALB, CARESB, KNOWB, LEADB, DISHONB, INTELB ) ~ PARTY nes2a <- poLCA(f2a, election, nclass = 3, nrep = 5, verbose = FALSE) td <- tidy(nes2a) td ggplot(td, aes(outcome, estimate, color = factor(class), group = class)) + geom_line() + facet_wrap(~variable, nrow = 2) + theme(axis.text.x = element_text(angle = 90, hjust = 1)) au <- augment(nes2a) au count(au, .class) # if the original data is provided, it leads to NAs in new columns # for rows that weren't predicted au2 <- augment(nes2a, data = election) au2 dim(au2)
Augment accepts a model object and a dataset and adds
information about each observation in the dataset. Most commonly, this
includes predicted values in the .fitted
column, residuals in the
.resid
column, and standard errors for the fitted values in a .se.fit
column. New columns always begin with a .
prefix to avoid overwriting
columns in the original dataset.
Users may pass data to augment via either the data
argument or the
newdata
argument. If the user passes data to the data
argument,
it must be exactly the data that was used to fit the model
object. Pass datasets to newdata
to augment data that was not used
during model fitting. This still requires that at least all predictor
variable columns used to fit the model are present. If the original outcome
variable used to fit the model is not included in newdata
, then no
.resid
column will be included in the output.
Augment will often behave differently depending on whether data
or
newdata
is given. This is because there is often information
associated with training observations (such as influences or related)
measures that is not meaningfully defined for new observations.
For convenience, many augment methods provide default data
arguments,
so that augment(fit)
will return the augmented training data. In these
cases, augment tries to reconstruct the original data based on the model
object with varying degrees of success.
The augmented dataset is always returned as a tibble::tibble with the
same number of rows as the passed dataset. This means that the passed
data must be coercible to a tibble. If a predictor enters the model as part
of a matrix of covariates, such as when the model formula uses
splines::ns()
, stats::poly()
, or survival::Surv()
, it is represented
as a matrix column.
We are in the process of defining behaviors for models fit with various
na.action
arguments, but make no guarantees about behavior when data is
missing at this time.
## S3 method for class 'polr' augment( x, data = model.frame(x), newdata = NULL, type.predict = c("class"), ... )
## S3 method for class 'polr' augment( x, data = model.frame(x), newdata = NULL, type.predict = c("class"), ... )
x |
A |
data |
A base::data.frame or |
newdata |
A |
type.predict |
Which type of prediction to compute,
passed to |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Other ordinal tidiers:
augment.clm()
,
glance.clm()
,
glance.clmm()
,
glance.polr()
,
glance.svyolr()
,
tidy.clm()
,
tidy.clmm()
,
tidy.polr()
,
tidy.svyolr()
# load libraries for models and data library(MASS) # fit model fit <- polr(Sat ~ Infl + Type + Cont, weights = Freq, data = housing) # summarize model fit with tidiers tidy(fit, exponentiate = TRUE, conf.int = TRUE) glance(fit) augment(fit, type.predict = "class") fit2 <- polr(factor(gear) ~ am + mpg + qsec, data = mtcars) tidy(fit, p.values = TRUE)
# load libraries for models and data library(MASS) # fit model fit <- polr(Sat ~ Infl + Type + Cont, weights = Freq, data = housing) # summarize model fit with tidiers tidy(fit, exponentiate = TRUE, conf.int = TRUE) glance(fit) augment(fit, type.predict = "class") fit2 <- polr(factor(gear) ~ am + mpg + qsec, data = mtcars) tidy(fit, p.values = TRUE)
Augment accepts a model object and a dataset and adds
information about each observation in the dataset. Most commonly, this
includes predicted values in the .fitted
column, residuals in the
.resid
column, and standard errors for the fitted values in a .se.fit
column. New columns always begin with a .
prefix to avoid overwriting
columns in the original dataset.
Users may pass data to augment via either the data
argument or the
newdata
argument. If the user passes data to the data
argument,
it must be exactly the data that was used to fit the model
object. Pass datasets to newdata
to augment data that was not used
during model fitting. This still requires that at least all predictor
variable columns used to fit the model are present. If the original outcome
variable used to fit the model is not included in newdata
, then no
.resid
column will be included in the output.
Augment will often behave differently depending on whether data
or
newdata
is given. This is because there is often information
associated with training observations (such as influences or related)
measures that is not meaningfully defined for new observations.
For convenience, many augment methods provide default data
arguments,
so that augment(fit)
will return the augmented training data. In these
cases, augment tries to reconstruct the original data based on the model
object with varying degrees of success.
The augmented dataset is always returned as a tibble::tibble with the
same number of rows as the passed dataset. This means that the passed
data must be coercible to a tibble. If a predictor enters the model as part
of a matrix of covariates, such as when the model formula uses
splines::ns()
, stats::poly()
, or survival::Surv()
, it is represented
as a matrix column.
We are in the process of defining behaviors for models fit with various
na.action
arguments, but make no guarantees about behavior when data is
missing at this time.
## S3 method for class 'prcomp' augment(x, data = NULL, newdata, ...)
## S3 method for class 'prcomp' augment(x, data = NULL, newdata, ...)
x |
A |
data |
A base::data.frame or |
newdata |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble containing the original data along with additional columns containing each observation's projection into PCA space.
Other svd tidiers:
tidy.prcomp()
,
tidy_irlba()
,
tidy_svd()
Augment accepts a model object and a dataset and adds
information about each observation in the dataset. Most commonly, this
includes predicted values in the .fitted
column, residuals in the
.resid
column, and standard errors for the fitted values in a .se.fit
column. New columns always begin with a .
prefix to avoid overwriting
columns in the original dataset.
Users may pass data to augment via either the data
argument or the
newdata
argument. If the user passes data to the data
argument,
it must be exactly the data that was used to fit the model
object. Pass datasets to newdata
to augment data that was not used
during model fitting. This still requires that at least all predictor
variable columns used to fit the model are present. If the original outcome
variable used to fit the model is not included in newdata
, then no
.resid
column will be included in the output.
Augment will often behave differently depending on whether data
or
newdata
is given. This is because there is often information
associated with training observations (such as influences or related)
measures that is not meaningfully defined for new observations.
For convenience, many augment methods provide default data
arguments,
so that augment(fit)
will return the augmented training data. In these
cases, augment tries to reconstruct the original data based on the model
object with varying degrees of success.
The augmented dataset is always returned as a tibble::tibble with the
same number of rows as the passed dataset. This means that the passed
data must be coercible to a tibble. If a predictor enters the model as part
of a matrix of covariates, such as when the model formula uses
splines::ns()
, stats::poly()
, or survival::Surv()
, it is represented
as a matrix column.
We are in the process of defining behaviors for models fit with various
na.action
arguments, but make no guarantees about behavior when data is
missing at this time.
## S3 method for class 'rlm' augment(x, data = model.frame(x), newdata = NULL, se_fit = FALSE, ...)
## S3 method for class 'rlm' augment(x, data = model.frame(x), newdata = NULL, se_fit = FALSE, ...)
x |
An |
data |
A base::data.frame or |
newdata |
A |
se_fit |
Logical indicating whether or not a |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with columns:
.fitted |
Fitted or predicted value. |
.hat |
Diagonal of the hat matrix. |
.resid |
The difference between observed and fitted values. |
.se.fit |
Standard errors of fitted values. |
.sigma |
Estimated residual standard deviation when corresponding observation is dropped from model. |
Other rlm tidiers:
glance.rlm()
,
tidy.rlm()
# load libraries for models and data library(MASS) # fit model r <- rlm(stack.loss ~ ., stackloss) # summarize model fit with tidiers tidy(r) augment(r) glance(r)
# load libraries for models and data library(MASS) # fit model r <- rlm(stack.loss ~ ., stackloss) # summarize model fit with tidiers tidy(r) augment(r) glance(r)
Augment accepts a model object and a dataset and adds
information about each observation in the dataset. Most commonly, this
includes predicted values in the .fitted
column, residuals in the
.resid
column, and standard errors for the fitted values in a .se.fit
column. New columns always begin with a .
prefix to avoid overwriting
columns in the original dataset.
Users may pass data to augment via either the data
argument or the
newdata
argument. If the user passes data to the data
argument,
it must be exactly the data that was used to fit the model
object. Pass datasets to newdata
to augment data that was not used
during model fitting. This still requires that at least all predictor
variable columns used to fit the model are present. If the original outcome
variable used to fit the model is not included in newdata
, then no
.resid
column will be included in the output.
Augment will often behave differently depending on whether data
or
newdata
is given. This is because there is often information
associated with training observations (such as influences or related)
measures that is not meaningfully defined for new observations.
For convenience, many augment methods provide default data
arguments,
so that augment(fit)
will return the augmented training data. In these
cases, augment tries to reconstruct the original data based on the model
object with varying degrees of success.
The augmented dataset is always returned as a tibble::tibble with the
same number of rows as the passed dataset. This means that the passed
data must be coercible to a tibble. If a predictor enters the model as part
of a matrix of covariates, such as when the model formula uses
splines::ns()
, stats::poly()
, or survival::Surv()
, it is represented
as a matrix column.
We are in the process of defining behaviors for models fit with various
na.action
arguments, but make no guarantees about behavior when data is
missing at this time.
## S3 method for class 'rma' augment(x, interval = c("prediction", "confidence"), ...)
## S3 method for class 'rma' augment(x, interval = c("prediction", "confidence"), ...)
x |
An |
interval |
For |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with columns:
.fitted |
Fitted or predicted value. |
.lower |
Lower bound on interval for fitted values. |
.moderator |
In meta-analysis, the moderators used to calculate the predicted values. |
.moderator.level |
In meta-analysis, the level of the moderators used to calculate the predicted values. |
.resid |
The difference between observed and fitted values. |
.se.fit |
Standard errors of fitted values. |
.upper |
Upper bound on interval for fitted values. |
.observed |
The observed values for the individual studies |
# load modeling library library(metafor) # generate data and fit df <- escalc( measure = "RR", ai = tpos, bi = tneg, ci = cpos, di = cneg, data = dat.bcg ) meta_analysis <- rma(yi, vi, data = df, method = "EB") # summarize model fit with tidiers augment(meta_analysis)
# load modeling library library(metafor) # generate data and fit df <- escalc( measure = "RR", ai = tpos, bi = tneg, ci = cpos, di = cneg, data = dat.bcg ) meta_analysis <- rma(yi, vi, data = df, method = "EB") # summarize model fit with tidiers augment(meta_analysis)
Augment accepts a model object and a dataset and adds
information about each observation in the dataset. Most commonly, this
includes predicted values in the .fitted
column, residuals in the
.resid
column, and standard errors for the fitted values in a .se.fit
column. New columns always begin with a .
prefix to avoid overwriting
columns in the original dataset.
Users may pass data to augment via either the data
argument or the
newdata
argument. If the user passes data to the data
argument,
it must be exactly the data that was used to fit the model
object. Pass datasets to newdata
to augment data that was not used
during model fitting. This still requires that at least all predictor
variable columns used to fit the model are present. If the original outcome
variable used to fit the model is not included in newdata
, then no
.resid
column will be included in the output.
Augment will often behave differently depending on whether data
or
newdata
is given. This is because there is often information
associated with training observations (such as influences or related)
measures that is not meaningfully defined for new observations.
For convenience, many augment methods provide default data
arguments,
so that augment(fit)
will return the augmented training data. In these
cases, augment tries to reconstruct the original data based on the model
object with varying degrees of success.
The augmented dataset is always returned as a tibble::tibble with the
same number of rows as the passed dataset. This means that the passed
data must be coercible to a tibble. If a predictor enters the model as part
of a matrix of covariates, such as when the model formula uses
splines::ns()
, stats::poly()
, or survival::Surv()
, it is represented
as a matrix column.
We are in the process of defining behaviors for models fit with various
na.action
arguments, but make no guarantees about behavior when data is
missing at this time.
## S3 method for class 'rq' augment(x, data = model.frame(x), newdata = NULL, ...)
## S3 method for class 'rq' augment(x, data = model.frame(x), newdata = NULL, ...)
x |
An |
data |
A base::data.frame or |
newdata |
A |
... |
Arguments passed on to
|
Depending on the arguments passed on to predict.rq
via ...
,
a confidence interval is also calculated on the fitted values resulting in
columns .lower
and .upper
. Does not provide confidence
intervals when data is specified via the newdata
argument.
A tibble::tibble()
with columns:
.fitted |
Fitted or predicted value. |
.resid |
The difference between observed and fitted values. |
.tau |
Quantile. |
augment, quantreg::rq()
, quantreg::predict.rq()
Other quantreg tidiers:
augment.nlrq()
,
augment.rqs()
,
glance.nlrq()
,
glance.rq()
,
tidy.nlrq()
,
tidy.rq()
,
tidy.rqs()
# load modeling library and data library(quantreg) data(stackloss) # median (l1) regression fit for the stackloss data. mod1 <- rq(stack.loss ~ stack.x, .5) # weighted sample median mod2 <- rq(rnorm(50) ~ 1, weights = runif(50)) # summarize model fit with tidiers tidy(mod1) glance(mod1) augment(mod1) tidy(mod2) glance(mod2) augment(mod2) # varying tau to generate an rqs object mod3 <- rq(stack.loss ~ stack.x, tau = c(.25, .5)) tidy(mod3) augment(mod3) # glance cannot handle rqs objects like `mod3`--use a purrr # `map`-based workflow instead
# load modeling library and data library(quantreg) data(stackloss) # median (l1) regression fit for the stackloss data. mod1 <- rq(stack.loss ~ stack.x, .5) # weighted sample median mod2 <- rq(rnorm(50) ~ 1, weights = runif(50)) # summarize model fit with tidiers tidy(mod1) glance(mod1) augment(mod1) tidy(mod2) glance(mod2) augment(mod2) # varying tau to generate an rqs object mod3 <- rq(stack.loss ~ stack.x, tau = c(.25, .5)) tidy(mod3) augment(mod3) # glance cannot handle rqs objects like `mod3`--use a purrr # `map`-based workflow instead
Augment accepts a model object and a dataset and adds
information about each observation in the dataset. Most commonly, this
includes predicted values in the .fitted
column, residuals in the
.resid
column, and standard errors for the fitted values in a .se.fit
column. New columns always begin with a .
prefix to avoid overwriting
columns in the original dataset.
Users may pass data to augment via either the data
argument or the
newdata
argument. If the user passes data to the data
argument,
it must be exactly the data that was used to fit the model
object. Pass datasets to newdata
to augment data that was not used
during model fitting. This still requires that at least all predictor
variable columns used to fit the model are present. If the original outcome
variable used to fit the model is not included in newdata
, then no
.resid
column will be included in the output.
Augment will often behave differently depending on whether data
or
newdata
is given. This is because there is often information
associated with training observations (such as influences or related)
measures that is not meaningfully defined for new observations.
For convenience, many augment methods provide default data
arguments,
so that augment(fit)
will return the augmented training data. In these
cases, augment tries to reconstruct the original data based on the model
object with varying degrees of success.
The augmented dataset is always returned as a tibble::tibble with the
same number of rows as the passed dataset. This means that the passed
data must be coercible to a tibble. If a predictor enters the model as part
of a matrix of covariates, such as when the model formula uses
splines::ns()
, stats::poly()
, or survival::Surv()
, it is represented
as a matrix column.
We are in the process of defining behaviors for models fit with various
na.action
arguments, but make no guarantees about behavior when data is
missing at this time.
## S3 method for class 'rqs' augment(x, data = model.frame(x), newdata, ...)
## S3 method for class 'rqs' augment(x, data = model.frame(x), newdata, ...)
x |
An |
data |
A base::data.frame or |
newdata |
A |
... |
Arguments passed on to
|
Depending on the arguments passed on to predict.rq
via ...
,
a confidence interval is also calculated on the fitted values resulting in
columns .lower
and .upper
. Does not provide confidence
intervals when data is specified via the newdata
argument.
augment, quantreg::rq()
, quantreg::predict.rqs()
Other quantreg tidiers:
augment.nlrq()
,
augment.rq()
,
glance.nlrq()
,
glance.rq()
,
tidy.nlrq()
,
tidy.rq()
,
tidy.rqs()
# load modeling library and data library(quantreg) data(stackloss) # median (l1) regression fit for the stackloss data. mod1 <- rq(stack.loss ~ stack.x, .5) # weighted sample median mod2 <- rq(rnorm(50) ~ 1, weights = runif(50)) # summarize model fit with tidiers tidy(mod1) glance(mod1) augment(mod1) tidy(mod2) glance(mod2) augment(mod2) # varying tau to generate an rqs object mod3 <- rq(stack.loss ~ stack.x, tau = c(.25, .5)) tidy(mod3) augment(mod3) # glance cannot handle rqs objects like `mod3`--use a purrr # `map`-based workflow instead
# load modeling library and data library(quantreg) data(stackloss) # median (l1) regression fit for the stackloss data. mod1 <- rq(stack.loss ~ stack.x, .5) # weighted sample median mod2 <- rq(rnorm(50) ~ 1, weights = runif(50)) # summarize model fit with tidiers tidy(mod1) glance(mod1) augment(mod1) tidy(mod2) glance(mod2) augment(mod2) # varying tau to generate an rqs object mod3 <- rq(stack.loss ~ stack.x, tau = c(.25, .5)) tidy(mod3) augment(mod3) # glance cannot handle rqs objects like `mod3`--use a purrr # `map`-based workflow instead
Augment accepts a model object and a dataset and adds
information about each observation in the dataset. Most commonly, this
includes predicted values in the .fitted
column, residuals in the
.resid
column, and standard errors for the fitted values in a .se.fit
column. New columns always begin with a .
prefix to avoid overwriting
columns in the original dataset.
Users may pass data to augment via either the data
argument or the
newdata
argument. If the user passes data to the data
argument,
it must be exactly the data that was used to fit the model
object. Pass datasets to newdata
to augment data that was not used
during model fitting. This still requires that at least all predictor
variable columns used to fit the model are present. If the original outcome
variable used to fit the model is not included in newdata
, then no
.resid
column will be included in the output.
Augment will often behave differently depending on whether data
or
newdata
is given. This is because there is often information
associated with training observations (such as influences or related)
measures that is not meaningfully defined for new observations.
For convenience, many augment methods provide default data
arguments,
so that augment(fit)
will return the augmented training data. In these
cases, augment tries to reconstruct the original data based on the model
object with varying degrees of success.
The augmented dataset is always returned as a tibble::tibble with the
same number of rows as the passed dataset. This means that the passed
data must be coercible to a tibble. If a predictor enters the model as part
of a matrix of covariates, such as when the model formula uses
splines::ns()
, stats::poly()
, or survival::Surv()
, it is represented
as a matrix column.
We are in the process of defining behaviors for models fit with various
na.action
arguments, but make no guarantees about behavior when data is
missing at this time.
## S3 method for class 'sarlm' augment(x, data = x$X, ...)
## S3 method for class 'sarlm' augment(x, data = x$X, ...)
x |
An object returned from |
data |
Ignored, but included for internal consistency. See the details below. |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
The predict method for sarlm objects assumes that the response is
known. See ?predict.sarlm for more discussion. As a result, since the
original data can be recovered from the fit object, this method
currently does not take in data
or newdata
arguments.
A tibble::tibble()
with columns:
.fitted |
Fitted or predicted value. |
.resid |
The difference between observed and fitted values. |
Other spatialreg tidiers:
glance.sarlm()
,
tidy.sarlm()
# load libraries for models and data library(spatialreg) library(spdep) # load data data(oldcol, package = "spdep") listw <- nb2listw(COL.nb, style = "W") # fit model crime_sar <- lagsarlm(CRIME ~ INC + HOVAL, data = COL.OLD, listw = listw, method = "eigen" ) # summarize model fit with tidiers tidy(crime_sar) tidy(crime_sar, conf.int = TRUE) glance(crime_sar) augment(crime_sar) # fit another model crime_sem <- errorsarlm(CRIME ~ INC + HOVAL, data = COL.OLD, listw) # summarize model fit with tidiers tidy(crime_sem) tidy(crime_sem, conf.int = TRUE) glance(crime_sem) augment(crime_sem) # fit another model crime_sac <- sacsarlm(CRIME ~ INC + HOVAL, data = COL.OLD, listw) # summarize model fit with tidiers tidy(crime_sac) tidy(crime_sac, conf.int = TRUE) glance(crime_sac) augment(crime_sac)
# load libraries for models and data library(spatialreg) library(spdep) # load data data(oldcol, package = "spdep") listw <- nb2listw(COL.nb, style = "W") # fit model crime_sar <- lagsarlm(CRIME ~ INC + HOVAL, data = COL.OLD, listw = listw, method = "eigen" ) # summarize model fit with tidiers tidy(crime_sar) tidy(crime_sar, conf.int = TRUE) glance(crime_sar) augment(crime_sar) # fit another model crime_sem <- errorsarlm(CRIME ~ INC + HOVAL, data = COL.OLD, listw) # summarize model fit with tidiers tidy(crime_sem) tidy(crime_sem, conf.int = TRUE) glance(crime_sem) augment(crime_sem) # fit another model crime_sac <- sacsarlm(CRIME ~ INC + HOVAL, data = COL.OLD, listw) # summarize model fit with tidiers tidy(crime_sac) tidy(crime_sac, conf.int = TRUE) glance(crime_sac) augment(crime_sac)
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'smooth.spline' augment(x, data = x$data, ...)
## S3 method for class 'smooth.spline' augment(x, data = x$data, ...)
x |
A |
data |
A base::data.frame or |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with columns:
.fitted |
Fitted or predicted value. |
.resid |
The difference between observed and fitted values. |
augment()
, stats::smooth.spline()
,
stats::predict.smooth.spline()
Other smoothing spline tidiers:
glance.smooth.spline()
# fit model spl <- smooth.spline(mtcars$wt, mtcars$mpg, df = 4) # summarize model fit with tidiers augment(spl, mtcars) # calls original columns x and y augment(spl) library(ggplot2) ggplot(augment(spl, mtcars), aes(wt, mpg)) + geom_point() + geom_line(aes(y = .fitted))
# fit model spl <- smooth.spline(mtcars$wt, mtcars$mpg, df = 4) # summarize model fit with tidiers augment(spl, mtcars) # calls original columns x and y augment(spl) library(ggplot2) ggplot(augment(spl, mtcars), aes(wt, mpg)) + geom_point() + geom_line(aes(y = .fitted))
Augment accepts a model object and a dataset and adds
information about each observation in the dataset. Most commonly, this
includes predicted values in the .fitted
column, residuals in the
.resid
column, and standard errors for the fitted values in a .se.fit
column. New columns always begin with a .
prefix to avoid overwriting
columns in the original dataset.
Users may pass data to augment via either the data
argument or the
newdata
argument. If the user passes data to the data
argument,
it must be exactly the data that was used to fit the model
object. Pass datasets to newdata
to augment data that was not used
during model fitting. This still requires that at least all predictor
variable columns used to fit the model are present. If the original outcome
variable used to fit the model is not included in newdata
, then no
.resid
column will be included in the output.
Augment will often behave differently depending on whether data
or
newdata
is given. This is because there is often information
associated with training observations (such as influences or related)
measures that is not meaningfully defined for new observations.
For convenience, many augment methods provide default data
arguments,
so that augment(fit)
will return the augmented training data. In these
cases, augment tries to reconstruct the original data based on the model
object with varying degrees of success.
The augmented dataset is always returned as a tibble::tibble with the
same number of rows as the passed dataset. This means that the passed
data must be coercible to a tibble. If a predictor enters the model as part
of a matrix of covariates, such as when the model formula uses
splines::ns()
, stats::poly()
, or survival::Surv()
, it is represented
as a matrix column.
We are in the process of defining behaviors for models fit with various
na.action
arguments, but make no guarantees about behavior when data is
missing at this time.
## S3 method for class 'speedlm' augment(x, data = model.frame(x), newdata = NULL, ...)
## S3 method for class 'speedlm' augment(x, data = model.frame(x), newdata = NULL, ...)
x |
A |
data |
A base::data.frame or |
newdata |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with columns:
.fitted |
Fitted or predicted value. |
.resid |
The difference between observed and fitted values. |
Other speedlm tidiers:
glance.speedglm()
,
glance.speedlm()
,
tidy.speedglm()
,
tidy.speedlm()
# load modeling library library(speedglm) # fit model mod <- speedlm(mpg ~ wt + qsec, data = mtcars, fitted = TRUE) # summarize model fit with tidiers tidy(mod) glance(mod) augment(mod)
# load modeling library library(speedglm) # fit model mod <- speedlm(mpg ~ wt + qsec, data = mtcars, fitted = TRUE) # summarize model fit with tidiers tidy(mod) glance(mod) augment(mod)
Augment accepts a model object and a dataset and adds
information about each observation in the dataset. Most commonly, this
includes predicted values in the .fitted
column, residuals in the
.resid
column, and standard errors for the fitted values in a .se.fit
column. New columns always begin with a .
prefix to avoid overwriting
columns in the original dataset.
Users may pass data to augment via either the data
argument or the
newdata
argument. If the user passes data to the data
argument,
it must be exactly the data that was used to fit the model
object. Pass datasets to newdata
to augment data that was not used
during model fitting. This still requires that at least all predictor
variable columns used to fit the model are present. If the original outcome
variable used to fit the model is not included in newdata
, then no
.resid
column will be included in the output.
Augment will often behave differently depending on whether data
or
newdata
is given. This is because there is often information
associated with training observations (such as influences or related)
measures that is not meaningfully defined for new observations.
For convenience, many augment methods provide default data
arguments,
so that augment(fit)
will return the augmented training data. In these
cases, augment tries to reconstruct the original data based on the model
object with varying degrees of success.
The augmented dataset is always returned as a tibble::tibble with the
same number of rows as the passed dataset. This means that the passed
data must be coercible to a tibble. If a predictor enters the model as part
of a matrix of covariates, such as when the model formula uses
splines::ns()
, stats::poly()
, or survival::Surv()
, it is represented
as a matrix column.
We are in the process of defining behaviors for models fit with various
na.action
arguments, but make no guarantees about behavior when data is
missing at this time.
## S3 method for class 'stl' augment(x, data = NULL, weights = TRUE, ...)
## S3 method for class 'stl' augment(x, data = NULL, weights = TRUE, ...)
x |
An |
data |
Ignored, included for consistency with the augment generic signature only. |
weights |
Logical indicating whether or not to include the robust weights in the output. |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble with one row for each observation in the original times series:
.seasonal |
The seasonal component of the decomposition. |
.trend |
The trend component of the decomposition. |
.remainder |
The remainder, or "random" component of the decomposition. |
.weight |
The final robust weights, if requested. |
.seasadj |
The seasonally adjusted (or "deseasonalised") series. |
Other decompose tidiers:
augment.decomposed.ts()
Augment accepts a model object and a dataset and adds
information about each observation in the dataset. Most commonly, this
includes predicted values in the .fitted
column, residuals in the
.resid
column, and standard errors for the fitted values in a .se.fit
column. New columns always begin with a .
prefix to avoid overwriting
columns in the original dataset.
Users may pass data to augment via either the data
argument or the
newdata
argument. If the user passes data to the data
argument,
it must be exactly the data that was used to fit the model
object. Pass datasets to newdata
to augment data that was not used
during model fitting. This still requires that at least all predictor
variable columns used to fit the model are present. If the original outcome
variable used to fit the model is not included in newdata
, then no
.resid
column will be included in the output.
Augment will often behave differently depending on whether data
or
newdata
is given. This is because there is often information
associated with training observations (such as influences or related)
measures that is not meaningfully defined for new observations.
For convenience, many augment methods provide default data
arguments,
so that augment(fit)
will return the augmented training data. In these
cases, augment tries to reconstruct the original data based on the model
object with varying degrees of success.
The augmented dataset is always returned as a tibble::tibble with the
same number of rows as the passed dataset. This means that the passed
data must be coercible to a tibble. If a predictor enters the model as part
of a matrix of covariates, such as when the model formula uses
splines::ns()
, stats::poly()
, or survival::Surv()
, it is represented
as a matrix column.
We are in the process of defining behaviors for models fit with various
na.action
arguments, but make no guarantees about behavior when data is
missing at this time.
## S3 method for class 'survreg' augment( x, data = model.frame(x), newdata = NULL, type.predict = "response", type.residuals = "response", ... )
## S3 method for class 'survreg' augment( x, data = model.frame(x), newdata = NULL, type.predict = "response", type.residuals = "response", ... )
x |
An |
data |
A base::data.frame or |
newdata |
A |
type.predict |
Character indicating type of prediction to use. Passed
to the |
type.residuals |
Character indicating type of residuals to use. Passed
to the |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with columns:
.fitted |
Fitted or predicted value. |
.resid |
The difference between observed and fitted values. |
.se.fit |
Standard errors of fitted values. |
augment()
, survival::survreg()
Other survreg tidiers:
glance.survreg()
,
tidy.survreg()
Other survival tidiers:
augment.coxph()
,
glance.aareg()
,
glance.cch()
,
glance.coxph()
,
glance.pyears()
,
glance.survdiff()
,
glance.survexp()
,
glance.survfit()
,
glance.survreg()
,
tidy.aareg()
,
tidy.cch()
,
tidy.coxph()
,
tidy.pyears()
,
tidy.survdiff()
,
tidy.survexp()
,
tidy.survfit()
,
tidy.survreg()
# load libraries for models and data library(survival) # fit model sr <- survreg( Surv(futime, fustat) ~ ecog.ps + rx, ovarian, dist = "exponential" ) # summarize model fit with tidiers + visualization tidy(sr) augment(sr, ovarian) glance(sr) # coefficient plot td <- tidy(sr, conf.int = TRUE) library(ggplot2) ggplot(td, aes(estimate, term)) + geom_point() + geom_errorbarh(aes(xmin = conf.low, xmax = conf.high), height = 0) + geom_vline(xintercept = 0)
# load libraries for models and data library(survival) # fit model sr <- survreg( Surv(futime, fustat) ~ ecog.ps + rx, ovarian, dist = "exponential" ) # summarize model fit with tidiers + visualization tidy(sr) augment(sr, ovarian) glance(sr) # coefficient plot td <- tidy(sr, conf.int = TRUE) library(ggplot2) ggplot(td, aes(estimate, term)) + geom_point() + geom_errorbarh(aes(xmin = conf.low, xmax = conf.high), height = 0) + geom_vline(xintercept = 0)
The bootstrap()
function is deprecated and will be removed from
an upcoming release of broom. For tidy resampling, please use the rsample
package instead. Functionality is no longer supported for this method.
bootstrap(df, m, by_group = FALSE)
bootstrap(df, m, by_group = FALSE)
df |
a data frame |
m |
number of bootstrap replicates to perform |
by_group |
If |
This code originates from Hadley Wickham (with a few small corrections) here: https://github.com/tidyverse/dplyr/issues/269
Other deprecated:
confint_tidy()
,
data.frame_tidiers
,
finish_glance()
,
fix_data_frame()
,
summary_tidiers
,
tidy.density()
,
tidy.dist()
,
tidy.ftable()
,
tidy.numeric()
This function is now deprecated and will be removed from a future release of broom.
confint_tidy(x, conf.level = 0.95, func = stats::confint, ...)
confint_tidy(x, conf.level = 0.95, func = stats::confint, ...)
x |
a model object for which |
conf.level |
confidence level |
func |
A function to compute a confidence interval for |
... |
extra arguments passed on to |
Return a confidence interval as a tidy data frame. This directly wraps the
confint()
function, but ensures it follows broom conventions:
column names of conf.low
and conf.high
, and no row names.
confint_tidy
A tibble with two columns: conf.low
and conf.high
.
Other deprecated:
bootstrap()
,
data.frame_tidiers
,
finish_glance()
,
fix_data_frame()
,
summary_tidiers
,
tidy.density()
,
tidy.dist()
,
tidy.ftable()
,
tidy.numeric()
Data frame tidiers are deprecated and will be removed from an upcoming release of broom.
## S3 method for class 'data.frame' tidy(x, ..., na.rm = TRUE, trim = 0.1) ## S3 method for class 'data.frame' augment(x, data, ...) ## S3 method for class 'data.frame' glance(x, ...)
## S3 method for class 'data.frame' tidy(x, ..., na.rm = TRUE, trim = 0.1) ## S3 method for class 'data.frame' augment(x, data, ...) ## S3 method for class 'data.frame' glance(x, ...)
x |
A data.frame |
... |
Additional arguments for other methods. |
na.rm |
a logical value indicating whether |
trim |
the fraction (0 to 0.5) of observations to be trimmed from
each end of |
data |
data, not used |
These perform tidy summaries of data.frame objects. tidy
produces
summary statistics about each column, while glance
simply reports
the number of rows and columns. Note that augment.data.frame
will
throw an error.
tidy.data.frame
produces a data frame with one
row per original column, containing summary statistics of each:
column |
name of original column |
n |
Number of valid (non-NA) values |
mean |
mean |
sd |
standard deviation |
median |
median |
trimmed |
trimmed mean, with trim defaulting to .1 |
mad |
median absolute deviation (from the median) |
min |
minimum value |
max |
maximum value |
range |
range |
skew |
skew |
kurtosis |
kurtosis |
se |
standard error |
glance
returns a one-row data.frame with
nrow |
number of rows |
ncol |
number of columns |
complete.obs |
number of rows that have no missing values |
na.fraction |
fraction of values across all rows and columns that are missing |
David Robinson, Benjamin Nutter
Skew and Kurtosis functions are adapted from implementations in the moments
package:
Lukasz Komsta and Frederick Novomestky (2015). moments: Moments, cumulants, skewness,
kurtosis and related tests. R package version 0.14.
https://CRAN.R-project.org/package=moments
Other deprecated:
bootstrap()
,
confint_tidy()
,
finish_glance()
,
fix_data_frame()
,
summary_tidiers
,
tidy.density()
,
tidy.dist()
,
tidy.ftable()
,
tidy.numeric()
Other deprecated:
bootstrap()
,
confint_tidy()
,
finish_glance()
,
fix_data_frame()
,
summary_tidiers
,
tidy.density()
,
tidy.dist()
,
tidy.ftable()
,
tidy.numeric()
Other deprecated:
bootstrap()
,
confint_tidy()
,
finish_glance()
,
fix_data_frame()
,
summary_tidiers
,
tidy.density()
,
tidy.dist()
,
tidy.ftable()
,
tidy.numeric()
td <- tidy(mtcars) td glance(mtcars) library(ggplot2) # compare mean and standard deviation ggplot(td, aes(mean, sd)) + geom_point() + geom_text(aes(label = column), hjust = 1, vjust = 1) + scale_x_log10() + scale_y_log10() + geom_abline()
td <- tidy(mtcars) td glance(mtcars) library(ggplot2) # compare mean and standard deviation ggplot(td, aes(mean, sd)) + geom_point() + geom_text(aes(label = column), hjust = 1, vjust = 1) + scale_x_log10() + scale_y_log10() + geom_abline()
For models that have only a single component, the tidy()
and
glance()
methods are identical. Please see the documentation for both
of those methods.
## S3 method for class 'durbinWatsonTest' tidy(x, ...) ## S3 method for class 'durbinWatsonTest' glance(x, ...)
## S3 method for class 'durbinWatsonTest' tidy(x, ...) ## S3 method for class 'durbinWatsonTest' glance(x, ...)
x |
An object of class |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with columns:
alternative |
Alternative hypothesis (character). |
autocorrelation |
Autocorrelation. |
p.value |
The two-sided p-value associated with the observed statistic. |
statistic |
Test statistic for Durbin-Watson test. |
method |
Always 'Durbin-Watson Test'. |
tidy()
, glance()
, car::durbinWatsonTest()
Other car tidiers:
leveneTest_tidiers
# load modeling library library(car) # fit model dw <- durbinWatsonTest(lm(mpg ~ wt, data = mtcars)) # summarize model fit with tidiers tidy(dw) # same output for all durbinWatsonTests glance(dw)
# load modeling library library(car) # fit model dw <- durbinWatsonTest(lm(mpg ~ wt, data = mtcars)) # summarize model fit with tidiers tidy(dw) # same output for all durbinWatsonTests glance(dw)
This function is now deprecated in favor of using custom logic and
the appropriate nobs()
method.
finish_glance(ret, x)
finish_glance(ret, x)
ret |
a one-row data frame (a partially complete glance) |
x |
the prediction model |
a one-row data frame with additional columns added, such as
logLik |
log likelihoods |
AIC |
Akaike Information Criterion |
BIC |
Bayesian Information Criterion |
deviance |
deviance |
df.residual |
residual degrees of freedom |
Other deprecated:
bootstrap()
,
confint_tidy()
,
data.frame_tidiers
,
fix_data_frame()
,
summary_tidiers
,
tidy.density()
,
tidy.dist()
,
tidy.ftable()
,
tidy.numeric()
This function is deprecated as of broom 0.7.0 and will be removed from
a future release. Please see tibble::as_tibble
.
fix_data_frame(x, newnames = NULL, newcol = "term")
fix_data_frame(x, newnames = NULL, newcol = "term")
x |
a data.frame or matrix |
newnames |
new column names, not including the rownames |
newcol |
the name of the new rownames column |
a data.frame, with rownames moved into a column and new column names assigned
Other deprecated:
bootstrap()
,
confint_tidy()
,
data.frame_tidiers
,
finish_glance()
,
summary_tidiers
,
tidy.density()
,
tidy.dist()
,
tidy.ftable()
,
tidy.numeric()
Broom tidies a number of lists that are effectively S3
objects without a class attribute. For example, stats::optim()
,
svd() and interp::interp()
produce consistent output, but
because they do not have a class attribute, they cannot be handled by S3
dispatch.
These functions look at the elements of a list and determine if there is
an appropriate tidying method to apply to the list. Those tidiers are
implemented as functions of the form tidy_<function>
or
glance_<function>
and are not exported (but they are documented!).
If no appropriate tidying method is found, they throw an error.
glance_optim(x, ...)
glance_optim(x, ...)
x |
A list returned from |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with exactly one row and columns:
convergence |
Convergence code. |
function.count |
Number of calls to 'fn'. |
gradient.count |
Number of calls to 'gr'. |
value |
Minimized or maximized output value. |
Other list tidiers:
list_tidiers
,
tidy_irlba()
,
tidy_optim()
,
tidy_svd()
,
tidy_xyz()
f <- function(x) (x[1] - 2)^2 + (x[2] - 3)^2 + (x[3] - 8)^2 o <- optim(c(1, 1, 1), f)
f <- function(x) (x[1] - 2)^2 + (x[2] - 3)^2 + (x[3] - 8)^2 o <- optim(c(1, 1, 1), f)
Glance accepts a model object and returns a tibble::tibble()
with exactly one row of model summaries. The summaries are typically
goodness of fit measures, p-values for hypothesis tests on residuals,
or model convergence information.
Glance never returns information from the original call to the modeling function. This includes the name of the modeling function or any arguments passed to the modeling function.
Glance does not calculate summary measures. Rather, it farms out these
computations to appropriate methods and gathers the results together.
Sometimes a goodness of fit measure will be undefined. In these cases
the measure will be reported as NA
.
Glance returns the same number of columns regardless of whether the
model matrix is rank-deficient or not. If so, entries in columns
that no longer have a well-defined value are filled in with an NA
of the appropriate type.
## S3 method for class 'aareg' glance(x, ...)
## S3 method for class 'aareg' glance(x, ...)
x |
An |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with exactly one row and columns:
df |
Degrees of freedom used by the model. |
nobs |
Number of observations used. |
p.value |
P-value corresponding to the test statistic. |
statistic |
Test statistic. |
Other aareg tidiers:
tidy.aareg()
Other survival tidiers:
augment.coxph()
,
augment.survreg()
,
glance.cch()
,
glance.coxph()
,
glance.pyears()
,
glance.survdiff()
,
glance.survexp()
,
glance.survfit()
,
glance.survreg()
,
tidy.aareg()
,
tidy.cch()
,
tidy.coxph()
,
tidy.pyears()
,
tidy.survdiff()
,
tidy.survexp()
,
tidy.survfit()
,
tidy.survreg()
# load libraries for models and data library(survival) # fit model afit <- aareg( Surv(time, status) ~ age + sex + ph.ecog, data = lung, dfbeta = TRUE ) # summarize model fit with tidiers tidy(afit)
# load libraries for models and data library(survival) # fit model afit <- aareg( Surv(time, status) ~ age + sex + ph.ecog, data = lung, dfbeta = TRUE ) # summarize model fit with tidiers tidy(afit)
Glance accepts a model object and returns a tibble::tibble()
with exactly one row of model summaries. The summaries are typically
goodness of fit measures, p-values for hypothesis tests on residuals,
or model convergence information.
Glance never returns information from the original call to the modeling function. This includes the name of the modeling function or any arguments passed to the modeling function.
Glance does not calculate summary measures. Rather, it farms out these
computations to appropriate methods and gathers the results together.
Sometimes a goodness of fit measure will be undefined. In these cases
the measure will be reported as NA
.
Glance returns the same number of columns regardless of whether the
model matrix is rank-deficient or not. If so, entries in columns
that no longer have a well-defined value are filled in with an NA
of the appropriate type.
## S3 method for class 'anova' glance(x, ...)
## S3 method for class 'anova' glance(x, ...)
x |
An |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with exactly one row and columns:
deviance |
Deviance of the model. |
df.residual |
Residual degrees of freedom. |
Note that the output of glance.anova()
will vary depending on the initializing
anova call. In some cases, it will just return an empty data frame. In other
cases, glance.anova()
may return columns that are also common to
tidy.anova()
. This is partly to preserve backwards compatibility with early
versions of broom
, but also because the underlying anova model yields
components that could reasonably be interpreted as goodness-of-fit summaries
too.
Other anova tidiers:
glance.aov()
,
tidy.TukeyHSD()
,
tidy.anova()
,
tidy.aov()
,
tidy.aovlist()
,
tidy.manova()
# fit models a <- lm(mpg ~ wt + qsec + disp, mtcars) b <- lm(mpg ~ wt + qsec, mtcars) mod <- anova(a, b) # summarize model fit with tidiers tidy(mod) glance(mod) # car::linearHypothesis() example library(car) mod_lht <- linearHypothesis(a, "wt - disp") tidy(mod_lht) glance(mod_lht)
# fit models a <- lm(mpg ~ wt + qsec + disp, mtcars) b <- lm(mpg ~ wt + qsec, mtcars) mod <- anova(a, b) # summarize model fit with tidiers tidy(mod) glance(mod) # car::linearHypothesis() example library(car) mod_lht <- linearHypothesis(a, "wt - disp") tidy(mod_lht) glance(mod_lht)
Glance accepts a model object and returns a tibble::tibble()
with exactly one row of model summaries. The summaries are typically
goodness of fit measures, p-values for hypothesis tests on residuals,
or model convergence information.
Glance never returns information from the original call to the modeling function. This includes the name of the modeling function or any arguments passed to the modeling function.
Glance does not calculate summary measures. Rather, it farms out these
computations to appropriate methods and gathers the results together.
Sometimes a goodness of fit measure will be undefined. In these cases
the measure will be reported as NA
.
Glance returns the same number of columns regardless of whether the
model matrix is rank-deficient or not. If so, entries in columns
that no longer have a well-defined value are filled in with an NA
of the appropriate type.
## S3 method for class 'aov' glance(x, ...)
## S3 method for class 'aov' glance(x, ...)
x |
An |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with exactly one row and columns:
AIC |
Akaike's Information Criterion for the model. |
BIC |
Bayesian Information Criterion for the model. |
deviance |
Deviance of the model. |
logLik |
The log-likelihood of the model. [stats::logLik()] may be a useful reference. |
nobs |
Number of observations used. |
Note that tidy.aov()
now contains the numerator and denominator degrees of
freedom, which were included in the output of glance.aov()
in some
previous versions of the package.
Other anova tidiers:
glance.anova()
,
tidy.TukeyHSD()
,
tidy.anova()
,
tidy.aov()
,
tidy.aovlist()
,
tidy.manova()
a <- aov(mpg ~ wt + qsec + disp, mtcars) tidy(a)
a <- aov(mpg ~ wt + qsec + disp, mtcars) tidy(a)
Glance accepts a model object and returns a tibble::tibble()
with exactly one row of model summaries. The summaries are typically
goodness of fit measures, p-values for hypothesis tests on residuals,
or model convergence information.
Glance never returns information from the original call to the modeling function. This includes the name of the modeling function or any arguments passed to the modeling function.
Glance does not calculate summary measures. Rather, it farms out these
computations to appropriate methods and gathers the results together.
Sometimes a goodness of fit measure will be undefined. In these cases
the measure will be reported as NA
.
Glance returns the same number of columns regardless of whether the
model matrix is rank-deficient or not. If so, entries in columns
that no longer have a well-defined value are filled in with an NA
of the appropriate type.
## S3 method for class 'Arima' glance(x, ...)
## S3 method for class 'Arima' glance(x, ...)
x |
An object of class |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with exactly one row and columns:
AIC |
Akaike's Information Criterion for the model. |
BIC |
Bayesian Information Criterion for the model. |
logLik |
The log-likelihood of the model. [stats::logLik()] may be a useful reference. |
nobs |
Number of observations used. |
sigma |
Estimated standard error of the residuals. |
Other Arima tidiers:
tidy.Arima()
# fit model fit <- arima(lh, order = c(1, 0, 0)) # summarize model fit with tidiers tidy(fit) glance(fit)
# fit model fit <- arima(lh, order = c(1, 0, 0)) # summarize model fit with tidiers tidy(fit) glance(fit)
Glance accepts a model object and returns a tibble::tibble()
with exactly one row of model summaries. The summaries are typically
goodness of fit measures, p-values for hypothesis tests on residuals,
or model convergence information.
Glance never returns information from the original call to the modeling function. This includes the name of the modeling function or any arguments passed to the modeling function.
Glance does not calculate summary measures. Rather, it farms out these
computations to appropriate methods and gathers the results together.
Sometimes a goodness of fit measure will be undefined. In these cases
the measure will be reported as NA
.
Glance returns the same number of columns regardless of whether the
model matrix is rank-deficient or not. If so, entries in columns
that no longer have a well-defined value are filled in with an NA
of the appropriate type.
## S3 method for class 'betamfx' glance(x, ...)
## S3 method for class 'betamfx' glance(x, ...)
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
This glance method wraps glance.betareg()
for mfx::betamfx()
objects.
A tibble::tibble()
with exactly one row and columns:
AIC |
Akaike's Information Criterion for the model. |
BIC |
Bayesian Information Criterion for the model. |
df.null |
Degrees of freedom used by the null model. |
df.residual |
Residual degrees of freedom. |
logLik |
The log-likelihood of the model. [stats::logLik()] may be a useful reference. |
nobs |
Number of observations used. |
pseudo.r.squared |
Like the R squared statistic, but for situations when the R squared statistic isn't defined. |
glance.betareg()
, mfx::betamfx()
Other mfx tidiers:
augment.betamfx()
,
augment.mfx()
,
glance.mfx()
,
tidy.betamfx()
,
tidy.mfx()
library(mfx) # Simulate some data set.seed(12345) n <- 1000 x <- rnorm(n) # Beta outcome y <- rbeta(n, shape1 = plogis(1 + 0.5 * x), shape2 = (abs(0.2 * x))) # Use Smithson and Verkuilen correction y <- (y * (n - 1) + 0.5) / n d <- data.frame(y, x) mod_betamfx <- betamfx(y ~ x | x, data = d) tidy(mod_betamfx, conf.int = TRUE) # Compare with the naive model coefficients of the equivalent betareg call (not run) # tidy(betamfx(y ~ x | x, data = d), conf.int = TRUE) augment(mod_betamfx) glance(mod_betamfx)
library(mfx) # Simulate some data set.seed(12345) n <- 1000 x <- rnorm(n) # Beta outcome y <- rbeta(n, shape1 = plogis(1 + 0.5 * x), shape2 = (abs(0.2 * x))) # Use Smithson and Verkuilen correction y <- (y * (n - 1) + 0.5) / n d <- data.frame(y, x) mod_betamfx <- betamfx(y ~ x | x, data = d) tidy(mod_betamfx, conf.int = TRUE) # Compare with the naive model coefficients of the equivalent betareg call (not run) # tidy(betamfx(y ~ x | x, data = d), conf.int = TRUE) augment(mod_betamfx) glance(mod_betamfx)
Glance accepts a model object and returns a tibble::tibble()
with exactly one row of model summaries. The summaries are typically
goodness of fit measures, p-values for hypothesis tests on residuals,
or model convergence information.
Glance never returns information from the original call to the modeling function. This includes the name of the modeling function or any arguments passed to the modeling function.
Glance does not calculate summary measures. Rather, it farms out these
computations to appropriate methods and gathers the results together.
Sometimes a goodness of fit measure will be undefined. In these cases
the measure will be reported as NA
.
Glance returns the same number of columns regardless of whether the
model matrix is rank-deficient or not. If so, entries in columns
that no longer have a well-defined value are filled in with an NA
of the appropriate type.
## S3 method for class 'betareg' glance(x, ...)
## S3 method for class 'betareg' glance(x, ...)
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with exactly one row and columns:
AIC |
Akaike's Information Criterion for the model. |
BIC |
Bayesian Information Criterion for the model. |
df.null |
Degrees of freedom used by the null model. |
df.residual |
Residual degrees of freedom. |
logLik |
The log-likelihood of the model. [stats::logLik()] may be a useful reference. |
nobs |
Number of observations used. |
pseudo.r.squared |
Like the R squared statistic, but for situations when the R squared statistic isn't defined. |
# load libraries for models and data library(betareg) # load dats data("GasolineYield", package = "betareg") # fit model mod <- betareg(yield ~ batch + temp, data = GasolineYield) mod # summarize model fit with tidiers tidy(mod) tidy(mod, conf.int = TRUE) tidy(mod, conf.int = TRUE, conf.level = .99) augment(mod) glance(mod)
# load libraries for models and data library(betareg) # load dats data("GasolineYield", package = "betareg") # fit model mod <- betareg(yield ~ batch + temp, data = GasolineYield) mod # summarize model fit with tidiers tidy(mod) tidy(mod, conf.int = TRUE) tidy(mod, conf.int = TRUE, conf.level = .99) augment(mod) glance(mod)
Glance accepts a model object and returns a tibble::tibble()
with exactly one row of model summaries. The summaries are typically
goodness of fit measures, p-values for hypothesis tests on residuals,
or model convergence information.
Glance never returns information from the original call to the modeling function. This includes the name of the modeling function or any arguments passed to the modeling function.
Glance does not calculate summary measures. Rather, it farms out these
computations to appropriate methods and gathers the results together.
Sometimes a goodness of fit measure will be undefined. In these cases
the measure will be reported as NA
.
Glance returns the same number of columns regardless of whether the
model matrix is rank-deficient or not. If so, entries in columns
that no longer have a well-defined value are filled in with an NA
of the appropriate type.
## S3 method for class 'biglm' glance(x, ...)
## S3 method for class 'biglm' glance(x, ...)
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with exactly one row and columns:
AIC |
Akaike's Information Criterion for the model. |
deviance |
Deviance of the model. |
df.residual |
Residual degrees of freedom. |
nobs |
Number of observations used. |
r.squared |
R squared statistic, or the percent of variation explained by the model. Also known as the coefficient of determination. |
glance()
, biglm::biglm()
, biglm::bigglm()
Other biglm tidiers:
tidy.biglm()
# load modeling library library(biglm) # fit model -- linear regression bfit <- biglm(mpg ~ wt + disp, mtcars) # summarize model fit with tidiers tidy(bfit) tidy(bfit, conf.int = TRUE) tidy(bfit, conf.int = TRUE, conf.level = .9) glance(bfit) # fit model -- logistic regression bgfit <- bigglm(am ~ mpg, mtcars, family = binomial()) # summarize model fit with tidiers tidy(bgfit) tidy(bgfit, exponentiate = TRUE) tidy(bgfit, conf.int = TRUE) tidy(bgfit, conf.int = TRUE, conf.level = .9) tidy(bgfit, conf.int = TRUE, conf.level = .9, exponentiate = TRUE) glance(bgfit)
# load modeling library library(biglm) # fit model -- linear regression bfit <- biglm(mpg ~ wt + disp, mtcars) # summarize model fit with tidiers tidy(bfit) tidy(bfit, conf.int = TRUE) tidy(bfit, conf.int = TRUE, conf.level = .9) glance(bfit) # fit model -- logistic regression bgfit <- bigglm(am ~ mpg, mtcars, family = binomial()) # summarize model fit with tidiers tidy(bgfit) tidy(bgfit, exponentiate = TRUE) tidy(bgfit, conf.int = TRUE) tidy(bgfit, conf.int = TRUE, conf.level = .9) tidy(bgfit, conf.int = TRUE, conf.level = .9, exponentiate = TRUE) glance(bgfit)
Glance accepts a model object and returns a tibble::tibble()
with exactly one row of model summaries. The summaries are typically
goodness of fit measures, p-values for hypothesis tests on residuals,
or model convergence information.
Glance never returns information from the original call to the modeling function. This includes the name of the modeling function or any arguments passed to the modeling function.
Glance does not calculate summary measures. Rather, it farms out these
computations to appropriate methods and gathers the results together.
Sometimes a goodness of fit measure will be undefined. In these cases
the measure will be reported as NA
.
Glance returns the same number of columns regardless of whether the
model matrix is rank-deficient or not. If so, entries in columns
that no longer have a well-defined value are filled in with an NA
of the appropriate type.
## S3 method for class 'binDesign' glance(x, ...)
## S3 method for class 'binDesign' glance(x, ...)
x |
A binGroup::binDesign object. |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with exactly one row and columns:
power |
Power achieved by the analysis. |
n |
Sample size used to achieve this power. |
power.reached |
Whether the desired power was reached. |
maxit |
Number of iterations performed. |
glance()
, binGroup::binDesign()
Other bingroup tidiers:
tidy.binDesign()
,
tidy.binWidth()
# load libraries for models and data library(binGroup) des <- binDesign( nmax = 300, delta = 0.06, p.hyp = 0.1, power = .8 ) glance(des) tidy(des) library(ggplot2) ggplot(tidy(des), aes(n, power)) + geom_line()
# load libraries for models and data library(binGroup) des <- binDesign( nmax = 300, delta = 0.06, p.hyp = 0.1, power = .8 ) glance(des) tidy(des) library(ggplot2) ggplot(tidy(des), aes(n, power)) + geom_line()
Glance accepts a model object and returns a tibble::tibble()
with exactly one row of model summaries. The summaries are typically
goodness of fit measures, p-values for hypothesis tests on residuals,
or model convergence information.
Glance never returns information from the original call to the modeling function. This includes the name of the modeling function or any arguments passed to the modeling function.
Glance does not calculate summary measures. Rather, it farms out these
computations to appropriate methods and gathers the results together.
Sometimes a goodness of fit measure will be undefined. In these cases
the measure will be reported as NA
.
Glance returns the same number of columns regardless of whether the
model matrix is rank-deficient or not. If so, entries in columns
that no longer have a well-defined value are filled in with an NA
of the appropriate type.
## S3 method for class 'cch' glance(x, ...)
## S3 method for class 'cch' glance(x, ...)
x |
An |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with exactly one row and columns:
iter |
Iterations of algorithm/fitting procedure completed. |
p.value |
P-value corresponding to the test statistic. |
rscore |
Robust log-rank statistic |
score |
Score. |
n |
number of predictions |
nevent |
number of events |
Other cch tidiers:
glance.survfit()
,
tidy.cch()
Other survival tidiers:
augment.coxph()
,
augment.survreg()
,
glance.aareg()
,
glance.coxph()
,
glance.pyears()
,
glance.survdiff()
,
glance.survexp()
,
glance.survfit()
,
glance.survreg()
,
tidy.aareg()
,
tidy.cch()
,
tidy.coxph()
,
tidy.pyears()
,
tidy.survdiff()
,
tidy.survexp()
,
tidy.survfit()
,
tidy.survreg()
# load libraries for models and data library(survival) # examples come from cch documentation subcoh <- nwtco$in.subcohort selccoh <- with(nwtco, rel == 1 | subcoh == 1) ccoh.data <- nwtco[selccoh, ] ccoh.data$subcohort <- subcoh[selccoh] # central-lab histology ccoh.data$histol <- factor(ccoh.data$histol, labels = c("FH", "UH")) # tumour stage ccoh.data$stage <- factor(ccoh.data$stage, labels = c("I", "II", "III", "IV")) ccoh.data$age <- ccoh.data$age / 12 # age in years # fit model fit.ccP <- cch(Surv(edrel, rel) ~ stage + histol + age, data = ccoh.data, subcoh = ~subcohort, id = ~seqno, cohort.size = 4028 ) # summarize model fit with tidiers + visualization tidy(fit.ccP) # coefficient plot library(ggplot2) ggplot(tidy(fit.ccP), aes(x = estimate, y = term)) + geom_point() + geom_errorbarh(aes(xmin = conf.low, xmax = conf.high), height = 0) + geom_vline(xintercept = 0)
# load libraries for models and data library(survival) # examples come from cch documentation subcoh <- nwtco$in.subcohort selccoh <- with(nwtco, rel == 1 | subcoh == 1) ccoh.data <- nwtco[selccoh, ] ccoh.data$subcohort <- subcoh[selccoh] # central-lab histology ccoh.data$histol <- factor(ccoh.data$histol, labels = c("FH", "UH")) # tumour stage ccoh.data$stage <- factor(ccoh.data$stage, labels = c("I", "II", "III", "IV")) ccoh.data$age <- ccoh.data$age / 12 # age in years # fit model fit.ccP <- cch(Surv(edrel, rel) ~ stage + histol + age, data = ccoh.data, subcoh = ~subcohort, id = ~seqno, cohort.size = 4028 ) # summarize model fit with tidiers + visualization tidy(fit.ccP) # coefficient plot library(ggplot2) ggplot(tidy(fit.ccP), aes(x = estimate, y = term)) + geom_point() + geom_errorbarh(aes(xmin = conf.low, xmax = conf.high), height = 0) + geom_vline(xintercept = 0)
Glance accepts a model object and returns a tibble::tibble()
with exactly one row of model summaries. The summaries are typically
goodness of fit measures, p-values for hypothesis tests on residuals,
or model convergence information.
Glance never returns information from the original call to the modeling function. This includes the name of the modeling function or any arguments passed to the modeling function.
Glance does not calculate summary measures. Rather, it farms out these
computations to appropriate methods and gathers the results together.
Sometimes a goodness of fit measure will be undefined. In these cases
the measure will be reported as NA
.
Glance returns the same number of columns regardless of whether the
model matrix is rank-deficient or not. If so, entries in columns
that no longer have a well-defined value are filled in with an NA
of the appropriate type.
## S3 method for class 'clm' glance(x, ...)
## S3 method for class 'clm' glance(x, ...)
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with exactly one row and columns:
AIC |
Akaike's Information Criterion for the model. |
BIC |
Bayesian Information Criterion for the model. |
df.residual |
Residual degrees of freedom. |
edf |
The effective degrees of freedom. |
logLik |
The log-likelihood of the model. [stats::logLik()] may be a useful reference. |
nobs |
Number of observations used. |
Other ordinal tidiers:
augment.clm()
,
augment.polr()
,
glance.clmm()
,
glance.polr()
,
glance.svyolr()
,
tidy.clm()
,
tidy.clmm()
,
tidy.polr()
,
tidy.svyolr()
# load libraries for models and data library(ordinal) # fit model fit <- clm(rating ~ temp * contact, data = wine) # summarize model fit with tidiers tidy(fit) tidy(fit, conf.int = TRUE, conf.level = 0.9) tidy(fit, conf.int = TRUE, conf.type = "Wald", exponentiate = TRUE) glance(fit) augment(fit, type.predict = "prob") augment(fit, type.predict = "class") # ...and again with another model specification fit2 <- clm(rating ~ temp, nominal = ~contact, data = wine) tidy(fit2) glance(fit2)
# load libraries for models and data library(ordinal) # fit model fit <- clm(rating ~ temp * contact, data = wine) # summarize model fit with tidiers tidy(fit) tidy(fit, conf.int = TRUE, conf.level = 0.9) tidy(fit, conf.int = TRUE, conf.type = "Wald", exponentiate = TRUE) glance(fit) augment(fit, type.predict = "prob") augment(fit, type.predict = "class") # ...and again with another model specification fit2 <- clm(rating ~ temp, nominal = ~contact, data = wine) tidy(fit2) glance(fit2)
Glance accepts a model object and returns a tibble::tibble()
with exactly one row of model summaries. The summaries are typically
goodness of fit measures, p-values for hypothesis tests on residuals,
or model convergence information.
Glance never returns information from the original call to the modeling function. This includes the name of the modeling function or any arguments passed to the modeling function.
Glance does not calculate summary measures. Rather, it farms out these
computations to appropriate methods and gathers the results together.
Sometimes a goodness of fit measure will be undefined. In these cases
the measure will be reported as NA
.
Glance returns the same number of columns regardless of whether the
model matrix is rank-deficient or not. If so, entries in columns
that no longer have a well-defined value are filled in with an NA
of the appropriate type.
## S3 method for class 'clmm' glance(x, ...)
## S3 method for class 'clmm' glance(x, ...)
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with exactly one row and columns:
AIC |
Akaike's Information Criterion for the model. |
BIC |
Bayesian Information Criterion for the model. |
edf |
The effective degrees of freedom. |
logLik |
The log-likelihood of the model. [stats::logLik()] may be a useful reference. |
nobs |
Number of observations used. |
Other ordinal tidiers:
augment.clm()
,
augment.polr()
,
glance.clm()
,
glance.polr()
,
glance.svyolr()
,
tidy.clm()
,
tidy.clmm()
,
tidy.polr()
,
tidy.svyolr()
# load libraries for models and data library(ordinal) # fit model fit <- clmm(rating ~ temp + contact + (1 | judge), data = wine) # summarize model fit with tidiers tidy(fit) tidy(fit, conf.int = TRUE, conf.level = 0.9) tidy(fit, conf.int = TRUE, exponentiate = TRUE) glance(fit) # ...and again with another model specification fit2 <- clmm(rating ~ temp + (1 | judge), nominal = ~contact, data = wine) tidy(fit2) glance(fit2)
# load libraries for models and data library(ordinal) # fit model fit <- clmm(rating ~ temp + contact + (1 | judge), data = wine) # summarize model fit with tidiers tidy(fit) tidy(fit, conf.int = TRUE, conf.level = 0.9) tidy(fit, conf.int = TRUE, exponentiate = TRUE) glance(fit) # ...and again with another model specification fit2 <- clmm(rating ~ temp + (1 | judge), nominal = ~contact, data = wine) tidy(fit2) glance(fit2)
Glance accepts a model object and returns a tibble::tibble()
with exactly one row of model summaries. The summaries are typically
goodness of fit measures, p-values for hypothesis tests on residuals,
or model convergence information.
Glance never returns information from the original call to the modeling function. This includes the name of the modeling function or any arguments passed to the modeling function.
Glance does not calculate summary measures. Rather, it farms out these
computations to appropriate methods and gathers the results together.
Sometimes a goodness of fit measure will be undefined. In these cases
the measure will be reported as NA
.
Glance returns the same number of columns regardless of whether the
model matrix is rank-deficient or not. If so, entries in columns
that no longer have a well-defined value are filled in with an NA
of the appropriate type.
## S3 method for class 'coeftest' glance(x, ...)
## S3 method for class 'coeftest' glance(x, ...)
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with exactly one row and columns:
adj.r.squared |
Adjusted R squared statistic, which is like the R squared statistic except taking degrees of freedom into account. |
AIC |
Akaike's Information Criterion for the model. |
BIC |
Bayesian Information Criterion for the model. |
deviance |
Deviance of the model. |
df |
Degrees of freedom used by the model. |
df.residual |
Residual degrees of freedom. |
logLik |
The log-likelihood of the model. [stats::logLik()] may be a useful reference. |
nobs |
Number of observations used. |
p.value |
P-value corresponding to the test statistic. |
r.squared |
R squared statistic, or the percent of variation explained by the model. Also known as the coefficient of determination. |
sigma |
Estimated standard error of the residuals. |
statistic |
Test statistic. |
Because of the way that lmtest::coeftest() retains information about the underlying model object, the returned columns for glance.coeftest() will vary depending on the arguments. Specifically, four columns are returned regardless: "Loglik", "AIC", "BIC", and "nobs". Users can obtain additional columns (e.g. "r.squared", "df") by invoking the "save = TRUE" argument as part of lmtest::coeftest(). See examples.
As an aside, goodness-of-fit measures such as R-squared are unaffected by the presence of heteroskedasticity. For further discussion see, e.g. chapter 8.1 of Wooldridge (2016).
Wooldridge, Jeffrey M. (2016) Introductory econometrics: A modern approach. (6th edition). Nelson Education.
# load libraries for models and data library(lmtest) m <- lm(dist ~ speed, data = cars) coeftest(m) tidy(coeftest(m)) tidy(coeftest(m, conf.int = TRUE)) # a very common workflow is to combine lmtest::coeftest with alternate # variance-covariance matrices via the sandwich package. The lmtest # tidiers support this workflow too, enabling you to adjust the standard # errors of your tidied models on the fly. library(sandwich) # "HC3" (default) robust SEs tidy(coeftest(m, vcov = vcovHC)) # "HC2" robust SEs tidy(coeftest(m, vcov = vcovHC, type = "HC2")) # N-W HAC robust SEs tidy(coeftest(m, vcov = NeweyWest)) # the columns of the returned tibble for glance.coeftest() will vary # depending on whether the coeftest object retains the underlying model. # Users can control this with the "save = TRUE" argument of coeftest(). glance(coeftest(m)) glance(coeftest(m, save = TRUE))
# load libraries for models and data library(lmtest) m <- lm(dist ~ speed, data = cars) coeftest(m) tidy(coeftest(m)) tidy(coeftest(m, conf.int = TRUE)) # a very common workflow is to combine lmtest::coeftest with alternate # variance-covariance matrices via the sandwich package. The lmtest # tidiers support this workflow too, enabling you to adjust the standard # errors of your tidied models on the fly. library(sandwich) # "HC3" (default) robust SEs tidy(coeftest(m, vcov = vcovHC)) # "HC2" robust SEs tidy(coeftest(m, vcov = vcovHC, type = "HC2")) # N-W HAC robust SEs tidy(coeftest(m, vcov = NeweyWest)) # the columns of the returned tibble for glance.coeftest() will vary # depending on whether the coeftest object retains the underlying model. # Users can control this with the "save = TRUE" argument of coeftest(). glance(coeftest(m)) glance(coeftest(m, save = TRUE))
Glance accepts a model object and returns a tibble::tibble()
with exactly one row of model summaries. The summaries are typically
goodness of fit measures, p-values for hypothesis tests on residuals,
or model convergence information.
Glance never returns information from the original call to the modeling function. This includes the name of the modeling function or any arguments passed to the modeling function.
Glance does not calculate summary measures. Rather, it farms out these
computations to appropriate methods and gathers the results together.
Sometimes a goodness of fit measure will be undefined. In these cases
the measure will be reported as NA
.
Glance returns the same number of columns regardless of whether the
model matrix is rank-deficient or not. If so, entries in columns
that no longer have a well-defined value are filled in with an NA
of the appropriate type.
## S3 method for class 'coxph' glance(x, ...)
## S3 method for class 'coxph' glance(x, ...)
x |
A |
... |
For |
A tibble::tibble()
with exactly one row and columns:
AIC |
Akaike's Information Criterion for the model. |
BIC |
Bayesian Information Criterion for the model. |
logLik |
The log-likelihood of the model. [stats::logLik()] may be a useful reference. |
n |
The total number of observations. |
nevent |
Number of events. |
nobs |
Number of observations used. |
See survival::coxph.object for additional column descriptions.
Other coxph tidiers:
augment.coxph()
,
tidy.coxph()
Other survival tidiers:
augment.coxph()
,
augment.survreg()
,
glance.aareg()
,
glance.cch()
,
glance.pyears()
,
glance.survdiff()
,
glance.survexp()
,
glance.survfit()
,
glance.survreg()
,
tidy.aareg()
,
tidy.cch()
,
tidy.coxph()
,
tidy.pyears()
,
tidy.survdiff()
,
tidy.survexp()
,
tidy.survfit()
,
tidy.survreg()
# load libraries for models and data library(survival) # fit model cfit <- coxph(Surv(time, status) ~ age + sex, lung) # summarize model fit with tidiers tidy(cfit) tidy(cfit, exponentiate = TRUE) lp <- augment(cfit, lung) risks <- augment(cfit, lung, type.predict = "risk") expected <- augment(cfit, lung, type.predict = "expected") glance(cfit) # also works on clogit models resp <- levels(logan$occupation) n <- nrow(logan) indx <- rep(1:n, length(resp)) logan2 <- data.frame( logan[indx, ], id = indx, tocc = factor(rep(resp, each = n)) ) logan2$case <- (logan2$occupation == logan2$tocc) cl <- clogit(case ~ tocc + tocc:education + strata(id), logan2) tidy(cl) glance(cl) library(ggplot2) ggplot(lp, aes(age, .fitted, color = sex)) + geom_point() ggplot(risks, aes(age, .fitted, color = sex)) + geom_point() ggplot(expected, aes(time, .fitted, color = sex)) + geom_point()
# load libraries for models and data library(survival) # fit model cfit <- coxph(Surv(time, status) ~ age + sex, lung) # summarize model fit with tidiers tidy(cfit) tidy(cfit, exponentiate = TRUE) lp <- augment(cfit, lung) risks <- augment(cfit, lung, type.predict = "risk") expected <- augment(cfit, lung, type.predict = "expected") glance(cfit) # also works on clogit models resp <- levels(logan$occupation) n <- nrow(logan) indx <- rep(1:n, length(resp)) logan2 <- data.frame( logan[indx, ], id = indx, tocc = factor(rep(resp, each = n)) ) logan2$case <- (logan2$occupation == logan2$tocc) cl <- clogit(case ~ tocc + tocc:education + strata(id), logan2) tidy(cl) glance(cl) library(ggplot2) ggplot(lp, aes(age, .fitted, color = sex)) + geom_point() ggplot(risks, aes(age, .fitted, color = sex)) + geom_point() ggplot(expected, aes(time, .fitted, color = sex)) + geom_point()
Glance accepts a model object and returns a tibble::tibble()
with exactly one row of model summaries. The summaries are typically
goodness of fit measures, p-values for hypothesis tests on residuals,
or model convergence information.
Glance never returns information from the original call to the modeling function. This includes the name of the modeling function or any arguments passed to the modeling function.
Glance does not calculate summary measures. Rather, it farms out these
computations to appropriate methods and gathers the results together.
Sometimes a goodness of fit measure will be undefined. In these cases
the measure will be reported as NA
.
Glance returns the same number of columns regardless of whether the
model matrix is rank-deficient or not. If so, entries in columns
that no longer have a well-defined value are filled in with an NA
of the appropriate type.
## S3 method for class 'crr' glance(x, ...)
## S3 method for class 'crr' glance(x, ...)
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with exactly one row and columns:
converged |
Logical indicating if the model fitting procedure was succesful and converged. |
df |
Degrees of freedom used by the model. |
logLik |
The log-likelihood of the model. [stats::logLik()] may be a useful reference. |
nobs |
Number of observations used. |
statistic |
Test statistic. |
Other cmprsk tidiers:
tidy.crr()
library(cmprsk) # time to loco-regional failure (lrf) lrf_time <- rexp(100) lrf_event <- sample(0:2, 100, replace = TRUE) trt <- sample(0:1, 100, replace = TRUE) strt <- sample(1:2, 100, replace = TRUE) # fit model x <- crr(lrf_time, lrf_event, cbind(trt, strt)) # summarize model fit with tidiers tidy(x, conf.int = TRUE) glance(x)
library(cmprsk) # time to loco-regional failure (lrf) lrf_time <- rexp(100) lrf_event <- sample(0:2, 100, replace = TRUE) trt <- sample(0:1, 100, replace = TRUE) strt <- sample(1:2, 100, replace = TRUE) # fit model x <- crr(lrf_time, lrf_event, cbind(trt, strt)) # summarize model fit with tidiers tidy(x, conf.int = TRUE) glance(x)
Glance accepts a model object and returns a tibble::tibble()
with exactly one row of model summaries. The summaries are typically
goodness of fit measures, p-values for hypothesis tests on residuals,
or model convergence information.
Glance never returns information from the original call to the modeling function. This includes the name of the modeling function or any arguments passed to the modeling function.
Glance does not calculate summary measures. Rather, it farms out these
computations to appropriate methods and gathers the results together.
Sometimes a goodness of fit measure will be undefined. In these cases
the measure will be reported as NA
.
Glance returns the same number of columns regardless of whether the
model matrix is rank-deficient or not. If so, entries in columns
that no longer have a well-defined value are filled in with an NA
of the appropriate type.
## S3 method for class 'cv.glmnet' glance(x, ...)
## S3 method for class 'cv.glmnet' glance(x, ...)
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with exactly one row and columns:
lambda.1se |
The value of the penalization parameter lambda that results in the sparsest model while remaining within one standard error of the minimum loss. |
lambda.min |
The value of the penalization parameter lambda that achieved minimum loss as estimated by cross validation. |
nobs |
Number of observations used. |
Other glmnet tidiers:
glance.glmnet()
,
tidy.cv.glmnet()
,
tidy.glmnet()
# load libraries for models and data library(glmnet) set.seed(27) nobs <- 100 nvar <- 50 real <- 5 x <- matrix(rnorm(nobs * nvar), nobs, nvar) beta <- c(rnorm(real, 0, 1), rep(0, nvar - real)) y <- c(t(beta) %*% t(x)) + rnorm(nvar, sd = 3) cvfit1 <- cv.glmnet(x, y) tidy(cvfit1) glance(cvfit1) library(ggplot2) tidied_cv <- tidy(cvfit1) glance_cv <- glance(cvfit1) # plot of MSE as a function of lambda g <- ggplot(tidied_cv, aes(lambda, estimate)) + geom_line() + scale_x_log10() g # plot of MSE as a function of lambda with confidence ribbon g <- g + geom_ribbon(aes(ymin = conf.low, ymax = conf.high), alpha = .25) g # plot of MSE as a function of lambda with confidence ribbon and choices # of minimum lambda marked g <- g + geom_vline(xintercept = glance_cv$lambda.min) + geom_vline(xintercept = glance_cv$lambda.1se, lty = 2) g # plot of number of zeros for each choice of lambda ggplot(tidied_cv, aes(lambda, nzero)) + geom_line() + scale_x_log10() # coefficient plot with min lambda shown tidied <- tidy(cvfit1$glmnet.fit) ggplot(tidied, aes(lambda, estimate, group = term)) + scale_x_log10() + geom_line() + geom_vline(xintercept = glance_cv$lambda.min) + geom_vline(xintercept = glance_cv$lambda.1se, lty = 2)
# load libraries for models and data library(glmnet) set.seed(27) nobs <- 100 nvar <- 50 real <- 5 x <- matrix(rnorm(nobs * nvar), nobs, nvar) beta <- c(rnorm(real, 0, 1), rep(0, nvar - real)) y <- c(t(beta) %*% t(x)) + rnorm(nvar, sd = 3) cvfit1 <- cv.glmnet(x, y) tidy(cvfit1) glance(cvfit1) library(ggplot2) tidied_cv <- tidy(cvfit1) glance_cv <- glance(cvfit1) # plot of MSE as a function of lambda g <- ggplot(tidied_cv, aes(lambda, estimate)) + geom_line() + scale_x_log10() g # plot of MSE as a function of lambda with confidence ribbon g <- g + geom_ribbon(aes(ymin = conf.low, ymax = conf.high), alpha = .25) g # plot of MSE as a function of lambda with confidence ribbon and choices # of minimum lambda marked g <- g + geom_vline(xintercept = glance_cv$lambda.min) + geom_vline(xintercept = glance_cv$lambda.1se, lty = 2) g # plot of number of zeros for each choice of lambda ggplot(tidied_cv, aes(lambda, nzero)) + geom_line() + scale_x_log10() # coefficient plot with min lambda shown tidied <- tidy(cvfit1$glmnet.fit) ggplot(tidied, aes(lambda, estimate, group = term)) + scale_x_log10() + geom_line() + geom_vline(xintercept = glance_cv$lambda.min) + geom_vline(xintercept = glance_cv$lambda.1se, lty = 2)
Glance accepts a model object and returns a tibble::tibble()
with exactly one row of model summaries. The summaries are typically
goodness of fit measures, p-values for hypothesis tests on residuals,
or model convergence information.
Glance never returns information from the original call to the modeling function. This includes the name of the modeling function or any arguments passed to the modeling function.
Glance does not calculate summary measures. Rather, it farms out these
computations to appropriate methods and gathers the results together.
Sometimes a goodness of fit measure will be undefined. In these cases
the measure will be reported as NA
.
Glance returns the same number of columns regardless of whether the
model matrix is rank-deficient or not. If so, entries in columns
that no longer have a well-defined value are filled in with an NA
of the appropriate type.
## S3 method for class 'drc' glance(x, ...)
## S3 method for class 'drc' glance(x, ...)
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with exactly one row and columns:
AIC |
Akaike's Information Criterion for the model. |
BIC |
Bayesian Information Criterion for the model. |
df.residual |
Residual degrees of freedom. |
logLik |
The log-likelihood of the model. [stats::logLik()] may be a useful reference. |
AICc |
AIC corrected for small samples |
Other drc tidiers:
augment.drc()
,
tidy.drc()
# load libraries for models and data library(drc) # fit model mod <- drm(dead / total ~ conc, type, weights = total, data = selenium, fct = LL.2(), type = "binomial" ) # summarize model fit with tidiers tidy(mod) tidy(mod, conf.int = TRUE) glance(mod) augment(mod, selenium)
# load libraries for models and data library(drc) # fit model mod <- drm(dead / total ~ conc, type, weights = total, data = selenium, fct = LL.2(), type = "binomial" ) # summarize model fit with tidiers tidy(mod) tidy(mod, conf.int = TRUE) glance(mod) augment(mod, selenium)
Glance accepts a model object and returns a tibble::tibble()
with exactly one row of model summaries. The summaries are typically
goodness of fit measures, p-values for hypothesis tests on residuals,
or model convergence information.
Glance never returns information from the original call to the modeling function. This includes the name of the modeling function or any arguments passed to the modeling function.
Glance does not calculate summary measures. Rather, it farms out these
computations to appropriate methods and gathers the results together.
Sometimes a goodness of fit measure will be undefined. In these cases
the measure will be reported as NA
.
Glance returns the same number of columns regardless of whether the
model matrix is rank-deficient or not. If so, entries in columns
that no longer have a well-defined value are filled in with an NA
of the appropriate type.
## S3 method for class 'ergm' glance(x, deviance = FALSE, mcmc = FALSE, ...)
## S3 method for class 'ergm' glance(x, deviance = FALSE, mcmc = FALSE, ...)
x |
An |
deviance |
Logical indicating whether or not to report null and
residual deviance for the model, as well as degrees of freedom. Defaults
to |
mcmc |
Logical indicating whether or not to report MCMC interval,
burn-in and sample size used to estimate the model. Defaults to |
... |
Additional arguments to pass to |
glance.ergm
returns a one-row tibble with the columns
independence |
Whether the model assumed dyadic independence |
iterations |
The number of MCMLE iterations performed before convergence |
logLik |
If applicable, the log-likelihood associated with the model |
AIC |
The Akaike Information Criterion |
BIC |
The Bayesian Information Criterion |
If deviance = TRUE
, and if the model supports it, the
tibble will also contain the columns
null.deviance |
The null deviance of the model |
df.null |
The degrees of freedom of the null deviance |
residual.deviance |
The residual deviance of the model |
df.residual |
The degrees of freedom of the residual deviance |
glance()
, ergm::ergm()
, ergm::summary.ergm()
Other ergm tidiers:
tidy.ergm()
Glance accepts a model object and returns a tibble::tibble()
with exactly one row of model summaries. The summaries are typically
goodness of fit measures, p-values for hypothesis tests on residuals,
or model convergence information.
Glance never returns information from the original call to the modeling function. This includes the name of the modeling function or any arguments passed to the modeling function.
Glance does not calculate summary measures. Rather, it farms out these
computations to appropriate methods and gathers the results together.
Sometimes a goodness of fit measure will be undefined. In these cases
the measure will be reported as NA
.
Glance returns the same number of columns regardless of whether the
model matrix is rank-deficient or not. If so, entries in columns
that no longer have a well-defined value are filled in with an NA
of the appropriate type.
## S3 method for class 'factanal' glance(x, ...)
## S3 method for class 'factanal' glance(x, ...)
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with exactly one row and columns:
converged |
Logical indicating if the model fitting procedure was succesful and converged. |
df |
Degrees of freedom used by the model. |
method |
Which method was used. |
n |
The total number of observations. |
n.factors |
The number of fitted factors. |
nobs |
Number of observations used. |
p.value |
P-value corresponding to the test statistic. |
statistic |
Test statistic. |
total.variance |
Total cumulative proportion of variance accounted for by all factors. |
Other factanal tidiers:
augment.factanal()
,
tidy.factanal()
set.seed(123) # generate data library(dplyr) library(purrr) m1 <- tibble( v1 = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 4, 5, 6), v2 = c(1, 2, 1, 1, 1, 1, 2, 1, 2, 1, 3, 4, 3, 3, 3, 4, 6, 5), v3 = c(3, 3, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 4, 6), v4 = c(3, 3, 4, 3, 3, 1, 1, 2, 1, 1, 1, 1, 2, 1, 1, 5, 6, 4), v5 = c(1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 1, 1, 1, 1, 1, 6, 4, 5), v6 = c(1, 1, 1, 2, 1, 3, 3, 3, 4, 3, 1, 1, 1, 2, 1, 6, 5, 4) ) # new data m2 <- map_dfr(m1, rev) # factor analysis objects fit1 <- factanal(m1, factors = 3, scores = "Bartlett") fit2 <- factanal(m1, factors = 3, scores = "regression") # tidying the object tidy(fit1) tidy(fit2) # augmented dataframe augment(fit1) augment(fit2) # augmented dataframe (with new data) augment(fit1, data = m2) augment(fit2, data = m2)
set.seed(123) # generate data library(dplyr) library(purrr) m1 <- tibble( v1 = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 4, 5, 6), v2 = c(1, 2, 1, 1, 1, 1, 2, 1, 2, 1, 3, 4, 3, 3, 3, 4, 6, 5), v3 = c(3, 3, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 4, 6), v4 = c(3, 3, 4, 3, 3, 1, 1, 2, 1, 1, 1, 1, 2, 1, 1, 5, 6, 4), v5 = c(1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 1, 1, 1, 1, 1, 6, 4, 5), v6 = c(1, 1, 1, 2, 1, 3, 3, 3, 4, 3, 1, 1, 1, 2, 1, 6, 5, 4) ) # new data m2 <- map_dfr(m1, rev) # factor analysis objects fit1 <- factanal(m1, factors = 3, scores = "Bartlett") fit2 <- factanal(m1, factors = 3, scores = "regression") # tidying the object tidy(fit1) tidy(fit2) # augmented dataframe augment(fit1) augment(fit2) # augmented dataframe (with new data) augment(fit1, data = m2) augment(fit2, data = m2)
Glance accepts a model object and returns a tibble::tibble()
with exactly one row of model summaries. The summaries are typically
goodness of fit measures, p-values for hypothesis tests on residuals,
or model convergence information.
Glance never returns information from the original call to the modeling function. This includes the name of the modeling function or any arguments passed to the modeling function.
Glance does not calculate summary measures. Rather, it farms out these
computations to appropriate methods and gathers the results together.
Sometimes a goodness of fit measure will be undefined. In these cases
the measure will be reported as NA
.
Glance returns the same number of columns regardless of whether the
model matrix is rank-deficient or not. If so, entries in columns
that no longer have a well-defined value are filled in with an NA
of the appropriate type.
## S3 method for class 'felm' glance(x, ...)
## S3 method for class 'felm' glance(x, ...)
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with exactly one row and columns:
adj.r.squared |
Adjusted R squared statistic, which is like the R squared statistic except taking degrees of freedom into account. |
df |
Degrees of freedom used by the model. |
df.residual |
Residual degrees of freedom. |
nobs |
Number of observations used. |
p.value |
P-value corresponding to the test statistic. |
r.squared |
R squared statistic, or the percent of variation explained by the model. Also known as the coefficient of determination. |
sigma |
Estimated standard error of the residuals. |
statistic |
Test statistic. |
# load libraries for models and data library(lfe) # use built-in `airquality` dataset head(airquality) # no FEs; same as lm() est0 <- felm(Ozone ~ Temp + Wind + Solar.R, airquality) # summarize model fit with tidiers tidy(est0) augment(est0) # add month fixed effects est1 <- felm(Ozone ~ Temp + Wind + Solar.R | Month, airquality) # summarize model fit with tidiers tidy(est1) tidy(est1, fe = TRUE) augment(est1) glance(est1) # the "se.type" argument can be used to switch out different standard errors # types on the fly. In turn, this can be useful exploring the effect of # different error structures on model inference. tidy(est1, se.type = "iid") tidy(est1, se.type = "robust") # add clustered SEs (also by month) est2 <- felm(Ozone ~ Temp + Wind + Solar.R | Month | 0 | Month, airquality) # summarize model fit with tidiers tidy(est2, conf.int = TRUE) tidy(est2, conf.int = TRUE, se.type = "cluster") tidy(est2, conf.int = TRUE, se.type = "robust") tidy(est2, conf.int = TRUE, se.type = "iid")
# load libraries for models and data library(lfe) # use built-in `airquality` dataset head(airquality) # no FEs; same as lm() est0 <- felm(Ozone ~ Temp + Wind + Solar.R, airquality) # summarize model fit with tidiers tidy(est0) augment(est0) # add month fixed effects est1 <- felm(Ozone ~ Temp + Wind + Solar.R | Month, airquality) # summarize model fit with tidiers tidy(est1) tidy(est1, fe = TRUE) augment(est1) glance(est1) # the "se.type" argument can be used to switch out different standard errors # types on the fly. In turn, this can be useful exploring the effect of # different error structures on model inference. tidy(est1, se.type = "iid") tidy(est1, se.type = "robust") # add clustered SEs (also by month) est2 <- felm(Ozone ~ Temp + Wind + Solar.R | Month | 0 | Month, airquality) # summarize model fit with tidiers tidy(est2, conf.int = TRUE) tidy(est2, conf.int = TRUE, se.type = "cluster") tidy(est2, conf.int = TRUE, se.type = "robust") tidy(est2, conf.int = TRUE, se.type = "iid")
Glance accepts a model object and returns a tibble::tibble()
with exactly one row of model summaries. The summaries are typically
goodness of fit measures, p-values for hypothesis tests on residuals,
or model convergence information.
Glance never returns information from the original call to the modeling function. This includes the name of the modeling function or any arguments passed to the modeling function.
Glance does not calculate summary measures. Rather, it farms out these
computations to appropriate methods and gathers the results together.
Sometimes a goodness of fit measure will be undefined. In these cases
the measure will be reported as NA
.
Glance returns the same number of columns regardless of whether the
model matrix is rank-deficient or not. If so, entries in columns
that no longer have a well-defined value are filled in with an NA
of the appropriate type.
## S3 method for class 'fitdistr' glance(x, ...)
## S3 method for class 'fitdistr' glance(x, ...)
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with exactly one row and columns:
AIC |
Akaike's Information Criterion for the model. |
BIC |
Bayesian Information Criterion for the model. |
logLik |
The log-likelihood of the model. [stats::logLik()] may be a useful reference. |
nobs |
Number of observations used. |
Other fitdistr tidiers:
tidy.fitdistr()
# load libraries for models and data library(MASS) # generate data set.seed(2015) x <- rnorm(100, 5, 2) # fit models fit <- fitdistr(x, dnorm, list(mean = 3, sd = 1)) # summarize model fit with tidiers tidy(fit) glance(fit)
# load libraries for models and data library(MASS) # generate data set.seed(2015) x <- rnorm(100, 5, 2) # fit models fit <- fitdistr(x, dnorm, list(mean = 3, sd = 1)) # summarize model fit with tidiers tidy(fit) glance(fit)
Glance accepts a model object and returns a tibble::tibble()
with exactly one row of model summaries. The summaries are typically
goodness of fit measures, p-values for hypothesis tests on residuals,
or model convergence information.
Glance never returns information from the original call to the modeling function. This includes the name of the modeling function or any arguments passed to the modeling function.
Glance does not calculate summary measures. Rather, it farms out these
computations to appropriate methods and gathers the results together.
Sometimes a goodness of fit measure will be undefined. In these cases
the measure will be reported as NA
.
Glance returns the same number of columns regardless of whether the
model matrix is rank-deficient or not. If so, entries in columns
that no longer have a well-defined value are filled in with an NA
of the appropriate type.
## S3 method for class 'fixest' glance(x, ...)
## S3 method for class 'fixest' glance(x, ...)
x |
A |
... |
Additional arguments passed to |
A tibble::tibble()
with exactly one row and columns:
adj.r.squared |
Adjusted R squared statistic, which is like the R squared statistic except taking degrees of freedom into account. |
AIC |
Akaike's Information Criterion for the model. |
BIC |
Bayesian Information Criterion for the model. |
logLik |
The log-likelihood of the model. [stats::logLik()] may be a useful reference. |
nobs |
Number of observations used. |
pseudo.r.squared |
Like the R squared statistic, but for situations when the R squared statistic isn't defined. |
r.squared |
R squared statistic, or the percent of variation explained by the model. Also known as the coefficient of determination. |
sigma |
Estimated standard error of the residuals. |
within.r.squared |
R squared within fixed-effect groups. |
All columns listed below will be returned, but some will be NA
,
depending on the type of model estimated. sigma
, r.squared
,
adj.r.squared
, and within.r.squared
will be NA for any model other than
feols
. pseudo.r.squared
will be NA for feols
.
# load libraries for models and data library(fixest) gravity <- feols( log(Euros) ~ log(dist_km) | Origin + Destination + Product + Year, trade ) tidy(gravity) glance(gravity) augment(gravity, trade) # to get robust or clustered SEs, users can either: # 1) specify the arguments directly in the `tidy()` call tidy(gravity, conf.int = TRUE, cluster = c("Product", "Year")) tidy(gravity, conf.int = TRUE, se = "threeway") # 2) or, feed tidy() a summary.fixest object that has already accepted # these arguments gravity_summ <- summary(gravity, cluster = c("Product", "Year")) tidy(gravity_summ, conf.int = TRUE) # approach (1) is preferred.
# load libraries for models and data library(fixest) gravity <- feols( log(Euros) ~ log(dist_km) | Origin + Destination + Product + Year, trade ) tidy(gravity) glance(gravity) augment(gravity, trade) # to get robust or clustered SEs, users can either: # 1) specify the arguments directly in the `tidy()` call tidy(gravity, conf.int = TRUE, cluster = c("Product", "Year")) tidy(gravity, conf.int = TRUE, se = "threeway") # 2) or, feed tidy() a summary.fixest object that has already accepted # these arguments gravity_summ <- summary(gravity, cluster = c("Product", "Year")) tidy(gravity_summ, conf.int = TRUE) # approach (1) is preferred.
Glance accepts a model object and returns a tibble::tibble()
with exactly one row of model summaries. The summaries are typically
goodness of fit measures, p-values for hypothesis tests on residuals,
or model convergence information.
Glance never returns information from the original call to the modeling function. This includes the name of the modeling function or any arguments passed to the modeling function.
Glance does not calculate summary measures. Rather, it farms out these
computations to appropriate methods and gathers the results together.
Sometimes a goodness of fit measure will be undefined. In these cases
the measure will be reported as NA
.
Glance returns the same number of columns regardless of whether the
model matrix is rank-deficient or not. If so, entries in columns
that no longer have a well-defined value are filled in with an NA
of the appropriate type.
## S3 method for class 'gam' glance(x, ...)
## S3 method for class 'gam' glance(x, ...)
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with exactly one row and columns:
adj.r.squared |
Adjusted R squared statistic, which is like the R squared statistic except taking degrees of freedom into account. |
AIC |
Akaike's Information Criterion for the model. |
BIC |
Bayesian Information Criterion for the model. |
deviance |
Deviance of the model. |
df |
Degrees of freedom used by the model. |
df.residual |
Residual degrees of freedom. |
logLik |
The log-likelihood of the model. [stats::logLik()] may be a useful reference. |
nobs |
Number of observations used. |
npar |
Number of parameters in the model. |
Other mgcv tidiers:
tidy.gam()
# load libraries for models and data library(mgcv) # fit model g <- gam(mpg ~ s(hp) + am + qsec, data = mtcars) # summarize model fit with tidiers tidy(g) tidy(g, parametric = TRUE) glance(g) augment(g)
# load libraries for models and data library(mgcv) # fit model g <- gam(mpg ~ s(hp) + am + qsec, data = mtcars) # summarize model fit with tidiers tidy(g) tidy(g, parametric = TRUE) glance(g) augment(g)
Glance accepts a model object and returns a tibble::tibble()
with exactly one row of model summaries. The summaries are typically
goodness of fit measures, p-values for hypothesis tests on residuals,
or model convergence information.
Glance never returns information from the original call to the modeling function. This includes the name of the modeling function or any arguments passed to the modeling function.
Glance does not calculate summary measures. Rather, it farms out these
computations to appropriate methods and gathers the results together.
Sometimes a goodness of fit measure will be undefined. In these cases
the measure will be reported as NA
.
Glance returns the same number of columns regardless of whether the
model matrix is rank-deficient or not. If so, entries in columns
that no longer have a well-defined value are filled in with an NA
of the appropriate type.
## S3 method for class 'Gam' glance(x, ...)
## S3 method for class 'Gam' glance(x, ...)
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Glance at gam
objects created by calls to mgcv::gam()
with
glance.gam()
.
A tibble::tibble()
with exactly one row and columns:
AIC |
Akaike's Information Criterion for the model. |
BIC |
Bayesian Information Criterion for the model. |
deviance |
Deviance of the model. |
df |
Degrees of freedom used by the model. |
df.residual |
Residual degrees of freedom. |
logLik |
The log-likelihood of the model. [stats::logLik()] may be a useful reference. |
nobs |
Number of observations used. |
Other gam tidiers:
tidy.Gam()
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'garch' glance(x, test = c("box-ljung-test", "jarque-bera-test"), ...)
## S3 method for class 'garch' glance(x, test = c("box-ljung-test", "jarque-bera-test"), ...)
x |
A |
test |
Character specification of which hypothesis test to use. The
|
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with exactly one row and columns:
AIC |
Akaike's Information Criterion for the model. |
BIC |
Bayesian Information Criterion for the model. |
logLik |
The log-likelihood of the model. [stats::logLik()] may be a useful reference. |
method |
Which method was used. |
nobs |
Number of observations used. |
p.value |
P-value corresponding to the test statistic. |
statistic |
Test statistic. |
parameter |
Parameter field in the htest, typically degrees of freedom. |
glance()
, tseries::garch()
, []
Other garch tidiers:
tidy.garch()
Glance accepts a model object and returns a tibble::tibble()
with exactly one row of model summaries. The summaries are typically
goodness of fit measures, p-values for hypothesis tests on residuals,
or model convergence information.
Glance never returns information from the original call to the modeling function. This includes the name of the modeling function or any arguments passed to the modeling function.
Glance does not calculate summary measures. Rather, it farms out these
computations to appropriate methods and gathers the results together.
Sometimes a goodness of fit measure will be undefined. In these cases
the measure will be reported as NA
.
Glance returns the same number of columns regardless of whether the
model matrix is rank-deficient or not. If so, entries in columns
that no longer have a well-defined value are filled in with an NA
of the appropriate type.
## S3 method for class 'geeglm' glance(x, ...)
## S3 method for class 'geeglm' glance(x, ...)
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with exactly one row and columns:
alpha |
Estimated correlation parameter for geepack::geeglm. |
df.residual |
Residual degrees of freedom. |
gamma |
Estimated scale parameter for geepack::geeglm. |
max.cluster.size |
Max number of elements in clusters. |
n.clusters |
Number of clusters. |
# load modeling library library(geepack) # load data data(state) ds <- data.frame(state.region, state.x77) # fit model geefit <- geeglm(Income ~ Frost + Murder, id = state.region, data = ds, corstr = "exchangeable" ) # summarize model fit with tidiers tidy(geefit) tidy(geefit, conf.int = TRUE)
# load modeling library library(geepack) # load data data(state) ds <- data.frame(state.region, state.x77) # fit model geefit <- geeglm(Income ~ Frost + Murder, id = state.region, data = ds, corstr = "exchangeable" ) # summarize model fit with tidiers tidy(geefit) tidy(geefit, conf.int = TRUE)
Glance accepts a model object and returns a tibble::tibble()
with exactly one row of model summaries. The summaries are typically
goodness of fit measures, p-values for hypothesis tests on residuals,
or model convergence information.
Glance never returns information from the original call to the modeling function. This includes the name of the modeling function or any arguments passed to the modeling function.
Glance does not calculate summary measures. Rather, it farms out these
computations to appropriate methods and gathers the results together.
Sometimes a goodness of fit measure will be undefined. In these cases
the measure will be reported as NA
.
Glance returns the same number of columns regardless of whether the
model matrix is rank-deficient or not. If so, entries in columns
that no longer have a well-defined value are filled in with an NA
of the appropriate type.
## S3 method for class 'glm' glance(x, ...)
## S3 method for class 'glm' glance(x, ...)
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with exactly one row and columns:
AIC |
Akaike's Information Criterion for the model. |
BIC |
Bayesian Information Criterion for the model. |
deviance |
Deviance of the model. |
df.null |
Degrees of freedom used by the null model. |
df.residual |
Residual degrees of freedom. |
logLik |
The log-likelihood of the model. [stats::logLik()] may be a useful reference. |
nobs |
Number of observations used. |
null.deviance |
Deviance of the null model. |
Other lm tidiers:
augment.glm()
,
augment.lm()
,
glance.lm()
,
glance.summary.lm()
,
glance.svyglm()
,
tidy.glm()
,
tidy.lm()
,
tidy.lm.beta()
,
tidy.mlm()
,
tidy.summary.lm()
g <- glm(am ~ mpg, mtcars, family = "binomial") glance(g)
g <- glm(am ~ mpg, mtcars, family = "binomial") glance(g)
Glance accepts a model object and returns a tibble::tibble()
with exactly one row of model summaries. The summaries are typically
goodness of fit measures, p-values for hypothesis tests on residuals,
or model convergence information.
Glance never returns information from the original call to the modeling function. This includes the name of the modeling function or any arguments passed to the modeling function.
Glance does not calculate summary measures. Rather, it farms out these
computations to appropriate methods and gathers the results together.
Sometimes a goodness of fit measure will be undefined. In these cases
the measure will be reported as NA
.
Glance returns the same number of columns regardless of whether the
model matrix is rank-deficient or not. If so, entries in columns
that no longer have a well-defined value are filled in with an NA
of the appropriate type.
## S3 method for class 'glmnet' glance(x, ...)
## S3 method for class 'glmnet' glance(x, ...)
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with exactly one row and columns:
nobs |
Number of observations used. |
npasses |
Total passes over the data across all lambda values. |
nulldev |
Null deviance. |
Other glmnet tidiers:
glance.cv.glmnet()
,
tidy.cv.glmnet()
,
tidy.glmnet()
# load libraries for models and data library(glmnet) set.seed(2014) x <- matrix(rnorm(100 * 20), 100, 20) y <- rnorm(100) fit1 <- glmnet(x, y) # summarize model fit with tidiers + visualization tidy(fit1) glance(fit1) library(dplyr) library(ggplot2) tidied <- tidy(fit1) %>% filter(term != "(Intercept)") ggplot(tidied, aes(step, estimate, group = term)) + geom_line() ggplot(tidied, aes(lambda, estimate, group = term)) + geom_line() + scale_x_log10() ggplot(tidied, aes(lambda, dev.ratio)) + geom_line() # works for other types of regressions as well, such as logistic g2 <- sample(1:2, 100, replace = TRUE) fit2 <- glmnet(x, g2, family = "binomial") tidy(fit2)
# load libraries for models and data library(glmnet) set.seed(2014) x <- matrix(rnorm(100 * 20), 100, 20) y <- rnorm(100) fit1 <- glmnet(x, y) # summarize model fit with tidiers + visualization tidy(fit1) glance(fit1) library(dplyr) library(ggplot2) tidied <- tidy(fit1) %>% filter(term != "(Intercept)") ggplot(tidied, aes(step, estimate, group = term)) + geom_line() ggplot(tidied, aes(lambda, estimate, group = term)) + geom_line() + scale_x_log10() ggplot(tidied, aes(lambda, dev.ratio)) + geom_line() # works for other types of regressions as well, such as logistic g2 <- sample(1:2, 100, replace = TRUE) fit2 <- glmnet(x, g2, family = "binomial") tidy(fit2)
Glance accepts a model object and returns a tibble::tibble()
with exactly one row of model summaries. The summaries are typically
goodness of fit measures, p-values for hypothesis tests on residuals,
or model convergence information.
Glance never returns information from the original call to the modeling function. This includes the name of the modeling function or any arguments passed to the modeling function.
Glance does not calculate summary measures. Rather, it farms out these
computations to appropriate methods and gathers the results together.
Sometimes a goodness of fit measure will be undefined. In these cases
the measure will be reported as NA
.
Glance returns the same number of columns regardless of whether the
model matrix is rank-deficient or not. If so, entries in columns
that no longer have a well-defined value are filled in with an NA
of the appropriate type.
## S3 method for class 'glmRob' glance(x, ...)
## S3 method for class 'glmRob' glance(x, ...)
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with exactly one row and columns:
deviance |
Deviance of the model. |
df.residual |
Residual degrees of freedom. |
nobs |
Number of observations used. |
null.deviance |
Deviance of the null model. |
sigma |
Estimated standard error of the residuals. |
Other robust tidiers:
augment.lmRob()
,
glance.lmRob()
,
tidy.glmRob()
,
tidy.lmRob()
# load libraries for models and data library(robust) # fit model gm <- glmRob(am ~ wt, data = mtcars, family = "binomial") # summarize model fit with tidiers tidy(gm) glance(gm)
# load libraries for models and data library(robust) # fit model gm <- glmRob(am ~ wt, data = mtcars, family = "binomial") # summarize model fit with tidiers tidy(gm) glance(gm)
Glance accepts a model object and returns a tibble::tibble()
with exactly one row of model summaries. The summaries are typically
goodness of fit measures, p-values for hypothesis tests on residuals,
or model convergence information.
Glance never returns information from the original call to the modeling function. This includes the name of the modeling function or any arguments passed to the modeling function.
Glance does not calculate summary measures. Rather, it farms out these
computations to appropriate methods and gathers the results together.
Sometimes a goodness of fit measure will be undefined. In these cases
the measure will be reported as NA
.
Glance returns the same number of columns regardless of whether the
model matrix is rank-deficient or not. If so, entries in columns
that no longer have a well-defined value are filled in with an NA
of the appropriate type.
## S3 method for class 'gmm' glance(x, ...)
## S3 method for class 'gmm' glance(x, ...)
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with exactly one row and columns:
df |
Degrees of freedom used by the model. |
df.residual |
Residual degrees of freedom. |
nobs |
Number of observations used. |
p.value |
P-value corresponding to the test statistic. |
statistic |
Test statistic. |
Other gmm tidiers:
tidy.gmm()
# load libraries for models and data library(gmm) # examples come from the "gmm" package # CAPM test with GMM data(Finance) r <- Finance[1:300, 1:10] rm <- Finance[1:300, "rm"] rf <- Finance[1:300, "rf"] z <- as.matrix(r - rf) t <- nrow(z) zm <- rm - rf h <- matrix(zm, t, 1) res <- gmm(z ~ zm, x = h) # tidy result tidy(res) tidy(res, conf.int = TRUE) tidy(res, conf.int = TRUE, conf.level = .99) # coefficient plot library(ggplot2) library(dplyr) tidy(res, conf.int = TRUE) %>% mutate(variable = reorder(term, estimate)) %>% ggplot(aes(estimate, variable)) + geom_point() + geom_errorbarh(aes(xmin = conf.low, xmax = conf.high)) + geom_vline(xintercept = 0, color = "red", lty = 2) # from a function instead of a matrix g <- function(theta, x) { e <- x[, 2:11] - theta[1] - (x[, 1] - theta[1]) %*% matrix(theta[2:11], 1, 10) gmat <- cbind(e, e * c(x[, 1])) return(gmat) } x <- as.matrix(cbind(rm, r)) res_black <- gmm(g, x = x, t0 = rep(0, 11)) tidy(res_black) tidy(res_black, conf.int = TRUE) # APT test with Fama-French factors and GMM f1 <- zm f2 <- Finance[1:300, "hml"] - rf f3 <- Finance[1:300, "smb"] - rf h <- cbind(f1, f2, f3) res2 <- gmm(z ~ f1 + f2 + f3, x = h) td2 <- tidy(res2, conf.int = TRUE) td2 # coefficient plot td2 %>% mutate(variable = reorder(term, estimate)) %>% ggplot(aes(estimate, variable)) + geom_point() + geom_errorbarh(aes(xmin = conf.low, xmax = conf.high)) + geom_vline(xintercept = 0, color = "red", lty = 2)
# load libraries for models and data library(gmm) # examples come from the "gmm" package # CAPM test with GMM data(Finance) r <- Finance[1:300, 1:10] rm <- Finance[1:300, "rm"] rf <- Finance[1:300, "rf"] z <- as.matrix(r - rf) t <- nrow(z) zm <- rm - rf h <- matrix(zm, t, 1) res <- gmm(z ~ zm, x = h) # tidy result tidy(res) tidy(res, conf.int = TRUE) tidy(res, conf.int = TRUE, conf.level = .99) # coefficient plot library(ggplot2) library(dplyr) tidy(res, conf.int = TRUE) %>% mutate(variable = reorder(term, estimate)) %>% ggplot(aes(estimate, variable)) + geom_point() + geom_errorbarh(aes(xmin = conf.low, xmax = conf.high)) + geom_vline(xintercept = 0, color = "red", lty = 2) # from a function instead of a matrix g <- function(theta, x) { e <- x[, 2:11] - theta[1] - (x[, 1] - theta[1]) %*% matrix(theta[2:11], 1, 10) gmat <- cbind(e, e * c(x[, 1])) return(gmat) } x <- as.matrix(cbind(rm, r)) res_black <- gmm(g, x = x, t0 = rep(0, 11)) tidy(res_black) tidy(res_black, conf.int = TRUE) # APT test with Fama-French factors and GMM f1 <- zm f2 <- Finance[1:300, "hml"] - rf f3 <- Finance[1:300, "smb"] - rf h <- cbind(f1, f2, f3) res2 <- gmm(z ~ f1 + f2 + f3, x = h) td2 <- tidy(res2, conf.int = TRUE) td2 # coefficient plot td2 %>% mutate(variable = reorder(term, estimate)) %>% ggplot(aes(estimate, variable)) + geom_point() + geom_errorbarh(aes(xmin = conf.low, xmax = conf.high)) + geom_vline(xintercept = 0, color = "red", lty = 2)
Glance accepts a model object and returns a tibble::tibble()
with exactly one row of model summaries. The summaries are typically
goodness of fit measures, p-values for hypothesis tests on residuals,
or model convergence information.
Glance never returns information from the original call to the modeling function. This includes the name of the modeling function or any arguments passed to the modeling function.
Glance does not calculate summary measures. Rather, it farms out these
computations to appropriate methods and gathers the results together.
Sometimes a goodness of fit measure will be undefined. In these cases
the measure will be reported as NA
.
Glance returns the same number of columns regardless of whether the
model matrix is rank-deficient or not. If so, entries in columns
that no longer have a well-defined value are filled in with an NA
of the appropriate type.
## S3 method for class 'ivreg' glance(x, diagnostics = FALSE, ...)
## S3 method for class 'ivreg' glance(x, diagnostics = FALSE, ...)
x |
An |
diagnostics |
Logical indicating whether or not to return the Wu-Hausman and Sargan diagnostic information. |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
This tidier currently only supports ivreg
-classed objects
outputted by the AER
package. The ivreg
package also outputs
objects of class ivreg
, and will be supported in a later release.
A tibble::tibble()
with exactly one row and columns:
adj.r.squared |
Adjusted R squared statistic, which is like the R squared statistic except taking degrees of freedom into account. |
df |
Degrees of freedom used by the model. |
df.residual |
Residual degrees of freedom. |
nobs |
Number of observations used. |
r.squared |
R squared statistic, or the percent of variation explained by the model. Also known as the coefficient of determination. |
sigma |
Estimated standard error of the residuals. |
statistic |
Wald test statistic. |
p.value |
P-value for the Wald test. |
Beginning 0.7.0, glance.ivreg
returns statistics for the
Wu-Hausman test for endogeneity and the Sargan test of
overidentifying restrictions. Sargan test values are returned as NA
if the number of instruments is not greater than the number of
endogenous regressors.
Other ivreg tidiers:
augment.ivreg()
,
tidy.ivreg()
# load libraries for models and data library(AER) # load data data("CigarettesSW", package = "AER") # fit model ivr <- ivreg( log(packs) ~ income | population, data = CigarettesSW, subset = year == "1995" ) # summarize model fit with tidiers tidy(ivr) tidy(ivr, conf.int = TRUE) tidy(ivr, conf.int = TRUE, instruments = TRUE) augment(ivr) augment(ivr, data = CigarettesSW) augment(ivr, newdata = CigarettesSW) glance(ivr)
# load libraries for models and data library(AER) # load data data("CigarettesSW", package = "AER") # fit model ivr <- ivreg( log(packs) ~ income | population, data = CigarettesSW, subset = year == "1995" ) # summarize model fit with tidiers tidy(ivr) tidy(ivr, conf.int = TRUE) tidy(ivr, conf.int = TRUE, instruments = TRUE) augment(ivr) augment(ivr, data = CigarettesSW) augment(ivr, newdata = CigarettesSW) glance(ivr)
Glance accepts a model object and returns a tibble::tibble()
with exactly one row of model summaries. The summaries are typically
goodness of fit measures, p-values for hypothesis tests on residuals,
or model convergence information.
Glance never returns information from the original call to the modeling function. This includes the name of the modeling function or any arguments passed to the modeling function.
Glance does not calculate summary measures. Rather, it farms out these
computations to appropriate methods and gathers the results together.
Sometimes a goodness of fit measure will be undefined. In these cases
the measure will be reported as NA
.
Glance returns the same number of columns regardless of whether the
model matrix is rank-deficient or not. If so, entries in columns
that no longer have a well-defined value are filled in with an NA
of the appropriate type.
## S3 method for class 'kmeans' glance(x, ...)
## S3 method for class 'kmeans' glance(x, ...)
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with exactly one row and columns:
betweenss |
The total between-cluster sum of squares. |
iter |
Iterations of algorithm/fitting procedure completed. |
tot.withinss |
The total within-cluster sum of squares. |
totss |
The total sum of squares. |
Other kmeans tidiers:
augment.kmeans()
,
tidy.kmeans()
library(cluster) library(modeldata) library(dplyr) data(hpc_data) x <- hpc_data[, 2:5] fit <- pam(x, k = 4) tidy(fit) glance(fit) augment(fit, x)
library(cluster) library(modeldata) library(dplyr) data(hpc_data) x <- hpc_data[, 2:5] fit <- pam(x, k = 4) tidy(fit) glance(fit) augment(fit, x)
Glance accepts a model object and returns a tibble::tibble()
with exactly one row of model summaries. The summaries are typically
goodness of fit measures, p-values for hypothesis tests on residuals,
or model convergence information.
Glance never returns information from the original call to the modeling function. This includes the name of the modeling function or any arguments passed to the modeling function.
Glance does not calculate summary measures. Rather, it farms out these
computations to appropriate methods and gathers the results together.
Sometimes a goodness of fit measure will be undefined. In these cases
the measure will be reported as NA
.
Glance returns the same number of columns regardless of whether the
model matrix is rank-deficient or not. If so, entries in columns
that no longer have a well-defined value are filled in with an NA
of the appropriate type.
## S3 method for class 'lavaan' glance(x, ...)
## S3 method for class 'lavaan' glance(x, ...)
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A one-row tibble::tibble with columns:
chisq |
Model chi squared |
npar |
Number of parameters in the model |
rmsea |
Root mean square error of approximation |
rmsea.conf.high |
95 percent upper bound on RMSEA |
srmr |
Standardised root mean residual |
agfi |
Adjusted goodness of fit |
cfi |
Comparative fit index |
tli |
Tucker Lewis index |
AIC |
Akaike information criterion |
BIC |
Bayesian information criterion |
ngroups |
Number of groups in model |
nobs |
Number of observations included |
norig |
Number of observation in the original dataset |
nexcluded |
Number of excluded observations |
converged |
Logical - Did the model converge |
estimator |
Estimator used |
missing_method |
Method for eliminating missing data |
For further recommendations on reporting SEM and CFA models see Schreiber, J. B. (2017). Update to core reporting practices in structural equation modeling. Research in Social and Administrative Pharmacy, 13(3), 634-643. https://doi.org/10.1016/j.sapharm.2016.06.006
glance()
, lavaan::cfa()
, lavaan::sem()
,
lavaan::fitmeasures()
Other lavaan tidiers:
tidy.lavaan()
library(lavaan) # fit model cfa.fit <- cfa( "F =~ x1 + x2 + x3 + x4 + x5", data = HolzingerSwineford1939, group = "school" ) # summarize model fit with tidiers glance(cfa.fit)
library(lavaan) # fit model cfa.fit <- cfa( "F =~ x1 + x2 + x3 + x4 + x5", data = HolzingerSwineford1939, group = "school" ) # summarize model fit with tidiers glance(cfa.fit)
Glance accepts a model object and returns a tibble::tibble()
with exactly one row of model summaries. The summaries are typically
goodness of fit measures, p-values for hypothesis tests on residuals,
or model convergence information.
Glance never returns information from the original call to the modeling function. This includes the name of the modeling function or any arguments passed to the modeling function.
Glance does not calculate summary measures. Rather, it farms out these
computations to appropriate methods and gathers the results together.
Sometimes a goodness of fit measure will be undefined. In these cases
the measure will be reported as NA
.
Glance returns the same number of columns regardless of whether the
model matrix is rank-deficient or not. If so, entries in columns
that no longer have a well-defined value are filled in with an NA
of the appropriate type.
## S3 method for class 'lm' glance(x, ...)
## S3 method for class 'lm' glance(x, ...)
x |
An |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with exactly one row and columns:
adj.r.squared |
Adjusted R squared statistic, which is like the R squared statistic except taking degrees of freedom into account. |
AIC |
Akaike's Information Criterion for the model. |
BIC |
Bayesian Information Criterion for the model. |
deviance |
Deviance of the model. |
df.residual |
Residual degrees of freedom. |
logLik |
The log-likelihood of the model. [stats::logLik()] may be a useful reference. |
nobs |
Number of observations used. |
p.value |
P-value corresponding to the test statistic. |
r.squared |
R squared statistic, or the percent of variation explained by the model. Also known as the coefficient of determination. |
sigma |
Estimated standard error of the residuals. |
statistic |
Test statistic. |
df |
The degrees for freedom from the numerator of the overall F-statistic. This is new in broom 0.7.0. Previously, this reported the rank of the design matrix, which is one more than the numerator degrees of freedom of the overall F-statistic. |
Other lm tidiers:
augment.glm()
,
augment.lm()
,
glance.glm()
,
glance.summary.lm()
,
glance.svyglm()
,
tidy.glm()
,
tidy.lm()
,
tidy.lm.beta()
,
tidy.mlm()
,
tidy.summary.lm()
library(ggplot2) library(dplyr) mod <- lm(mpg ~ wt + qsec, data = mtcars) tidy(mod) glance(mod) # coefficient plot d <- tidy(mod, conf.int = TRUE) ggplot(d, aes(estimate, term, xmin = conf.low, xmax = conf.high, height = 0)) + geom_point() + geom_vline(xintercept = 0, lty = 4) + geom_errorbarh() # aside: There are tidy() and glance() methods for lm.summary objects too. # this can be useful when you want to conserve memory by converting large lm # objects into their leaner summary.lm equivalents. s <- summary(mod) tidy(s, conf.int = TRUE) glance(s) augment(mod) augment(mod, mtcars, interval = "confidence") # predict on new data newdata <- mtcars %>% head(6) %>% mutate(wt = wt + 1) augment(mod, newdata = newdata) # ggplot2 example where we also construct 95% prediction interval # simpler bivariate model since we're plotting in 2D mod2 <- lm(mpg ~ wt, data = mtcars) au <- augment(mod2, newdata = newdata, interval = "prediction") ggplot(au, aes(wt, mpg)) + geom_point() + geom_line(aes(y = .fitted)) + geom_ribbon(aes(ymin = .lower, ymax = .upper), col = NA, alpha = 0.3) # predict on new data without outcome variable. Output does not include .resid newdata <- newdata %>% select(-mpg) augment(mod, newdata = newdata) au <- augment(mod, data = mtcars) ggplot(au, aes(.hat, .std.resid)) + geom_vline(size = 2, colour = "white", xintercept = 0) + geom_hline(size = 2, colour = "white", yintercept = 0) + geom_point() + geom_smooth(se = FALSE) plot(mod, which = 6) ggplot(au, aes(.hat, .cooksd)) + geom_vline(xintercept = 0, colour = NA) + geom_abline(slope = seq(0, 3, by = 0.5), colour = "white") + geom_smooth(se = FALSE) + geom_point() # column-wise models a <- matrix(rnorm(20), nrow = 10) b <- a + rnorm(length(a)) result <- lm(b ~ a) tidy(result)
library(ggplot2) library(dplyr) mod <- lm(mpg ~ wt + qsec, data = mtcars) tidy(mod) glance(mod) # coefficient plot d <- tidy(mod, conf.int = TRUE) ggplot(d, aes(estimate, term, xmin = conf.low, xmax = conf.high, height = 0)) + geom_point() + geom_vline(xintercept = 0, lty = 4) + geom_errorbarh() # aside: There are tidy() and glance() methods for lm.summary objects too. # this can be useful when you want to conserve memory by converting large lm # objects into their leaner summary.lm equivalents. s <- summary(mod) tidy(s, conf.int = TRUE) glance(s) augment(mod) augment(mod, mtcars, interval = "confidence") # predict on new data newdata <- mtcars %>% head(6) %>% mutate(wt = wt + 1) augment(mod, newdata = newdata) # ggplot2 example where we also construct 95% prediction interval # simpler bivariate model since we're plotting in 2D mod2 <- lm(mpg ~ wt, data = mtcars) au <- augment(mod2, newdata = newdata, interval = "prediction") ggplot(au, aes(wt, mpg)) + geom_point() + geom_line(aes(y = .fitted)) + geom_ribbon(aes(ymin = .lower, ymax = .upper), col = NA, alpha = 0.3) # predict on new data without outcome variable. Output does not include .resid newdata <- newdata %>% select(-mpg) augment(mod, newdata = newdata) au <- augment(mod, data = mtcars) ggplot(au, aes(.hat, .std.resid)) + geom_vline(size = 2, colour = "white", xintercept = 0) + geom_hline(size = 2, colour = "white", yintercept = 0) + geom_point() + geom_smooth(se = FALSE) plot(mod, which = 6) ggplot(au, aes(.hat, .cooksd)) + geom_vline(xintercept = 0, colour = NA) + geom_abline(slope = seq(0, 3, by = 0.5), colour = "white") + geom_smooth(se = FALSE) + geom_point() # column-wise models a <- matrix(rnorm(20), nrow = 10) b <- a + rnorm(length(a)) result <- lm(b ~ a) tidy(result)
Glance accepts a model object and returns a tibble::tibble()
with exactly one row of model summaries. The summaries are typically
goodness of fit measures, p-values for hypothesis tests on residuals,
or model convergence information.
Glance never returns information from the original call to the modeling function. This includes the name of the modeling function or any arguments passed to the modeling function.
Glance does not calculate summary measures. Rather, it farms out these
computations to appropriate methods and gathers the results together.
Sometimes a goodness of fit measure will be undefined. In these cases
the measure will be reported as NA
.
Glance returns the same number of columns regardless of whether the
model matrix is rank-deficient or not. If so, entries in columns
that no longer have a well-defined value are filled in with an NA
of the appropriate type.
## S3 method for class 'lmodel2' glance(x, ...)
## S3 method for class 'lmodel2' glance(x, ...)
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with exactly one row and columns:
nobs |
Number of observations used. |
p.value |
P-value corresponding to the test statistic. |
r.squared |
R squared statistic, or the percent of variation explained by the model. Also known as the coefficient of determination. |
theta |
Angle between OLS lines 'lm(y ~ x)' and 'lm(x ~ y)' |
H |
H statistic for computing confidence interval of major axis slope |
Other lmodel2 tidiers:
tidy.lmodel2()
# load libraries for models and data library(lmodel2) data(mod2ex2) Ex2.res <- lmodel2(Prey ~ Predators, data = mod2ex2, "relative", "relative", 99) Ex2.res # summarize model fit with tidiers + visualization tidy(Ex2.res) glance(Ex2.res) # this allows coefficient plots with ggplot2 library(ggplot2) ggplot(tidy(Ex2.res), aes(estimate, term, color = method)) + geom_point() + geom_errorbarh(aes(xmin = conf.low, xmax = conf.high)) + geom_errorbarh(aes(xmin = conf.low, xmax = conf.high))
# load libraries for models and data library(lmodel2) data(mod2ex2) Ex2.res <- lmodel2(Prey ~ Predators, data = mod2ex2, "relative", "relative", 99) Ex2.res # summarize model fit with tidiers + visualization tidy(Ex2.res) glance(Ex2.res) # this allows coefficient plots with ggplot2 library(ggplot2) ggplot(tidy(Ex2.res), aes(estimate, term, color = method)) + geom_point() + geom_errorbarh(aes(xmin = conf.low, xmax = conf.high)) + geom_errorbarh(aes(xmin = conf.low, xmax = conf.high))
Glance accepts a model object and returns a tibble::tibble()
with exactly one row of model summaries. The summaries are typically
goodness of fit measures, p-values for hypothesis tests on residuals,
or model convergence information.
Glance never returns information from the original call to the modeling function. This includes the name of the modeling function or any arguments passed to the modeling function.
Glance does not calculate summary measures. Rather, it farms out these
computations to appropriate methods and gathers the results together.
Sometimes a goodness of fit measure will be undefined. In these cases
the measure will be reported as NA
.
Glance returns the same number of columns regardless of whether the
model matrix is rank-deficient or not. If so, entries in columns
that no longer have a well-defined value are filled in with an NA
of the appropriate type.
## S3 method for class 'lmrob' glance(x, ...)
## S3 method for class 'lmrob' glance(x, ...)
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
For tidiers for robust models from the MASS package see
tidy.rlm()
.
A tibble::tibble()
with exactly one row and columns:
df.residual |
Residual degrees of freedom. |
r.squared |
R squared statistic, or the percent of variation explained by the model. Also known as the coefficient of determination. |
sigma |
Estimated standard error of the residuals. |
Other robustbase tidiers:
augment.glmrob()
,
augment.lmrob()
,
tidy.glmrob()
,
tidy.lmrob()
if (requireNamespace("robustbase", quietly = TRUE)) { # load libraries for models and data library(robustbase) data(coleman) set.seed(0) m <- lmrob(Y ~ ., data = coleman) tidy(m) augment(m) glance(m) data(carrots) Rfit <- glmrob(cbind(success, total - success) ~ logdose + block, family = binomial, data = carrots, method = "Mqle", control = glmrobMqle.control(tcc = 1.2) ) tidy(Rfit) augment(Rfit) }
if (requireNamespace("robustbase", quietly = TRUE)) { # load libraries for models and data library(robustbase) data(coleman) set.seed(0) m <- lmrob(Y ~ ., data = coleman) tidy(m) augment(m) glance(m) data(carrots) Rfit <- glmrob(cbind(success, total - success) ~ logdose + block, family = binomial, data = carrots, method = "Mqle", control = glmrobMqle.control(tcc = 1.2) ) tidy(Rfit) augment(Rfit) }
Glance accepts a model object and returns a tibble::tibble()
with exactly one row of model summaries. The summaries are typically
goodness of fit measures, p-values for hypothesis tests on residuals,
or model convergence information.
Glance never returns information from the original call to the modeling function. This includes the name of the modeling function or any arguments passed to the modeling function.
Glance does not calculate summary measures. Rather, it farms out these
computations to appropriate methods and gathers the results together.
Sometimes a goodness of fit measure will be undefined. In these cases
the measure will be reported as NA
.
Glance returns the same number of columns regardless of whether the
model matrix is rank-deficient or not. If so, entries in columns
that no longer have a well-defined value are filled in with an NA
of the appropriate type.
## S3 method for class 'lmRob' glance(x, ...)
## S3 method for class 'lmRob' glance(x, ...)
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with exactly one row and columns:
deviance |
Deviance of the model. |
df.residual |
Residual degrees of freedom. |
nobs |
Number of observations used. |
r.squared |
R squared statistic, or the percent of variation explained by the model. Also known as the coefficient of determination. |
sigma |
Estimated standard error of the residuals. |
Other robust tidiers:
augment.lmRob()
,
glance.glmRob()
,
tidy.glmRob()
,
tidy.lmRob()
# load modeling library library(robust) # fit model m <- lmRob(mpg ~ wt, data = mtcars) # summarize model fit with tidiers tidy(m) augment(m) glance(m)
# load modeling library library(robust) # fit model m <- lmRob(mpg ~ wt, data = mtcars) # summarize model fit with tidiers tidy(m) augment(m) glance(m)
Glance accepts a model object and returns a tibble::tibble()
with exactly one row of model summaries. The summaries are typically
goodness of fit measures, p-values for hypothesis tests on residuals,
or model convergence information.
Glance never returns information from the original call to the modeling function. This includes the name of the modeling function or any arguments passed to the modeling function.
Glance does not calculate summary measures. Rather, it farms out these
computations to appropriate methods and gathers the results together.
Sometimes a goodness of fit measure will be undefined. In these cases
the measure will be reported as NA
.
Glance returns the same number of columns regardless of whether the
model matrix is rank-deficient or not. If so, entries in columns
that no longer have a well-defined value are filled in with an NA
of the appropriate type.
## S3 method for class 'margins' glance(x, ...)
## S3 method for class 'margins' glance(x, ...)
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with exactly one row and columns:
adj.r.squared |
Adjusted R squared statistic, which is like the R squared statistic except taking degrees of freedom into account. |
df |
Degrees of freedom used by the model. |
df.residual |
Residual degrees of freedom. |
nobs |
Number of observations used. |
p.value |
P-value corresponding to the test statistic. |
r.squared |
R squared statistic, or the percent of variation explained by the model. Also known as the coefficient of determination. |
sigma |
Estimated standard error of the residuals. |
statistic |
Test statistic. |
# load libraries for models and data library(margins) # example 1: logit model mod_log <- glm(am ~ cyl + hp + wt, data = mtcars, family = binomial) # get tidied "naive" model coefficients tidy(mod_log) # convert to marginal effects with margins() marg_log <- margins(mod_log) # get tidied marginal effects tidy(marg_log) tidy(marg_log, conf.int = TRUE) # requires running the underlying model again. quick for this example glance(marg_log) # augmenting `margins` outputs isn't supported, but # you can get the same info by running on the underlying model augment(mod_log) # example 2: threeway interaction terms mod_ie <- lm(mpg ~ wt * cyl * disp, data = mtcars) # get tidied "naive" model coefficients tidy(mod_ie) # convert to marginal effects with margins() marg_ie0 <- margins(mod_ie) # get tidied marginal effects tidy(marg_ie0) glance(marg_ie0) # marginal effects evaluated at specific values of a variable (here: cyl) marg_ie1 <- margins(mod_ie, at = list(cyl = c(4,6,8))) # summarize model fit with tidiers tidy(marg_ie1) # marginal effects of one interaction variable (here: wt), modulated at # specific values of the two other interaction variables (here: cyl and drat) marg_ie2 <- margins(mod_ie, variables = "wt", at = list(cyl = c(4,6,8), drat = c(3, 3.5, 4))) # summarize model fit with tidiers tidy(marg_ie2)
# load libraries for models and data library(margins) # example 1: logit model mod_log <- glm(am ~ cyl + hp + wt, data = mtcars, family = binomial) # get tidied "naive" model coefficients tidy(mod_log) # convert to marginal effects with margins() marg_log <- margins(mod_log) # get tidied marginal effects tidy(marg_log) tidy(marg_log, conf.int = TRUE) # requires running the underlying model again. quick for this example glance(marg_log) # augmenting `margins` outputs isn't supported, but # you can get the same info by running on the underlying model augment(mod_log) # example 2: threeway interaction terms mod_ie <- lm(mpg ~ wt * cyl * disp, data = mtcars) # get tidied "naive" model coefficients tidy(mod_ie) # convert to marginal effects with margins() marg_ie0 <- margins(mod_ie) # get tidied marginal effects tidy(marg_ie0) glance(marg_ie0) # marginal effects evaluated at specific values of a variable (here: cyl) marg_ie1 <- margins(mod_ie, at = list(cyl = c(4,6,8))) # summarize model fit with tidiers tidy(marg_ie1) # marginal effects of one interaction variable (here: wt), modulated at # specific values of the two other interaction variables (here: cyl and drat) marg_ie2 <- margins(mod_ie, variables = "wt", at = list(cyl = c(4,6,8), drat = c(3, 3.5, 4))) # summarize model fit with tidiers tidy(marg_ie2)
Glance accepts a model object and returns a tibble::tibble()
with exactly one row of model summaries. The summaries are typically
goodness of fit measures, p-values for hypothesis tests on residuals,
or model convergence information.
Glance never returns information from the original call to the modeling function. This includes the name of the modeling function or any arguments passed to the modeling function.
Glance does not calculate summary measures. Rather, it farms out these
computations to appropriate methods and gathers the results together.
Sometimes a goodness of fit measure will be undefined. In these cases
the measure will be reported as NA
.
Glance returns the same number of columns regardless of whether the
model matrix is rank-deficient or not. If so, entries in columns
that no longer have a well-defined value are filled in with an NA
of the appropriate type.
## S3 method for class 'Mclust' glance(x, ...)
## S3 method for class 'Mclust' glance(x, ...)
x |
An |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with exactly one row and columns:
BIC |
Bayesian Information Criterion for the model. |
df |
Degrees of freedom used by the model. |
logLik |
The log-likelihood of the model. [stats::logLik()] may be a useful reference. |
nobs |
Number of observations used. |
model |
A string denoting the model type with optimal BIC |
G |
Number mixture components in optimal model |
hypvol |
If the other model contains a noise component, the value of the hypervolume parameter. Otherwise 'NA'. |
# load library for models and data library(mclust) # load data manipulation libraries library(dplyr) library(tibble) library(purrr) library(tidyr) set.seed(27) centers <- tibble( cluster = factor(1:3), # number points in each cluster num_points = c(100, 150, 50), # x1 coordinate of cluster center x1 = c(5, 0, -3), # x2 coordinate of cluster center x2 = c(-1, 1, -2) ) points <- centers %>% mutate( x1 = map2(num_points, x1, rnorm), x2 = map2(num_points, x2, rnorm) ) %>% select(-num_points, -cluster) %>% unnest(c(x1, x2)) # fit model m <- Mclust(points) # summarize model fit with tidiers tidy(m) augment(m, points) glance(m)
# load library for models and data library(mclust) # load data manipulation libraries library(dplyr) library(tibble) library(purrr) library(tidyr) set.seed(27) centers <- tibble( cluster = factor(1:3), # number points in each cluster num_points = c(100, 150, 50), # x1 coordinate of cluster center x1 = c(5, 0, -3), # x2 coordinate of cluster center x2 = c(-1, 1, -2) ) points <- centers %>% mutate( x1 = map2(num_points, x1, rnorm), x2 = map2(num_points, x2, rnorm) ) %>% select(-num_points, -cluster) %>% unnest(c(x1, x2)) # fit model m <- Mclust(points) # summarize model fit with tidiers tidy(m) augment(m, points) glance(m)
Glance accepts a model object and returns a tibble::tibble()
with exactly one row of model summaries. The summaries are typically
goodness of fit measures, p-values for hypothesis tests on residuals,
or model convergence information.
Glance never returns information from the original call to the modeling function. This includes the name of the modeling function or any arguments passed to the modeling function.
Glance does not calculate summary measures. Rather, it farms out these
computations to appropriate methods and gathers the results together.
Sometimes a goodness of fit measure will be undefined. In these cases
the measure will be reported as NA
.
Glance returns the same number of columns regardless of whether the
model matrix is rank-deficient or not. If so, entries in columns
that no longer have a well-defined value are filled in with an NA
of the appropriate type.
## S3 method for class 'mfx' glance(x, ...) ## S3 method for class 'logitmfx' glance(x, ...) ## S3 method for class 'negbinmfx' glance(x, ...) ## S3 method for class 'poissonmfx' glance(x, ...) ## S3 method for class 'probitmfx' glance(x, ...)
## S3 method for class 'mfx' glance(x, ...) ## S3 method for class 'logitmfx' glance(x, ...) ## S3 method for class 'negbinmfx' glance(x, ...) ## S3 method for class 'poissonmfx' glance(x, ...) ## S3 method for class 'probitmfx' glance(x, ...)
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
This generic glance method wraps glance.glm()
for applicable
objects from the mfx
package.
A tibble::tibble()
with exactly one row and columns:
AIC |
Akaike's Information Criterion for the model. |
BIC |
Bayesian Information Criterion for the model. |
deviance |
Deviance of the model. |
df.null |
Degrees of freedom used by the null model. |
df.residual |
Residual degrees of freedom. |
logLik |
The log-likelihood of the model. [stats::logLik()] may be a useful reference. |
nobs |
Number of observations used. |
null.deviance |
Deviance of the null model. |
glance.glm()
, mfx::logitmfx()
, mfx::negbinmfx()
,
mfx::poissonmfx()
, mfx::probitmfx()
Other mfx tidiers:
augment.betamfx()
,
augment.mfx()
,
glance.betamfx()
,
tidy.betamfx()
,
tidy.mfx()
# load libraries for models and data library(mfx) # get the marginal effects from a logit regression mod_logmfx <- logitmfx(am ~ cyl + hp + wt, atmean = TRUE, data = mtcars) tidy(mod_logmfx, conf.int = TRUE) # compare with the naive model coefficients of the same logit call tidy( glm(am ~ cyl + hp + wt, family = binomial, data = mtcars), conf.int = TRUE ) augment(mod_logmfx) glance(mod_logmfx) # another example, this time using probit regression mod_probmfx <- probitmfx(am ~ cyl + hp + wt, atmean = TRUE, data = mtcars) tidy(mod_probmfx, conf.int = TRUE) augment(mod_probmfx) glance(mod_probmfx)
# load libraries for models and data library(mfx) # get the marginal effects from a logit regression mod_logmfx <- logitmfx(am ~ cyl + hp + wt, atmean = TRUE, data = mtcars) tidy(mod_logmfx, conf.int = TRUE) # compare with the naive model coefficients of the same logit call tidy( glm(am ~ cyl + hp + wt, family = binomial, data = mtcars), conf.int = TRUE ) augment(mod_logmfx) glance(mod_logmfx) # another example, this time using probit regression mod_probmfx <- probitmfx(am ~ cyl + hp + wt, atmean = TRUE, data = mtcars) tidy(mod_probmfx, conf.int = TRUE) augment(mod_probmfx) glance(mod_probmfx)
Glance accepts a model object and returns a tibble::tibble()
with exactly one row of model summaries. The summaries are typically
goodness of fit measures, p-values for hypothesis tests on residuals,
or model convergence information.
Glance never returns information from the original call to the modeling function. This includes the name of the modeling function or any arguments passed to the modeling function.
Glance does not calculate summary measures. Rather, it farms out these
computations to appropriate methods and gathers the results together.
Sometimes a goodness of fit measure will be undefined. In these cases
the measure will be reported as NA
.
Glance returns the same number of columns regardless of whether the
model matrix is rank-deficient or not. If so, entries in columns
that no longer have a well-defined value are filled in with an NA
of the appropriate type.
## S3 method for class 'mjoint' glance(x, ...)
## S3 method for class 'mjoint' glance(x, ...)
x |
An |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with exactly one row and columns:
AIC |
Akaike's Information Criterion for the model. |
BIC |
Bayesian Information Criterion for the model. |
logLik |
The log-likelihood of the model. [stats::logLik()] may be a useful reference. |
sigma2_j |
The square root of the estimated residual variance for the j-th longitudinal process |
Other mjoint tidiers:
tidy.mjoint()
# broom only skips running these examples because the example models take a # while to generate—they should run just fine, though! ## Not run: # load libraries for models and data library(joineRML) # fit a joint model with bivariate longitudinal outcomes data(heart.valve) hvd <- heart.valve[!is.na(heart.valve$log.grad) & !is.na(heart.valve$log.lvmi) & heart.valve$num <= 50, ] fit <- mjoint( formLongFixed = list( "grad" = log.grad ~ time + sex + hs, "lvmi" = log.lvmi ~ time + sex ), formLongRandom = list( "grad" = ~ 1 | num, "lvmi" = ~ time | num ), formSurv = Surv(fuyrs, status) ~ age, data = hvd, inits = list("gamma" = c(0.11, 1.51, 0.80)), timeVar = "time" ) # extract the survival fixed effects tidy(fit) # extract the longitudinal fixed effects tidy(fit, component = "longitudinal") # extract the survival fixed effects with confidence intervals tidy(fit, ci = TRUE) # extract the survival fixed effects with confidence intervals based # on bootstrapped standard errors bSE <- bootSE(fit, nboot = 5, safe.boot = TRUE) tidy(fit, boot_se = bSE, ci = TRUE) # augment original data with fitted longitudinal values and residuals hvd2 <- augment(fit) # extract model statistics glance(fit) ## End(Not run)
# broom only skips running these examples because the example models take a # while to generate—they should run just fine, though! ## Not run: # load libraries for models and data library(joineRML) # fit a joint model with bivariate longitudinal outcomes data(heart.valve) hvd <- heart.valve[!is.na(heart.valve$log.grad) & !is.na(heart.valve$log.lvmi) & heart.valve$num <= 50, ] fit <- mjoint( formLongFixed = list( "grad" = log.grad ~ time + sex + hs, "lvmi" = log.lvmi ~ time + sex ), formLongRandom = list( "grad" = ~ 1 | num, "lvmi" = ~ time | num ), formSurv = Surv(fuyrs, status) ~ age, data = hvd, inits = list("gamma" = c(0.11, 1.51, 0.80)), timeVar = "time" ) # extract the survival fixed effects tidy(fit) # extract the longitudinal fixed effects tidy(fit, component = "longitudinal") # extract the survival fixed effects with confidence intervals tidy(fit, ci = TRUE) # extract the survival fixed effects with confidence intervals based # on bootstrapped standard errors bSE <- bootSE(fit, nboot = 5, safe.boot = TRUE) tidy(fit, boot_se = bSE, ci = TRUE) # augment original data with fitted longitudinal values and residuals hvd2 <- augment(fit) # extract model statistics glance(fit) ## End(Not run)
Glance accepts a model object and returns a tibble::tibble()
with exactly one row of model summaries. The summaries are typically
goodness of fit measures, p-values for hypothesis tests on residuals,
or model convergence information.
Glance never returns information from the original call to the modeling function. This includes the name of the modeling function or any arguments passed to the modeling function.
Glance does not calculate summary measures. Rather, it farms out these
computations to appropriate methods and gathers the results together.
Sometimes a goodness of fit measure will be undefined. In these cases
the measure will be reported as NA
.
Glance returns the same number of columns regardless of whether the
model matrix is rank-deficient or not. If so, entries in columns
that no longer have a well-defined value are filled in with an NA
of the appropriate type.
## S3 method for class 'mlogit' glance(x, ...)
## S3 method for class 'mlogit' glance(x, ...)
x |
an object returned from |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with exactly one row and columns:
AIC |
Akaike's Information Criterion for the model. |
BIC |
Bayesian Information Criterion for the model. |
logLik |
The log-likelihood of the model. [stats::logLik()] may be a useful reference. |
nobs |
Number of observations used. |
rho2 |
McFadden's rho squared with respect to a market shares (constants-only) model. |
rho20 |
McFadden's rho squared with respect to an equal shares (no information) model. |
Other mlogit tidiers:
augment.mlogit()
,
tidy.mlogit()
# load libraries for models and data library(mlogit) data("Fishing", package = "mlogit") Fish <- dfidx(Fishing, varying = 2:9, shape = "wide", choice = "mode") # fit model m <- mlogit(mode ~ price + catch | income, data = Fish) # summarize model fit with tidiers tidy(m) augment(m) glance(m)
# load libraries for models and data library(mlogit) data("Fishing", package = "mlogit") Fish <- dfidx(Fishing, varying = 2:9, shape = "wide", choice = "mode") # fit model m <- mlogit(mode ~ price + catch | income, data = Fish) # summarize model fit with tidiers tidy(m) augment(m) glance(m)
Glance accepts a model object and returns a tibble::tibble()
with exactly one row of model summaries. The summaries are typically
goodness of fit measures, p-values for hypothesis tests on residuals,
or model convergence information.
Glance never returns information from the original call to the modeling function. This includes the name of the modeling function or any arguments passed to the modeling function.
Glance does not calculate summary measures. Rather, it farms out these
computations to appropriate methods and gathers the results together.
Sometimes a goodness of fit measure will be undefined. In these cases
the measure will be reported as NA
.
Glance returns the same number of columns regardless of whether the
model matrix is rank-deficient or not. If so, entries in columns
that no longer have a well-defined value are filled in with an NA
of the appropriate type.
## S3 method for class 'muhaz' glance(x, ...)
## S3 method for class 'muhaz' glance(x, ...)
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with exactly one row and columns:
max.hazard |
Maximal estimated hazard. |
max.time |
The maximum observed event or censoring time. |
min.hazard |
Minimal estimated hazard. |
min.time |
The minimum observed event or censoring time. |
nobs |
Number of observations used. |
Other muhaz tidiers:
tidy.muhaz()
# load libraries for models and data library(muhaz) library(survival) # fit model x <- muhaz(ovarian$futime, ovarian$fustat) # summarize model fit with tidiers tidy(x) glance(x)
# load libraries for models and data library(muhaz) library(survival) # fit model x <- muhaz(ovarian$futime, ovarian$fustat) # summarize model fit with tidiers tidy(x) glance(x)
Glance accepts a model object and returns a tibble::tibble()
with exactly one row of model summaries. The summaries are typically
goodness of fit measures, p-values for hypothesis tests on residuals,
or model convergence information.
Glance never returns information from the original call to the modeling function. This includes the name of the modeling function or any arguments passed to the modeling function.
Glance does not calculate summary measures. Rather, it farms out these
computations to appropriate methods and gathers the results together.
Sometimes a goodness of fit measure will be undefined. In these cases
the measure will be reported as NA
.
Glance returns the same number of columns regardless of whether the
model matrix is rank-deficient or not. If so, entries in columns
that no longer have a well-defined value are filled in with an NA
of the appropriate type.
## S3 method for class 'multinom' glance(x, ...)
## S3 method for class 'multinom' glance(x, ...)
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with exactly one row and columns:
AIC |
Akaike's Information Criterion for the model. |
deviance |
Deviance of the model. |
edf |
The effective degrees of freedom. |
nobs |
Number of observations used. |
Other multinom tidiers:
tidy.multinom()
# load libraries for models and data library(nnet) library(MASS) example(birthwt) bwt.mu <- multinom(low ~ ., bwt) tidy(bwt.mu) glance(bwt.mu) # or, for output from a multinomial logistic regression fit.gear <- multinom(gear ~ mpg + factor(am), data = mtcars) tidy(fit.gear) glance(fit.gear)
# load libraries for models and data library(nnet) library(MASS) example(birthwt) bwt.mu <- multinom(low ~ ., bwt) tidy(bwt.mu) glance(bwt.mu) # or, for output from a multinomial logistic regression fit.gear <- multinom(gear ~ mpg + factor(am), data = mtcars) tidy(fit.gear) glance(fit.gear)
Glance accepts a model object and returns a tibble::tibble()
with exactly one row of model summaries. The summaries are typically
goodness of fit measures, p-values for hypothesis tests on residuals,
or model convergence information.
Glance never returns information from the original call to the modeling function. This includes the name of the modeling function or any arguments passed to the modeling function.
Glance does not calculate summary measures. Rather, it farms out these
computations to appropriate methods and gathers the results together.
Sometimes a goodness of fit measure will be undefined. In these cases
the measure will be reported as NA
.
Glance returns the same number of columns regardless of whether the
model matrix is rank-deficient or not. If so, entries in columns
that no longer have a well-defined value are filled in with an NA
of the appropriate type.
## S3 method for class 'negbin' glance(x, ...)
## S3 method for class 'negbin' glance(x, ...)
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with exactly one row and columns:
AIC |
Akaike's Information Criterion for the model. |
BIC |
Bayesian Information Criterion for the model. |
deviance |
Deviance of the model. |
df.null |
Degrees of freedom used by the null model. |
df.residual |
Residual degrees of freedom. |
logLik |
The log-likelihood of the model. [stats::logLik()] may be a useful reference. |
nobs |
Number of observations used. |
null.deviance |
Deviance of the null model. |
Other glm.nb tidiers:
tidy.negbin()
# load libraries for models and data library(MASS) # fit model r <- glm.nb(Days ~ Sex / (Age + Eth * Lrn), data = quine) # summarize model fit with tidiers tidy(r) glance(r)
# load libraries for models and data library(MASS) # fit model r <- glm.nb(Days ~ Sex / (Age + Eth * Lrn), data = quine) # summarize model fit with tidiers tidy(r) glance(r)
Glance accepts a model object and returns a tibble::tibble()
with exactly one row of model summaries. The summaries are typically
goodness of fit measures, p-values for hypothesis tests on residuals,
or model convergence information.
Glance never returns information from the original call to the modeling function. This includes the name of the modeling function or any arguments passed to the modeling function.
Glance does not calculate summary measures. Rather, it farms out these
computations to appropriate methods and gathers the results together.
Sometimes a goodness of fit measure will be undefined. In these cases
the measure will be reported as NA
.
Glance returns the same number of columns regardless of whether the
model matrix is rank-deficient or not. If so, entries in columns
that no longer have a well-defined value are filled in with an NA
of the appropriate type.
## S3 method for class 'nlrq' glance(x, ...)
## S3 method for class 'nlrq' glance(x, ...)
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with exactly one row and columns:
AIC |
Akaike's Information Criterion for the model. |
BIC |
Bayesian Information Criterion for the model. |
df.residual |
Residual degrees of freedom. |
logLik |
The log-likelihood of the model. [stats::logLik()] may be a useful reference. |
tau |
Quantile. |
Other quantreg tidiers:
augment.nlrq()
,
augment.rq()
,
augment.rqs()
,
glance.rq()
,
tidy.nlrq()
,
tidy.rq()
,
tidy.rqs()
# load modeling library library(quantreg) # build artificial data with multiplicative error set.seed(1) dat <- NULL dat$x <- rep(1:25, 20) dat$y <- SSlogis(dat$x, 10, 12, 2) * rnorm(500, 1, 0.1) # fit the median using nlrq mod <- nlrq(y ~ SSlogis(x, Asym, mid, scal), data = dat, tau = 0.5, trace = TRUE ) # summarize model fit with tidiers tidy(mod) glance(mod) augment(mod)
# load modeling library library(quantreg) # build artificial data with multiplicative error set.seed(1) dat <- NULL dat$x <- rep(1:25, 20) dat$y <- SSlogis(dat$x, 10, 12, 2) * rnorm(500, 1, 0.1) # fit the median using nlrq mod <- nlrq(y ~ SSlogis(x, Asym, mid, scal), data = dat, tau = 0.5, trace = TRUE ) # summarize model fit with tidiers tidy(mod) glance(mod) augment(mod)
Glance accepts a model object and returns a tibble::tibble()
with exactly one row of model summaries. The summaries are typically
goodness of fit measures, p-values for hypothesis tests on residuals,
or model convergence information.
Glance never returns information from the original call to the modeling function. This includes the name of the modeling function or any arguments passed to the modeling function.
Glance does not calculate summary measures. Rather, it farms out these
computations to appropriate methods and gathers the results together.
Sometimes a goodness of fit measure will be undefined. In these cases
the measure will be reported as NA
.
Glance returns the same number of columns regardless of whether the
model matrix is rank-deficient or not. If so, entries in columns
that no longer have a well-defined value are filled in with an NA
of the appropriate type.
## S3 method for class 'nls' glance(x, ...)
## S3 method for class 'nls' glance(x, ...)
x |
An |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with exactly one row and columns:
AIC |
Akaike's Information Criterion for the model. |
BIC |
Bayesian Information Criterion for the model. |
deviance |
Deviance of the model. |
df.residual |
Residual degrees of freedom. |
finTol |
The achieved convergence tolerance. |
isConv |
Whether the fit successfully converged. |
logLik |
The log-likelihood of the model. [stats::logLik()] may be a useful reference. |
nobs |
Number of observations used. |
sigma |
Estimated standard error of the residuals. |
Other nls tidiers:
augment.nls()
,
tidy.nls()
# fit model n <- nls(mpg ~ k * e^wt, data = mtcars, start = list(k = 1, e = 2)) # summarize model fit with tidiers + visualization tidy(n) augment(n) glance(n) library(ggplot2) ggplot(augment(n), aes(wt, mpg)) + geom_point() + geom_line(aes(y = .fitted)) newdata <- head(mtcars) newdata$wt <- newdata$wt + 1 augment(n, newdata = newdata)
# fit model n <- nls(mpg ~ k * e^wt, data = mtcars, start = list(k = 1, e = 2)) # summarize model fit with tidiers + visualization tidy(n) augment(n) glance(n) library(ggplot2) ggplot(augment(n), aes(wt, mpg)) + geom_point() + geom_line(aes(y = .fitted)) newdata <- head(mtcars) newdata$wt <- newdata$wt + 1 augment(n, newdata = newdata)
Glance accepts a model object and returns a tibble::tibble()
with exactly one row of model summaries. The summaries are typically
goodness of fit measures, p-values for hypothesis tests on residuals,
or model convergence information.
Glance never returns information from the original call to the modeling function. This includes the name of the modeling function or any arguments passed to the modeling function.
Glance does not calculate summary measures. Rather, it farms out these
computations to appropriate methods and gathers the results together.
Sometimes a goodness of fit measure will be undefined. In these cases
the measure will be reported as NA
.
Glance returns the same number of columns regardless of whether the
model matrix is rank-deficient or not. If so, entries in columns
that no longer have a well-defined value are filled in with an NA
of the appropriate type.
## S3 method for class 'orcutt' glance(x, ...)
## S3 method for class 'orcutt' glance(x, ...)
x |
An |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with exactly one row and columns:
adj.r.squared |
Adjusted R squared statistic, which is like the R squared statistic except taking degrees of freedom into account. |
dw.original |
Durbin-Watson statistic of original fit. |
dw.transformed |
Durbin-Watson statistic of transformed fit. |
nobs |
Number of observations used. |
number.interaction |
Number of interactions. |
p.value.original |
P-value of original Durbin-Watson statistic. |
p.value.transformed |
P-value of autocorrelation after transformation. |
r.squared |
R squared statistic, or the percent of variation explained by the model. Also known as the coefficient of determination. |
rho |
Spearman's rho autocorrelation |
glance()
, orcutt::cochrane.orcutt()
Other orcutt tidiers:
tidy.orcutt()
# load libraries for models and data library(orcutt) # fit model and summarize results reg <- lm(mpg ~ wt + qsec + disp, mtcars) tidy(reg) co <- cochrane.orcutt(reg) tidy(co) glance(co)
# load libraries for models and data library(orcutt) # fit model and summarize results reg <- lm(mpg ~ wt + qsec + disp, mtcars) tidy(reg) co <- cochrane.orcutt(reg) tidy(co) glance(co)
Glance accepts a model object and returns a tibble::tibble()
with exactly one row of model summaries. The summaries are typically
goodness of fit measures, p-values for hypothesis tests on residuals,
or model convergence information.
Glance never returns information from the original call to the modeling function. This includes the name of the modeling function or any arguments passed to the modeling function.
Glance does not calculate summary measures. Rather, it farms out these
computations to appropriate methods and gathers the results together.
Sometimes a goodness of fit measure will be undefined. In these cases
the measure will be reported as NA
.
Glance returns the same number of columns regardless of whether the
model matrix is rank-deficient or not. If so, entries in columns
that no longer have a well-defined value are filled in with an NA
of the appropriate type.
## S3 method for class 'pam' glance(x, ...)
## S3 method for class 'pam' glance(x, ...)
x |
An |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with exactly one row and columns:
avg.silhouette.width |
The average silhouette width for the dataset. |
Other pam tidiers:
augment.pam()
,
tidy.pam()
# load libraries for models and data library(dplyr) library(ggplot2) library(cluster) library(modeldata) data(hpc_data) x <- hpc_data[, 2:5] p <- pam(x, k = 4) # summarize model fit with tidiers + visualization tidy(p) glance(p) augment(p, x) augment(p, x) %>% ggplot(aes(compounds, input_fields)) + geom_point(aes(color = .cluster)) + geom_text(aes(label = cluster), data = tidy(p), size = 10)
# load libraries for models and data library(dplyr) library(ggplot2) library(cluster) library(modeldata) data(hpc_data) x <- hpc_data[, 2:5] p <- pam(x, k = 4) # summarize model fit with tidiers + visualization tidy(p) glance(p) augment(p, x) augment(p, x) %>% ggplot(aes(compounds, input_fields)) + geom_point(aes(color = .cluster)) + geom_text(aes(label = cluster), data = tidy(p), size = 10)
Glance accepts a model object and returns a tibble::tibble()
with exactly one row of model summaries. The summaries are typically
goodness of fit measures, p-values for hypothesis tests on residuals,
or model convergence information.
Glance never returns information from the original call to the modeling function. This includes the name of the modeling function or any arguments passed to the modeling function.
Glance does not calculate summary measures. Rather, it farms out these
computations to appropriate methods and gathers the results together.
Sometimes a goodness of fit measure will be undefined. In these cases
the measure will be reported as NA
.
Glance returns the same number of columns regardless of whether the
model matrix is rank-deficient or not. If so, entries in columns
that no longer have a well-defined value are filled in with an NA
of the appropriate type.
## S3 method for class 'plm' glance(x, ...)
## S3 method for class 'plm' glance(x, ...)
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with exactly one row and columns:
adj.r.squared |
Adjusted R squared statistic, which is like the R squared statistic except taking degrees of freedom into account. |
deviance |
Deviance of the model. |
df.residual |
Residual degrees of freedom. |
nobs |
Number of observations used. |
p.value |
P-value corresponding to the test statistic. |
r.squared |
R squared statistic, or the percent of variation explained by the model. Also known as the coefficient of determination. |
statistic |
F-statistic |
Other plm tidiers:
augment.plm()
,
tidy.plm()
# load libraries for models and data library(plm) # load data data("Produc", package = "plm") # fit model zz <- plm(log(gsp) ~ log(pcap) + log(pc) + log(emp) + unemp, data = Produc, index = c("state", "year") ) # summarize model fit with tidiers summary(zz) tidy(zz) tidy(zz, conf.int = TRUE) tidy(zz, conf.int = TRUE, conf.level = 0.9) augment(zz) glance(zz)
# load libraries for models and data library(plm) # load data data("Produc", package = "plm") # fit model zz <- plm(log(gsp) ~ log(pcap) + log(pc) + log(emp) + unemp, data = Produc, index = c("state", "year") ) # summarize model fit with tidiers summary(zz) tidy(zz) tidy(zz, conf.int = TRUE) tidy(zz, conf.int = TRUE, conf.level = 0.9) augment(zz) glance(zz)
Glance accepts a model object and returns a tibble::tibble()
with exactly one row of model summaries. The summaries are typically
goodness of fit measures, p-values for hypothesis tests on residuals,
or model convergence information.
Glance never returns information from the original call to the modeling function. This includes the name of the modeling function or any arguments passed to the modeling function.
Glance does not calculate summary measures. Rather, it farms out these
computations to appropriate methods and gathers the results together.
Sometimes a goodness of fit measure will be undefined. In these cases
the measure will be reported as NA
.
Glance returns the same number of columns regardless of whether the
model matrix is rank-deficient or not. If so, entries in columns
that no longer have a well-defined value are filled in with an NA
of the appropriate type.
## S3 method for class 'poLCA' glance(x, ...)
## S3 method for class 'poLCA' glance(x, ...)
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with exactly one row and columns:
AIC |
Akaike's Information Criterion for the model. |
BIC |
Bayesian Information Criterion for the model. |
chi.squared |
The Pearson Chi-Square goodness of fit statistic for multiway tables. |
df |
Degrees of freedom used by the model. |
df.residual |
Residual degrees of freedom. |
logLik |
The log-likelihood of the model. [stats::logLik()] may be a useful reference. |
nobs |
Number of observations used. |
g.squared |
The likelihood ratio/deviance statistic |
Other poLCA tidiers:
augment.poLCA()
,
tidy.poLCA()
# load libraries for models and data library(poLCA) library(dplyr) # generate data data(values) f <- cbind(A, B, C, D) ~ 1 # fit model M1 <- poLCA(f, values, nclass = 2, verbose = FALSE) M1 # summarize model fit with tidiers + visualization tidy(M1) augment(M1) glance(M1) library(ggplot2) ggplot(tidy(M1), aes(factor(class), estimate, fill = factor(outcome))) + geom_bar(stat = "identity", width = 1) + facet_wrap(~variable) # three-class model with a single covariate. data(election) f2a <- cbind( MORALG, CARESG, KNOWG, LEADG, DISHONG, INTELG, MORALB, CARESB, KNOWB, LEADB, DISHONB, INTELB ) ~ PARTY nes2a <- poLCA(f2a, election, nclass = 3, nrep = 5, verbose = FALSE) td <- tidy(nes2a) td ggplot(td, aes(outcome, estimate, color = factor(class), group = class)) + geom_line() + facet_wrap(~variable, nrow = 2) + theme(axis.text.x = element_text(angle = 90, hjust = 1)) au <- augment(nes2a) au count(au, .class) # if the original data is provided, it leads to NAs in new columns # for rows that weren't predicted au2 <- augment(nes2a, data = election) au2 dim(au2)
# load libraries for models and data library(poLCA) library(dplyr) # generate data data(values) f <- cbind(A, B, C, D) ~ 1 # fit model M1 <- poLCA(f, values, nclass = 2, verbose = FALSE) M1 # summarize model fit with tidiers + visualization tidy(M1) augment(M1) glance(M1) library(ggplot2) ggplot(tidy(M1), aes(factor(class), estimate, fill = factor(outcome))) + geom_bar(stat = "identity", width = 1) + facet_wrap(~variable) # three-class model with a single covariate. data(election) f2a <- cbind( MORALG, CARESG, KNOWG, LEADG, DISHONG, INTELG, MORALB, CARESB, KNOWB, LEADB, DISHONB, INTELB ) ~ PARTY nes2a <- poLCA(f2a, election, nclass = 3, nrep = 5, verbose = FALSE) td <- tidy(nes2a) td ggplot(td, aes(outcome, estimate, color = factor(class), group = class)) + geom_line() + facet_wrap(~variable, nrow = 2) + theme(axis.text.x = element_text(angle = 90, hjust = 1)) au <- augment(nes2a) au count(au, .class) # if the original data is provided, it leads to NAs in new columns # for rows that weren't predicted au2 <- augment(nes2a, data = election) au2 dim(au2)
Glance accepts a model object and returns a tibble::tibble()
with exactly one row of model summaries. The summaries are typically
goodness of fit measures, p-values for hypothesis tests on residuals,
or model convergence information.
Glance never returns information from the original call to the modeling function. This includes the name of the modeling function or any arguments passed to the modeling function.
Glance does not calculate summary measures. Rather, it farms out these
computations to appropriate methods and gathers the results together.
Sometimes a goodness of fit measure will be undefined. In these cases
the measure will be reported as NA
.
Glance returns the same number of columns regardless of whether the
model matrix is rank-deficient or not. If so, entries in columns
that no longer have a well-defined value are filled in with an NA
of the appropriate type.
## S3 method for class 'polr' glance(x, ...)
## S3 method for class 'polr' glance(x, ...)
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with exactly one row and columns:
AIC |
Akaike's Information Criterion for the model. |
BIC |
Bayesian Information Criterion for the model. |
deviance |
Deviance of the model. |
df.residual |
Residual degrees of freedom. |
edf |
The effective degrees of freedom. |
logLik |
The log-likelihood of the model. [stats::logLik()] may be a useful reference. |
nobs |
Number of observations used. |
Other ordinal tidiers:
augment.clm()
,
augment.polr()
,
glance.clm()
,
glance.clmm()
,
glance.svyolr()
,
tidy.clm()
,
tidy.clmm()
,
tidy.polr()
,
tidy.svyolr()
# load libraries for models and data library(MASS) # fit model fit <- polr(Sat ~ Infl + Type + Cont, weights = Freq, data = housing) # summarize model fit with tidiers tidy(fit, exponentiate = TRUE, conf.int = TRUE) glance(fit) augment(fit, type.predict = "class") fit2 <- polr(factor(gear) ~ am + mpg + qsec, data = mtcars) tidy(fit, p.values = TRUE)
# load libraries for models and data library(MASS) # fit model fit <- polr(Sat ~ Infl + Type + Cont, weights = Freq, data = housing) # summarize model fit with tidiers tidy(fit, exponentiate = TRUE, conf.int = TRUE) glance(fit) augment(fit, type.predict = "class") fit2 <- polr(factor(gear) ~ am + mpg + qsec, data = mtcars) tidy(fit, p.values = TRUE)
Glance accepts a model object and returns a tibble::tibble()
with exactly one row of model summaries. The summaries are typically
goodness of fit measures, p-values for hypothesis tests on residuals,
or model convergence information.
Glance never returns information from the original call to the modeling function. This includes the name of the modeling function or any arguments passed to the modeling function.
Glance does not calculate summary measures. Rather, it farms out these
computations to appropriate methods and gathers the results together.
Sometimes a goodness of fit measure will be undefined. In these cases
the measure will be reported as NA
.
Glance returns the same number of columns regardless of whether the
model matrix is rank-deficient or not. If so, entries in columns
that no longer have a well-defined value are filled in with an NA
of the appropriate type.
## S3 method for class 'pyears' glance(x, ...)
## S3 method for class 'pyears' glance(x, ...)
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with exactly one row and columns:
nobs |
Number of observations used. |
total |
total number of person-years tabulated |
offtable |
total number of person-years off table |
Other pyears tidiers:
tidy.pyears()
Other survival tidiers:
augment.coxph()
,
augment.survreg()
,
glance.aareg()
,
glance.cch()
,
glance.coxph()
,
glance.survdiff()
,
glance.survexp()
,
glance.survfit()
,
glance.survreg()
,
tidy.aareg()
,
tidy.cch()
,
tidy.coxph()
,
tidy.pyears()
,
tidy.survdiff()
,
tidy.survexp()
,
tidy.survfit()
,
tidy.survreg()
# load libraries for models and data library(survival) # generate and format data temp.yr <- tcut(mgus$dxyr, 55:92, labels = as.character(55:91)) temp.age <- tcut(mgus$age, 34:101, labels = as.character(34:100)) ptime <- ifelse(is.na(mgus$pctime), mgus$futime, mgus$pctime) pstat <- ifelse(is.na(mgus$pctime), 0, 1) pfit <- pyears(Surv(ptime / 365.25, pstat) ~ temp.yr + temp.age + sex, mgus, data.frame = TRUE ) # summarize model fit with tidiers tidy(pfit) glance(pfit) # if data.frame argument is not given, different information is present in # output pfit2 <- pyears(Surv(ptime / 365.25, pstat) ~ temp.yr + temp.age + sex, mgus) tidy(pfit2) glance(pfit2)
# load libraries for models and data library(survival) # generate and format data temp.yr <- tcut(mgus$dxyr, 55:92, labels = as.character(55:91)) temp.age <- tcut(mgus$age, 34:101, labels = as.character(34:100)) ptime <- ifelse(is.na(mgus$pctime), mgus$futime, mgus$pctime) pstat <- ifelse(is.na(mgus$pctime), 0, 1) pfit <- pyears(Surv(ptime / 365.25, pstat) ~ temp.yr + temp.age + sex, mgus, data.frame = TRUE ) # summarize model fit with tidiers tidy(pfit) glance(pfit) # if data.frame argument is not given, different information is present in # output pfit2 <- pyears(Surv(ptime / 365.25, pstat) ~ temp.yr + temp.age + sex, mgus) tidy(pfit2) glance(pfit2)
Glance accepts a model object and returns a tibble::tibble()
with exactly one row of model summaries. The summaries are typically
goodness of fit measures, p-values for hypothesis tests on residuals,
or model convergence information.
Glance never returns information from the original call to the modeling function. This includes the name of the modeling function or any arguments passed to the modeling function.
Glance does not calculate summary measures. Rather, it farms out these
computations to appropriate methods and gathers the results together.
Sometimes a goodness of fit measure will be undefined. In these cases
the measure will be reported as NA
.
Glance returns the same number of columns regardless of whether the
model matrix is rank-deficient or not. If so, entries in columns
that no longer have a well-defined value are filled in with an NA
of the appropriate type.
## S3 method for class 'ridgelm' glance(x, ...)
## S3 method for class 'ridgelm' glance(x, ...)
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
This is similar to the output of select.ridgelm
, but it is
returned rather than printed.
A tibble::tibble()
with exactly one row and columns:
kHKB |
modified HKB estimate of the ridge constant |
kLW |
modified L-W estimate of the ridge constant |
lambdaGCV |
choice of lambda that minimizes GCV |
glance()
, MASS::select.ridgelm()
, MASS::lm.ridge()
Other ridgelm tidiers:
tidy.ridgelm()
# load libraries for models and data library(MASS) names(longley)[1] <- "y" # fit model and summarizd results fit1 <- lm.ridge(y ~ ., longley) tidy(fit1) fit2 <- lm.ridge(y ~ ., longley, lambda = seq(0.001, .05, .001)) td2 <- tidy(fit2) g2 <- glance(fit2) # coefficient plot library(ggplot2) ggplot(td2, aes(lambda, estimate, color = term)) + geom_line() # GCV plot ggplot(td2, aes(lambda, GCV)) + geom_line() # add line for the GCV minimizing estimate ggplot(td2, aes(lambda, GCV)) + geom_line() + geom_vline(xintercept = g2$lambdaGCV, col = "red", lty = 2)
# load libraries for models and data library(MASS) names(longley)[1] <- "y" # fit model and summarizd results fit1 <- lm.ridge(y ~ ., longley) tidy(fit1) fit2 <- lm.ridge(y ~ ., longley, lambda = seq(0.001, .05, .001)) td2 <- tidy(fit2) g2 <- glance(fit2) # coefficient plot library(ggplot2) ggplot(td2, aes(lambda, estimate, color = term)) + geom_line() # GCV plot ggplot(td2, aes(lambda, GCV)) + geom_line() # add line for the GCV minimizing estimate ggplot(td2, aes(lambda, GCV)) + geom_line() + geom_vline(xintercept = g2$lambdaGCV, col = "red", lty = 2)
Glance accepts a model object and returns a tibble::tibble()
with exactly one row of model summaries. The summaries are typically
goodness of fit measures, p-values for hypothesis tests on residuals,
or model convergence information.
Glance never returns information from the original call to the modeling function. This includes the name of the modeling function or any arguments passed to the modeling function.
Glance does not calculate summary measures. Rather, it farms out these
computations to appropriate methods and gathers the results together.
Sometimes a goodness of fit measure will be undefined. In these cases
the measure will be reported as NA
.
Glance returns the same number of columns regardless of whether the
model matrix is rank-deficient or not. If so, entries in columns
that no longer have a well-defined value are filled in with an NA
of the appropriate type.
## S3 method for class 'rlm' glance(x, ...)
## S3 method for class 'rlm' glance(x, ...)
x |
An |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with exactly one row and columns:
AIC |
Akaike's Information Criterion for the model. |
BIC |
Bayesian Information Criterion for the model. |
converged |
Logical indicating if the model fitting procedure was succesful and converged. |
deviance |
Deviance of the model. |
logLik |
The log-likelihood of the model. [stats::logLik()] may be a useful reference. |
nobs |
Number of observations used. |
sigma |
Estimated standard error of the residuals. |
Other rlm tidiers:
augment.rlm()
,
tidy.rlm()
# load libraries for models and data library(MASS) # fit model r <- rlm(stack.loss ~ ., stackloss) # summarize model fit with tidiers tidy(r) augment(r) glance(r)
# load libraries for models and data library(MASS) # fit model r <- rlm(stack.loss ~ ., stackloss) # summarize model fit with tidiers tidy(r) augment(r) glance(r)
Glance accepts a model object and returns a tibble::tibble()
with exactly one row of model summaries. The summaries are typically
goodness of fit measures, p-values for hypothesis tests on residuals,
or model convergence information.
Glance never returns information from the original call to the modeling function. This includes the name of the modeling function or any arguments passed to the modeling function.
Glance does not calculate summary measures. Rather, it farms out these
computations to appropriate methods and gathers the results together.
Sometimes a goodness of fit measure will be undefined. In these cases
the measure will be reported as NA
.
Glance returns the same number of columns regardless of whether the
model matrix is rank-deficient or not. If so, entries in columns
that no longer have a well-defined value are filled in with an NA
of the appropriate type.
## S3 method for class 'rma' glance(x, ...)
## S3 method for class 'rma' glance(x, ...)
x |
An |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with exactly one row and columns:
cochran.qe |
In meta-analysis, test statistic for the Cochran's Q_e test of residual heterogeneity. |
cochran.qm |
In meta-analysis, test statistic for the Cochran's Q_m omnibus test of coefficients. |
df.residual |
Residual degrees of freedom. |
h.squared |
Value of the H-Squared statistic. |
i.squared |
Value of the I-Squared statistic. |
measure |
The measure used in the meta-analysis. |
method |
Which method was used. |
nobs |
Number of observations used. |
p.value.cochran.qe |
In meta-analysis, p-value for the Cochran's Q_e test of residual heterogeneity. |
p.value.cochran.qm |
In meta-analysis, p-value for the Cochran's Q_m omnibus test of coefficients. |
tau.squared |
In meta-analysis, estimated amount of residual heterogeneity. |
tau.squared.se |
In meta-analysis, standard error of residual heterogeneity. |
library(metafor) df <- escalc( measure = "RR", ai = tpos, bi = tneg, ci = cpos, di = cneg, data = dat.bcg ) meta_analysis <- rma(yi, vi, data = df, method = "EB") glance(meta_analysis)
library(metafor) df <- escalc( measure = "RR", ai = tpos, bi = tneg, ci = cpos, di = cneg, data = dat.bcg ) meta_analysis <- rma(yi, vi, data = df, method = "EB") glance(meta_analysis)
Glance accepts a model object and returns a tibble::tibble()
with exactly one row of model summaries. The summaries are typically
goodness of fit measures, p-values for hypothesis tests on residuals,
or model convergence information.
Glance never returns information from the original call to the modeling function. This includes the name of the modeling function or any arguments passed to the modeling function.
Glance does not calculate summary measures. Rather, it farms out these
computations to appropriate methods and gathers the results together.
Sometimes a goodness of fit measure will be undefined. In these cases
the measure will be reported as NA
.
Glance returns the same number of columns regardless of whether the
model matrix is rank-deficient or not. If so, entries in columns
that no longer have a well-defined value are filled in with an NA
of the appropriate type.
## S3 method for class 'rq' glance(x, ...)
## S3 method for class 'rq' glance(x, ...)
x |
An |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Only models with a single tau
value may be passed.
For multiple values, please use a purrr::map()
workflow instead, e.g.
taus %>% map(function(tau_val) rq(y ~ x, tau = tau_val)) %>% map_dfr(glance)
A tibble::tibble()
with exactly one row and columns:
AIC |
Akaike's Information Criterion for the model. |
BIC |
Bayesian Information Criterion for the model. |
df.residual |
Residual degrees of freedom. |
logLik |
The log-likelihood of the model. [stats::logLik()] may be a useful reference. |
tau |
Quantile. |
Other quantreg tidiers:
augment.nlrq()
,
augment.rq()
,
augment.rqs()
,
glance.nlrq()
,
tidy.nlrq()
,
tidy.rq()
,
tidy.rqs()
# load modeling library and data library(quantreg) data(stackloss) # median (l1) regression fit for the stackloss data. mod1 <- rq(stack.loss ~ stack.x, .5) # weighted sample median mod2 <- rq(rnorm(50) ~ 1, weights = runif(50)) # summarize model fit with tidiers tidy(mod1) glance(mod1) augment(mod1) tidy(mod2) glance(mod2) augment(mod2) # varying tau to generate an rqs object mod3 <- rq(stack.loss ~ stack.x, tau = c(.25, .5)) tidy(mod3) augment(mod3) # glance cannot handle rqs objects like `mod3`--use a purrr # `map`-based workflow instead
# load modeling library and data library(quantreg) data(stackloss) # median (l1) regression fit for the stackloss data. mod1 <- rq(stack.loss ~ stack.x, .5) # weighted sample median mod2 <- rq(rnorm(50) ~ 1, weights = runif(50)) # summarize model fit with tidiers tidy(mod1) glance(mod1) augment(mod1) tidy(mod2) glance(mod2) augment(mod2) # varying tau to generate an rqs object mod3 <- rq(stack.loss ~ stack.x, tau = c(.25, .5)) tidy(mod3) augment(mod3) # glance cannot handle rqs objects like `mod3`--use a purrr # `map`-based workflow instead
Glance accepts a model object and returns a tibble::tibble()
with exactly one row of model summaries. The summaries are typically
goodness of fit measures, p-values for hypothesis tests on residuals,
or model convergence information.
Glance never returns information from the original call to the modeling function. This includes the name of the modeling function or any arguments passed to the modeling function.
Glance does not calculate summary measures. Rather, it farms out these
computations to appropriate methods and gathers the results together.
Sometimes a goodness of fit measure will be undefined. In these cases
the measure will be reported as NA
.
Glance returns the same number of columns regardless of whether the
model matrix is rank-deficient or not. If so, entries in columns
that no longer have a well-defined value are filled in with an NA
of the appropriate type.
## S3 method for class 'sarlm' glance(x, ...)
## S3 method for class 'sarlm' glance(x, ...)
x |
An object returned from |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with exactly one row and columns:
AIC |
Akaike's Information Criterion for the model. |
BIC |
Bayesian Information Criterion for the model. |
deviance |
Deviance of the model. |
logLik |
The log-likelihood of the model. [stats::logLik()] may be a useful reference. |
nobs |
Number of observations used. |
glance()
, spatialreg::lagsarlm()
, spatialreg::errorsarlm()
,
spatialreg::sacsarlm()
Other spatialreg tidiers:
augment.sarlm()
,
tidy.sarlm()
# load libraries for models and data library(spatialreg) library(spdep) # load data data(oldcol, package = "spdep") listw <- nb2listw(COL.nb, style = "W") # fit model crime_sar <- lagsarlm(CRIME ~ INC + HOVAL, data = COL.OLD, listw = listw, method = "eigen" ) # summarize model fit with tidiers tidy(crime_sar) tidy(crime_sar, conf.int = TRUE) glance(crime_sar) augment(crime_sar) # fit another model crime_sem <- errorsarlm(CRIME ~ INC + HOVAL, data = COL.OLD, listw) # summarize model fit with tidiers tidy(crime_sem) tidy(crime_sem, conf.int = TRUE) glance(crime_sem) augment(crime_sem) # fit another model crime_sac <- sacsarlm(CRIME ~ INC + HOVAL, data = COL.OLD, listw) # summarize model fit with tidiers tidy(crime_sac) tidy(crime_sac, conf.int = TRUE) glance(crime_sac) augment(crime_sac)
# load libraries for models and data library(spatialreg) library(spdep) # load data data(oldcol, package = "spdep") listw <- nb2listw(COL.nb, style = "W") # fit model crime_sar <- lagsarlm(CRIME ~ INC + HOVAL, data = COL.OLD, listw = listw, method = "eigen" ) # summarize model fit with tidiers tidy(crime_sar) tidy(crime_sar, conf.int = TRUE) glance(crime_sar) augment(crime_sar) # fit another model crime_sem <- errorsarlm(CRIME ~ INC + HOVAL, data = COL.OLD, listw) # summarize model fit with tidiers tidy(crime_sem) tidy(crime_sem, conf.int = TRUE) glance(crime_sem) augment(crime_sem) # fit another model crime_sac <- sacsarlm(CRIME ~ INC + HOVAL, data = COL.OLD, listw) # summarize model fit with tidiers tidy(crime_sac) tidy(crime_sac, conf.int = TRUE) glance(crime_sac) augment(crime_sac)
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'smooth.spline' glance(x, ...)
## S3 method for class 'smooth.spline' glance(x, ...)
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with exactly one row and columns:
crit |
Minimized criterion |
cv.crit |
Cross-validation score |
df |
Degrees of freedom used by the model. |
lambda |
Choice of lambda corresponding to 'spar'. |
nobs |
Number of observations used. |
pen.crit |
Penalized criterion. |
spar |
Smoothing parameter. |
augment()
, stats::smooth.spline()
Other smoothing spline tidiers:
augment.smooth.spline()
# fit model spl <- smooth.spline(mtcars$wt, mtcars$mpg, df = 4) # summarize model fit with tidiers augment(spl, mtcars) # calls original columns x and y augment(spl) library(ggplot2) ggplot(augment(spl, mtcars), aes(wt, mpg)) + geom_point() + geom_line(aes(y = .fitted))
# fit model spl <- smooth.spline(mtcars$wt, mtcars$mpg, df = 4) # summarize model fit with tidiers augment(spl, mtcars) # calls original columns x and y augment(spl) library(ggplot2) ggplot(augment(spl, mtcars), aes(wt, mpg)) + geom_point() + geom_line(aes(y = .fitted))
Glance accepts a model object and returns a tibble::tibble()
with exactly one row of model summaries. The summaries are typically
goodness of fit measures, p-values for hypothesis tests on residuals,
or model convergence information.
Glance never returns information from the original call to the modeling function. This includes the name of the modeling function or any arguments passed to the modeling function.
Glance does not calculate summary measures. Rather, it farms out these
computations to appropriate methods and gathers the results together.
Sometimes a goodness of fit measure will be undefined. In these cases
the measure will be reported as NA
.
Glance returns the same number of columns regardless of whether the
model matrix is rank-deficient or not. If so, entries in columns
that no longer have a well-defined value are filled in with an NA
of the appropriate type.
## S3 method for class 'speedglm' glance(x, ...)
## S3 method for class 'speedglm' glance(x, ...)
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with exactly one row and columns:
AIC |
Akaike's Information Criterion for the model. |
BIC |
Bayesian Information Criterion for the model. |
deviance |
Deviance of the model. |
df.null |
Degrees of freedom used by the null model. |
df.residual |
Residual degrees of freedom. |
logLik |
The log-likelihood of the model. [stats::logLik()] may be a useful reference. |
nobs |
Number of observations used. |
null.deviance |
Deviance of the null model. |
Other speedlm tidiers:
augment.speedlm()
,
glance.speedlm()
,
tidy.speedglm()
,
tidy.speedlm()
# load libraries for models and data library(speedglm) # generate data clotting <- data.frame( u = c(5, 10, 15, 20, 30, 40, 60, 80, 100), lot1 = c(118, 58, 42, 35, 27, 25, 21, 19, 18) ) # fit model fit <- speedglm(lot1 ~ log(u), data = clotting, family = Gamma(log)) # summarize model fit with tidiers tidy(fit) glance(fit)
# load libraries for models and data library(speedglm) # generate data clotting <- data.frame( u = c(5, 10, 15, 20, 30, 40, 60, 80, 100), lot1 = c(118, 58, 42, 35, 27, 25, 21, 19, 18) ) # fit model fit <- speedglm(lot1 ~ log(u), data = clotting, family = Gamma(log)) # summarize model fit with tidiers tidy(fit) glance(fit)
Glance accepts a model object and returns a tibble::tibble()
with exactly one row of model summaries. The summaries are typically
goodness of fit measures, p-values for hypothesis tests on residuals,
or model convergence information.
Glance never returns information from the original call to the modeling function. This includes the name of the modeling function or any arguments passed to the modeling function.
Glance does not calculate summary measures. Rather, it farms out these
computations to appropriate methods and gathers the results together.
Sometimes a goodness of fit measure will be undefined. In these cases
the measure will be reported as NA
.
Glance returns the same number of columns regardless of whether the
model matrix is rank-deficient or not. If so, entries in columns
that no longer have a well-defined value are filled in with an NA
of the appropriate type.
## S3 method for class 'speedlm' glance(x, ...)
## S3 method for class 'speedlm' glance(x, ...)
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with exactly one row and columns:
adj.r.squared |
Adjusted R squared statistic, which is like the R squared statistic except taking degrees of freedom into account. |
AIC |
Akaike's Information Criterion for the model. |
BIC |
Bayesian Information Criterion for the model. |
deviance |
Deviance of the model. |
df |
Degrees of freedom used by the model. |
df.residual |
Residual degrees of freedom. |
logLik |
The log-likelihood of the model. [stats::logLik()] may be a useful reference. |
nobs |
Number of observations used. |
p.value |
P-value corresponding to the test statistic. |
r.squared |
R squared statistic, or the percent of variation explained by the model. Also known as the coefficient of determination. |
statistic |
F-statistic. |
Other speedlm tidiers:
augment.speedlm()
,
glance.speedglm()
,
tidy.speedglm()
,
tidy.speedlm()
# load modeling library library(speedglm) # fit model mod <- speedlm(mpg ~ wt + qsec, data = mtcars, fitted = TRUE) # summarize model fit with tidiers tidy(mod) glance(mod) augment(mod)
# load modeling library library(speedglm) # fit model mod <- speedlm(mpg ~ wt + qsec, data = mtcars, fitted = TRUE) # summarize model fit with tidiers tidy(mod) glance(mod) augment(mod)
Glance accepts a model object and returns a tibble::tibble()
with exactly one row of model summaries. The summaries are typically
goodness of fit measures, p-values for hypothesis tests on residuals,
or model convergence information.
Glance never returns information from the original call to the modeling function. This includes the name of the modeling function or any arguments passed to the modeling function.
Glance does not calculate summary measures. Rather, it farms out these
computations to appropriate methods and gathers the results together.
Sometimes a goodness of fit measure will be undefined. In these cases
the measure will be reported as NA
.
Glance returns the same number of columns regardless of whether the
model matrix is rank-deficient or not. If so, entries in columns
that no longer have a well-defined value are filled in with an NA
of the appropriate type.
## S3 method for class 'summary.lm' glance(x, ...)
## S3 method for class 'summary.lm' glance(x, ...)
x |
An |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
The glance.summary.lm()
method is a potentially useful alternative
to glance.lm()
. For instance, if users have already converted large lm
objects into their leaner summary.lm
equivalents to conserve memory. Note,
however, that this method does not return all of the columns of the
non-summary method (e.g. AIC and BIC will be missing.)
A tibble::tibble()
with exactly one row and columns:
adj.r.squared |
Adjusted R squared statistic, which is like the R squared statistic except taking degrees of freedom into account. |
df.residual |
Residual degrees of freedom. |
nobs |
Number of observations used. |
p.value |
P-value corresponding to the test statistic. |
r.squared |
R squared statistic, or the percent of variation explained by the model. Also known as the coefficient of determination. |
sigma |
Estimated standard error of the residuals. |
statistic |
Test statistic. |
df |
The degrees for freedom from the numerator of the overall F-statistic. This is new in broom 0.7.0. Previously, this reported the rank of the design matrix, which is one more than the numerator degrees of freedom of the overall F-statistic. |
Other lm tidiers:
augment.glm()
,
augment.lm()
,
glance.glm()
,
glance.lm()
,
glance.svyglm()
,
tidy.glm()
,
tidy.lm()
,
tidy.lm.beta()
,
tidy.mlm()
,
tidy.summary.lm()
library(ggplot2) library(dplyr) mod <- lm(mpg ~ wt + qsec, data = mtcars) tidy(mod) glance(mod) # coefficient plot d <- tidy(mod, conf.int = TRUE) ggplot(d, aes(estimate, term, xmin = conf.low, xmax = conf.high, height = 0)) + geom_point() + geom_vline(xintercept = 0, lty = 4) + geom_errorbarh() # aside: There are tidy() and glance() methods for lm.summary objects too. # this can be useful when you want to conserve memory by converting large lm # objects into their leaner summary.lm equivalents. s <- summary(mod) tidy(s, conf.int = TRUE) glance(s) augment(mod) augment(mod, mtcars, interval = "confidence") # predict on new data newdata <- mtcars %>% head(6) %>% mutate(wt = wt + 1) augment(mod, newdata = newdata) # ggplot2 example where we also construct 95% prediction interval # simpler bivariate model since we're plotting in 2D mod2 <- lm(mpg ~ wt, data = mtcars) au <- augment(mod2, newdata = newdata, interval = "prediction") ggplot(au, aes(wt, mpg)) + geom_point() + geom_line(aes(y = .fitted)) + geom_ribbon(aes(ymin = .lower, ymax = .upper), col = NA, alpha = 0.3) # predict on new data without outcome variable. Output does not include .resid newdata <- newdata %>% select(-mpg) augment(mod, newdata = newdata) au <- augment(mod, data = mtcars) ggplot(au, aes(.hat, .std.resid)) + geom_vline(size = 2, colour = "white", xintercept = 0) + geom_hline(size = 2, colour = "white", yintercept = 0) + geom_point() + geom_smooth(se = FALSE) plot(mod, which = 6) ggplot(au, aes(.hat, .cooksd)) + geom_vline(xintercept = 0, colour = NA) + geom_abline(slope = seq(0, 3, by = 0.5), colour = "white") + geom_smooth(se = FALSE) + geom_point() # column-wise models a <- matrix(rnorm(20), nrow = 10) b <- a + rnorm(length(a)) result <- lm(b ~ a) tidy(result)
library(ggplot2) library(dplyr) mod <- lm(mpg ~ wt + qsec, data = mtcars) tidy(mod) glance(mod) # coefficient plot d <- tidy(mod, conf.int = TRUE) ggplot(d, aes(estimate, term, xmin = conf.low, xmax = conf.high, height = 0)) + geom_point() + geom_vline(xintercept = 0, lty = 4) + geom_errorbarh() # aside: There are tidy() and glance() methods for lm.summary objects too. # this can be useful when you want to conserve memory by converting large lm # objects into their leaner summary.lm equivalents. s <- summary(mod) tidy(s, conf.int = TRUE) glance(s) augment(mod) augment(mod, mtcars, interval = "confidence") # predict on new data newdata <- mtcars %>% head(6) %>% mutate(wt = wt + 1) augment(mod, newdata = newdata) # ggplot2 example where we also construct 95% prediction interval # simpler bivariate model since we're plotting in 2D mod2 <- lm(mpg ~ wt, data = mtcars) au <- augment(mod2, newdata = newdata, interval = "prediction") ggplot(au, aes(wt, mpg)) + geom_point() + geom_line(aes(y = .fitted)) + geom_ribbon(aes(ymin = .lower, ymax = .upper), col = NA, alpha = 0.3) # predict on new data without outcome variable. Output does not include .resid newdata <- newdata %>% select(-mpg) augment(mod, newdata = newdata) au <- augment(mod, data = mtcars) ggplot(au, aes(.hat, .std.resid)) + geom_vline(size = 2, colour = "white", xintercept = 0) + geom_hline(size = 2, colour = "white", yintercept = 0) + geom_point() + geom_smooth(se = FALSE) plot(mod, which = 6) ggplot(au, aes(.hat, .cooksd)) + geom_vline(xintercept = 0, colour = NA) + geom_abline(slope = seq(0, 3, by = 0.5), colour = "white") + geom_smooth(se = FALSE) + geom_point() # column-wise models a <- matrix(rnorm(20), nrow = 10) b <- a + rnorm(length(a)) result <- lm(b ~ a) tidy(result)
Glance accepts a model object and returns a tibble::tibble()
with exactly one row of model summaries. The summaries are typically
goodness of fit measures, p-values for hypothesis tests on residuals,
or model convergence information.
Glance never returns information from the original call to the modeling function. This includes the name of the modeling function or any arguments passed to the modeling function.
Glance does not calculate summary measures. Rather, it farms out these
computations to appropriate methods and gathers the results together.
Sometimes a goodness of fit measure will be undefined. In these cases
the measure will be reported as NA
.
Glance returns the same number of columns regardless of whether the
model matrix is rank-deficient or not. If so, entries in columns
that no longer have a well-defined value are filled in with an NA
of the appropriate type.
## S3 method for class 'survdiff' glance(x, ...)
## S3 method for class 'survdiff' glance(x, ...)
x |
An |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with exactly one row and columns:
df |
Degrees of freedom used by the model. |
p.value |
P-value corresponding to the test statistic. |
statistic |
Test statistic. |
glance()
, survival::survdiff()
Other survdiff tidiers:
tidy.survdiff()
Other survival tidiers:
augment.coxph()
,
augment.survreg()
,
glance.aareg()
,
glance.cch()
,
glance.coxph()
,
glance.pyears()
,
glance.survexp()
,
glance.survfit()
,
glance.survreg()
,
tidy.aareg()
,
tidy.cch()
,
tidy.coxph()
,
tidy.pyears()
,
tidy.survdiff()
,
tidy.survexp()
,
tidy.survfit()
,
tidy.survreg()
# load libraries for models and data library(survival) # fit model s <- survdiff( Surv(time, status) ~ pat.karno + strata(inst), data = lung ) # summarize model fit with tidiers tidy(s) glance(s)
# load libraries for models and data library(survival) # fit model s <- survdiff( Surv(time, status) ~ pat.karno + strata(inst), data = lung ) # summarize model fit with tidiers tidy(s) glance(s)
Glance accepts a model object and returns a tibble::tibble()
with exactly one row of model summaries. The summaries are typically
goodness of fit measures, p-values for hypothesis tests on residuals,
or model convergence information.
Glance never returns information from the original call to the modeling function. This includes the name of the modeling function or any arguments passed to the modeling function.
Glance does not calculate summary measures. Rather, it farms out these
computations to appropriate methods and gathers the results together.
Sometimes a goodness of fit measure will be undefined. In these cases
the measure will be reported as NA
.
Glance returns the same number of columns regardless of whether the
model matrix is rank-deficient or not. If so, entries in columns
that no longer have a well-defined value are filled in with an NA
of the appropriate type.
## S3 method for class 'survexp' glance(x, ...)
## S3 method for class 'survexp' glance(x, ...)
x |
An |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with exactly one row and columns:
n.max |
Maximum number of subjects at risk. |
n.start |
Initial number of subjects at risk. |
timepoints |
Number of timepoints. |
Other survexp tidiers:
tidy.survexp()
Other survival tidiers:
augment.coxph()
,
augment.survreg()
,
glance.aareg()
,
glance.cch()
,
glance.coxph()
,
glance.pyears()
,
glance.survdiff()
,
glance.survfit()
,
glance.survreg()
,
tidy.aareg()
,
tidy.cch()
,
tidy.coxph()
,
tidy.pyears()
,
tidy.survdiff()
,
tidy.survexp()
,
tidy.survfit()
,
tidy.survreg()
# load libraries for models and data library(survival) # fit model sexpfit <- survexp( futime ~ 1, rmap = list( sex = "male", year = accept.dt, age = (accept.dt - birth.dt) ), method = "conditional", data = jasa ) # summarize model fit with tidiers tidy(sexpfit) glance(sexpfit)
# load libraries for models and data library(survival) # fit model sexpfit <- survexp( futime ~ 1, rmap = list( sex = "male", year = accept.dt, age = (accept.dt - birth.dt) ), method = "conditional", data = jasa ) # summarize model fit with tidiers tidy(sexpfit) glance(sexpfit)
Glance accepts a model object and returns a tibble::tibble()
with exactly one row of model summaries. The summaries are typically
goodness of fit measures, p-values for hypothesis tests on residuals,
or model convergence information.
Glance never returns information from the original call to the modeling function. This includes the name of the modeling function or any arguments passed to the modeling function.
Glance does not calculate summary measures. Rather, it farms out these
computations to appropriate methods and gathers the results together.
Sometimes a goodness of fit measure will be undefined. In these cases
the measure will be reported as NA
.
Glance returns the same number of columns regardless of whether the
model matrix is rank-deficient or not. If so, entries in columns
that no longer have a well-defined value are filled in with an NA
of the appropriate type.
## S3 method for class 'survfit' glance(x, ...)
## S3 method for class 'survfit' glance(x, ...)
x |
An |
... |
Additional arguments passed to |
A tibble::tibble()
with exactly one row and columns:
events |
Number of events. |
n.max |
Maximum number of subjects at risk. |
n.start |
Initial number of subjects at risk. |
nobs |
Number of observations used. |
records |
Number of observations |
rmean |
Restricted mean (see [survival::print.survfit()]). |
rmean.std.error |
Restricted mean standard error. |
conf.low |
lower end of confidence interval on median |
conf.high |
upper end of confidence interval on median |
median |
median survival |
Other cch tidiers:
glance.cch()
,
tidy.cch()
Other survival tidiers:
augment.coxph()
,
augment.survreg()
,
glance.aareg()
,
glance.cch()
,
glance.coxph()
,
glance.pyears()
,
glance.survdiff()
,
glance.survexp()
,
glance.survreg()
,
tidy.aareg()
,
tidy.cch()
,
tidy.coxph()
,
tidy.pyears()
,
tidy.survdiff()
,
tidy.survexp()
,
tidy.survfit()
,
tidy.survreg()
# load libraries for models and data library(survival) # fit model cfit <- coxph(Surv(time, status) ~ age + sex, lung) sfit <- survfit(cfit) # summarize model fit with tidiers + visualization tidy(sfit) glance(sfit) library(ggplot2) ggplot(tidy(sfit), aes(time, estimate)) + geom_line() + geom_ribbon(aes(ymin = conf.low, ymax = conf.high), alpha = .25) # multi-state fitCI <- survfit(Surv(stop, status * as.numeric(event), type = "mstate") ~ 1, data = mgus1, subset = (start == 0) ) td_multi <- tidy(fitCI) td_multi ggplot(td_multi, aes(time, estimate, group = state)) + geom_line(aes(color = state)) + geom_ribbon(aes(ymin = conf.low, ymax = conf.high), alpha = .25)
# load libraries for models and data library(survival) # fit model cfit <- coxph(Surv(time, status) ~ age + sex, lung) sfit <- survfit(cfit) # summarize model fit with tidiers + visualization tidy(sfit) glance(sfit) library(ggplot2) ggplot(tidy(sfit), aes(time, estimate)) + geom_line() + geom_ribbon(aes(ymin = conf.low, ymax = conf.high), alpha = .25) # multi-state fitCI <- survfit(Surv(stop, status * as.numeric(event), type = "mstate") ~ 1, data = mgus1, subset = (start == 0) ) td_multi <- tidy(fitCI) td_multi ggplot(td_multi, aes(time, estimate, group = state)) + geom_line(aes(color = state)) + geom_ribbon(aes(ymin = conf.low, ymax = conf.high), alpha = .25)
Glance accepts a model object and returns a tibble::tibble()
with exactly one row of model summaries. The summaries are typically
goodness of fit measures, p-values for hypothesis tests on residuals,
or model convergence information.
Glance never returns information from the original call to the modeling function. This includes the name of the modeling function or any arguments passed to the modeling function.
Glance does not calculate summary measures. Rather, it farms out these
computations to appropriate methods and gathers the results together.
Sometimes a goodness of fit measure will be undefined. In these cases
the measure will be reported as NA
.
Glance returns the same number of columns regardless of whether the
model matrix is rank-deficient or not. If so, entries in columns
that no longer have a well-defined value are filled in with an NA
of the appropriate type.
## S3 method for class 'survreg' glance(x, ...)
## S3 method for class 'survreg' glance(x, ...)
x |
An |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with exactly one row and columns:
AIC |
Akaike's Information Criterion for the model. |
BIC |
Bayesian Information Criterion for the model. |
df |
Degrees of freedom used by the model. |
df.residual |
Residual degrees of freedom. |
iter |
Iterations of algorithm/fitting procedure completed. |
logLik |
The log-likelihood of the model. [stats::logLik()] may be a useful reference. |
nobs |
Number of observations used. |
p.value |
P-value corresponding to the test statistic. |
statistic |
Chi-squared statistic. |
Other survreg tidiers:
augment.survreg()
,
tidy.survreg()
Other survival tidiers:
augment.coxph()
,
augment.survreg()
,
glance.aareg()
,
glance.cch()
,
glance.coxph()
,
glance.pyears()
,
glance.survdiff()
,
glance.survexp()
,
glance.survfit()
,
tidy.aareg()
,
tidy.cch()
,
tidy.coxph()
,
tidy.pyears()
,
tidy.survdiff()
,
tidy.survexp()
,
tidy.survfit()
,
tidy.survreg()
# load libraries for models and data library(survival) # fit model sr <- survreg( Surv(futime, fustat) ~ ecog.ps + rx, ovarian, dist = "exponential" ) # summarize model fit with tidiers + visualization tidy(sr) augment(sr, ovarian) glance(sr) # coefficient plot td <- tidy(sr, conf.int = TRUE) library(ggplot2) ggplot(td, aes(estimate, term)) + geom_point() + geom_errorbarh(aes(xmin = conf.low, xmax = conf.high), height = 0) + geom_vline(xintercept = 0)
# load libraries for models and data library(survival) # fit model sr <- survreg( Surv(futime, fustat) ~ ecog.ps + rx, ovarian, dist = "exponential" ) # summarize model fit with tidiers + visualization tidy(sr) augment(sr, ovarian) glance(sr) # coefficient plot td <- tidy(sr, conf.int = TRUE) library(ggplot2) ggplot(td, aes(estimate, term)) + geom_point() + geom_errorbarh(aes(xmin = conf.low, xmax = conf.high), height = 0) + geom_vline(xintercept = 0)
Glance accepts a model object and returns a tibble::tibble()
with exactly one row of model summaries. The summaries are typically
goodness of fit measures, p-values for hypothesis tests on residuals,
or model convergence information.
Glance never returns information from the original call to the modeling function. This includes the name of the modeling function or any arguments passed to the modeling function.
Glance does not calculate summary measures. Rather, it farms out these
computations to appropriate methods and gathers the results together.
Sometimes a goodness of fit measure will be undefined. In these cases
the measure will be reported as NA
.
Glance returns the same number of columns regardless of whether the
model matrix is rank-deficient or not. If so, entries in columns
that no longer have a well-defined value are filled in with an NA
of the appropriate type.
## S3 method for class 'svyglm' glance(x, maximal = x, ...)
## S3 method for class 'svyglm' glance(x, maximal = x, ...)
x |
A |
maximal |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with exactly one row and columns:
AIC |
Akaike's Information Criterion for the model. |
BIC |
Bayesian Information Criterion for the model. |
deviance |
Deviance of the model. |
df.null |
Degrees of freedom used by the null model. |
df.residual |
Residual degrees of freedom. |
null.deviance |
Deviance of the null model. |
Lumley T, Scott A (2015). AIC and BIC for modelling with complex survey data. Journal of Survey Statistics and Methodology, 3(1).
survey::svyglm()
, stats::glm()
, survey::anova.svyglm
Other lm tidiers:
augment.glm()
,
augment.lm()
,
glance.glm()
,
glance.lm()
,
glance.summary.lm()
,
tidy.glm()
,
tidy.lm()
,
tidy.lm.beta()
,
tidy.mlm()
,
tidy.summary.lm()
# load libraries for models and data library(survey) set.seed(123) data(api) # survey design dstrat <- svydesign( id = ~1, strata = ~stype, weights = ~pw, data = apistrat, fpc = ~fpc ) # model m <- svyglm( formula = sch.wide ~ ell + meals + mobility, design = dstrat, family = quasibinomial() ) glance(m)
# load libraries for models and data library(survey) set.seed(123) data(api) # survey design dstrat <- svydesign( id = ~1, strata = ~stype, weights = ~pw, data = apistrat, fpc = ~fpc ) # model m <- svyglm( formula = sch.wide ~ ell + meals + mobility, design = dstrat, family = quasibinomial() ) glance(m)
Glance accepts a model object and returns a tibble::tibble()
with exactly one row of model summaries. The summaries are typically
goodness of fit measures, p-values for hypothesis tests on residuals,
or model convergence information.
Glance never returns information from the original call to the modeling function. This includes the name of the modeling function or any arguments passed to the modeling function.
Glance does not calculate summary measures. Rather, it farms out these
computations to appropriate methods and gathers the results together.
Sometimes a goodness of fit measure will be undefined. In these cases
the measure will be reported as NA
.
Glance returns the same number of columns regardless of whether the
model matrix is rank-deficient or not. If so, entries in columns
that no longer have a well-defined value are filled in with an NA
of the appropriate type.
## S3 method for class 'svyolr' glance(x, ...)
## S3 method for class 'svyolr' glance(x, ...)
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with exactly one row and columns:
df.residual |
Residual degrees of freedom. |
edf |
The effective degrees of freedom. |
nobs |
Number of observations used. |
Other ordinal tidiers:
augment.clm()
,
augment.polr()
,
glance.clm()
,
glance.clmm()
,
glance.polr()
,
tidy.clm()
,
tidy.clmm()
,
tidy.polr()
,
tidy.svyolr()
library(broom) library(survey) data(api) dclus1 <- svydesign(id = ~dnum, weights = ~pw, data = apiclus1, fpc = ~fpc) dclus1 <- update(dclus1, mealcat = cut(meals, c(0, 25, 50, 75, 100))) m <- svyolr(mealcat ~ avg.ed + mobility + stype, design = dclus1) m tidy(m, conf.int = TRUE)
library(broom) library(survey) data(api) dclus1 <- svydesign(id = ~dnum, weights = ~pw, data = apiclus1, fpc = ~fpc) dclus1 <- update(dclus1, mealcat = cut(meals, c(0, 25, 50, 75, 100))) m <- svyolr(mealcat ~ avg.ed + mobility + stype, design = dclus1) m tidy(m, conf.int = TRUE)
Glance accepts a model object and returns a tibble::tibble()
with exactly one row of model summaries. The summaries are typically
goodness of fit measures, p-values for hypothesis tests on residuals,
or model convergence information.
Glance never returns information from the original call to the modeling function. This includes the name of the modeling function or any arguments passed to the modeling function.
Glance does not calculate summary measures. Rather, it farms out these
computations to appropriate methods and gathers the results together.
Sometimes a goodness of fit measure will be undefined. In these cases
the measure will be reported as NA
.
Glance returns the same number of columns regardless of whether the
model matrix is rank-deficient or not. If so, entries in columns
that no longer have a well-defined value are filled in with an NA
of the appropriate type.
## S3 method for class 'varest' glance(x, ...)
## S3 method for class 'varest' glance(x, ...)
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with exactly one row and columns:
lag.order |
Lag order. |
logLik |
The log-likelihood of the model. [stats::logLik()] may be a useful reference. |
n |
The total number of observations. |
nobs |
Number of observations used. |
# load libraries for models and data library(vars) # load data data("Canada", package = "vars") # fit models mod <- VAR(Canada, p = 1, type = "both") # summarize model fit with tidiers tidy(mod) glance(mod)
# load libraries for models and data library(vars) # load data data("Canada", package = "vars") # fit models mod <- VAR(Canada, p = 1, type = "both") # summarize model fit with tidiers tidy(mod) glance(mod)
For models that have only a single component, the tidy()
and
glance()
methods are identical. Please see the documentation for both
of those methods.
## S3 method for class 'leveneTest' tidy(x, ...)
## S3 method for class 'leveneTest' tidy(x, ...)
x |
An object of class |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with columns:
df |
Degrees of freedom used by this term in the model. |
p.value |
The two-sided p-value associated with the observed statistic. |
statistic |
The value of a T-statistic to use in a hypothesis that the regression term is non-zero. |
df.residual |
Residual degrees of freedom. |
tidy()
, glance()
, car::leveneTest()
Other car tidiers:
durbinWatsonTest_tidiers
# load libraries for models and data library(car) data(Moore) lt <- with(Moore, leveneTest(conformity, fcategory)) tidy(lt) glance(lt)
# load libraries for models and data library(car) data(Moore) lt <- with(Moore, leveneTest(conformity, fcategory)) tidy(lt) glance(lt)
Broom tidies a number of lists that are effectively S3 objects without
a class attribute. For example, stats::optim()
, base::svd()
and
interp::interp()
produce consistent output, but because they do not
have a class attribute, they cannot be handled by S3 dispatch.
## S3 method for class 'list' tidy(x, ...) ## S3 method for class 'list' glance(x, ...)
## S3 method for class 'list' tidy(x, ...) ## S3 method for class 'list' glance(x, ...)
x |
A list, potentially representing an object that can be tidied. |
... |
Additionally, arguments passed to the tidying function. |
These functions look at the elements of a list and determine if there is
an appropriate tidying method to apply to the list. Those tidiers are
themselves are implemented as functions of the form tidy_<function>
or glance_<function>
and are not exported (but they are documented!).
If no appropriate tidying method is found, throws an error.
Other list tidiers:
glance_optim()
,
tidy_irlba()
,
tidy_optim()
,
tidy_svd()
,
tidy_xyz()
tidy(NULL)
, glance(NULL)
and augment(NULL)
all return an empty
tibble::tibble. This empty tibble can be treated a tibble with zero
rows, making it convenient to combine with other tibbles using
functions like purrr::map_df()
on lists of potentially NULL
objects.
## S3 method for class ''NULL'' tidy(x, ...) ## S3 method for class ''NULL'' glance(x, ...) ## S3 method for class ''NULL'' augment(x, ...)
## S3 method for class ''NULL'' tidy(x, ...) ## S3 method for class ''NULL'' glance(x, ...) ## S3 method for class ''NULL'' augment(x, ...)
x |
The value |
... |
Additional arguments (not used). |
An empty tibble::tibble.
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
Note that the sf
package now defines tidy spatial objects
and is the recommended approach to spatial data. sp
tidiers are now
deprecated in favor of sf::st_as_sf()
and coercion methods found in
other packages. See
https://r-spatial.org/r/2023/05/15/evolution4.html for more on
migration from retiring spatial packages.
## S3 method for class 'SpatialPolygonsDataFrame' tidy(x, region = NULL, ...) ## S3 method for class 'SpatialPolygons' tidy(x, ...) ## S3 method for class 'Polygons' tidy(x, ...) ## S3 method for class 'Polygon' tidy(x, ...) ## S3 method for class 'SpatialLinesDataFrame' tidy(x, ...) ## S3 method for class 'Lines' tidy(x, ...) ## S3 method for class 'Line' tidy(x, ...)
## S3 method for class 'SpatialPolygonsDataFrame' tidy(x, region = NULL, ...) ## S3 method for class 'SpatialPolygons' tidy(x, ...) ## S3 method for class 'Polygons' tidy(x, ...) ## S3 method for class 'Polygon' tidy(x, ...) ## S3 method for class 'SpatialLinesDataFrame' tidy(x, ...) ## S3 method for class 'Lines' tidy(x, ...) ## S3 method for class 'Line' tidy(x, ...)
x |
A |
region |
name of variable used to split up regions |
... |
not used by this method |
Tidiers for summaryDefault objects have been deprecated as of
broom 0.7.0 in favor of skimr::skim()
.
## S3 method for class 'summaryDefault' tidy(x, ...) ## S3 method for class 'summaryDefault' glance(x, ...)
## S3 method for class 'summaryDefault' tidy(x, ...) ## S3 method for class 'summaryDefault' glance(x, ...)
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A one-row tibble::tibble with columns:
minimum |
Minimum value in original vector. |
q1 |
First quartile of original vector. |
median |
Median of original vector. |
mean |
Mean of original vector. |
q3 |
Third quartile of original vector. |
maximum |
Maximum value in original vector. |
na |
Number of |
Other deprecated:
bootstrap()
,
confint_tidy()
,
data.frame_tidiers
,
finish_glance()
,
fix_data_frame()
,
tidy.density()
,
tidy.dist()
,
tidy.ftable()
,
tidy.numeric()
Other deprecated:
bootstrap()
,
confint_tidy()
,
data.frame_tidiers
,
finish_glance()
,
fix_data_frame()
,
tidy.density()
,
tidy.dist()
,
tidy.ftable()
,
tidy.numeric()
v <- rnorm(1000) s <- summary(v) s tidy(s) glance(s) v2 <- c(v,NA) tidy(summary(v2))
v <- rnorm(1000) s <- summary(v) s tidy(s) glance(s) v2 <- c(v,NA) tidy(summary(v2))
Broom tidies a number of lists that are effectively S3
objects without a class attribute. For example, stats::optim()
,
svd() and interp::interp()
produce consistent output, but
because they do not have a class attribute, they cannot be handled by S3
dispatch.
These functions look at the elements of a list and determine if there is
an appropriate tidying method to apply to the list. Those tidiers are
implemented as functions of the form tidy_<function>
or
glance_<function>
and are not exported (but they are documented!).
If no appropriate tidying method is found, they throw an error.
tidy_irlba(x, ...)
tidy_irlba(x, ...)
x |
A list returned from |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A very thin wrapper around tidy_svd()
.
A tibble::tibble with columns depending on the component of PCA being tidied.
If matrix
is "u"
, "samples"
, "scores"
, or "x"
each row in the
tidied output corresponds to the original data in PCA space. The columns
are:
row |
ID of the original observation (i.e. rowname from original data). |
PC |
Integer indicating a principal component. |
value |
The score of the observation for that particular principal component. That is, the location of the observation in PCA space. |
If matrix
is "v"
, "rotation"
, "loadings"
or "variables"
, each
row in the tidied output corresponds to information about the principle
components in the original space. The columns are:
row |
The variable labels (colnames) of the data set on which PCA was performed. |
PC |
An integer vector indicating the principal component. |
value |
The value of the eigenvector (axis score) on the indicated principal component. |
If matrix
is "d"
, "eigenvalues"
or "pcs"
, the columns are:
PC |
An integer vector indicating the principal component. |
std.dev |
Standard deviation explained by this PC. |
percent |
Fraction of variation explained by this component (a numeric value between 0 and 1). |
cumulative |
Cumulative fraction of variation explained by principle components up to this component (a numeric value between 0 and 1). |
Other list tidiers:
glance_optim()
,
list_tidiers
,
tidy_optim()
,
tidy_svd()
,
tidy_xyz()
Other svd tidiers:
augment.prcomp()
,
tidy.prcomp()
,
tidy_svd()
library(modeldata) data(hpc_data) mat <- scale(as.matrix(hpc_data[, 2:5])) s <- svd(mat) tidy_u <- tidy(s, matrix = "u") tidy_u tidy_d <- tidy(s, matrix = "d") tidy_d tidy_v <- tidy(s, matrix = "v") tidy_v library(ggplot2) library(dplyr) ggplot(tidy_d, aes(PC, percent)) + geom_point() + ylab("% of variance explained") tidy_u %>% mutate(class = hpc_data$class[row]) %>% ggplot(aes(class, value)) + geom_boxplot() + facet_wrap(~PC, scale = "free_y")
library(modeldata) data(hpc_data) mat <- scale(as.matrix(hpc_data[, 2:5])) s <- svd(mat) tidy_u <- tidy(s, matrix = "u") tidy_u tidy_d <- tidy(s, matrix = "d") tidy_d tidy_v <- tidy(s, matrix = "v") tidy_v library(ggplot2) library(dplyr) ggplot(tidy_d, aes(PC, percent)) + geom_point() + ylab("% of variance explained") tidy_u %>% mutate(class = hpc_data$class[row]) %>% ggplot(aes(class, value)) + geom_boxplot() + facet_wrap(~PC, scale = "free_y")
Broom tidies a number of lists that are effectively S3
objects without a class attribute. For example, stats::optim()
,
svd() and interp::interp()
produce consistent output, but
because they do not have a class attribute, they cannot be handled by S3
dispatch.
These functions look at the elements of a list and determine if there is
an appropriate tidying method to apply to the list. Those tidiers are
implemented as functions of the form tidy_<function>
or
glance_<function>
and are not exported (but they are documented!).
If no appropriate tidying method is found, they throw an error.
tidy_optim(x, ...)
tidy_optim(x, ...)
x |
A list returned from |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with columns:
parameter |
The parameter being modeled. |
std.error |
The standard error of the regression term. |
value |
The value/estimate of the component. Results from data reshaping. |
std.error
is only provided as a column if the Hessian is calculated.
This function assumes that the provided objective function is a negative log-likelihood function. Results will be invalid if an incorrect function is supplied.
tidy(o) glance(o)
Other list tidiers:
glance_optim()
,
list_tidiers
,
tidy_irlba()
,
tidy_svd()
,
tidy_xyz()
f <- function(x) (x[1] - 2)^2 + (x[2] - 3)^2 + (x[3] - 8)^2 o <- optim(c(1, 1, 1), f)
f <- function(x) (x[1] - 2)^2 + (x[2] - 3)^2 + (x[3] - 8)^2 o <- optim(c(1, 1, 1), f)
Broom tidies a number of lists that are effectively S3
objects without a class attribute. For example, stats::optim()
,
svd() and interp::interp()
produce consistent output, but
because they do not have a class attribute, they cannot be handled by S3
dispatch.
These functions look at the elements of a list and determine if there is
an appropriate tidying method to apply to the list. Those tidiers are
implemented as functions of the form tidy_<function>
or
glance_<function>
and are not exported (but they are documented!).
If no appropriate tidying method is found, they throw an error.
tidy_svd(x, matrix = "u", ...)
tidy_svd(x, matrix = "u", ...)
x |
A list with components |
matrix |
Character specifying which component of the PCA should be tidied.
|
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
See https://stats.stackexchange.com/questions/134282/relationship-between-svd-and-pca-how-to-use-svd-to-perform-pca for information on how to interpret the various tidied matrices. Note that SVD is only equivalent to PCA on centered data.
A tibble::tibble with columns depending on the component of PCA being tidied.
If matrix
is "u"
, "samples"
, "scores"
, or "x"
each row in the
tidied output corresponds to the original data in PCA space. The columns
are:
row |
ID of the original observation (i.e. rowname from original data). |
PC |
Integer indicating a principal component. |
value |
The score of the observation for that particular principal component. That is, the location of the observation in PCA space. |
If matrix
is "v"
, "rotation"
, "loadings"
or "variables"
, each
row in the tidied output corresponds to information about the principle
components in the original space. The columns are:
row |
The variable labels (colnames) of the data set on which PCA was performed. |
PC |
An integer vector indicating the principal component. |
value |
The value of the eigenvector (axis score) on the indicated principal component. |
If matrix
is "d"
, "eigenvalues"
or "pcs"
, the columns are:
PC |
An integer vector indicating the principal component. |
std.dev |
Standard deviation explained by this PC. |
percent |
Fraction of variation explained by this component (a numeric value between 0 and 1). |
cumulative |
Cumulative fraction of variation explained by principle components up to this component (a numeric value between 0 and 1). |
Other svd tidiers:
augment.prcomp()
,
tidy.prcomp()
,
tidy_irlba()
Other list tidiers:
glance_optim()
,
list_tidiers
,
tidy_irlba()
,
tidy_optim()
,
tidy_xyz()
library(modeldata) data(hpc_data) mat <- scale(as.matrix(hpc_data[, 2:5])) s <- svd(mat) tidy_u <- tidy(s, matrix = "u") tidy_u tidy_d <- tidy(s, matrix = "d") tidy_d tidy_v <- tidy(s, matrix = "v") tidy_v library(ggplot2) library(dplyr) ggplot(tidy_d, aes(PC, percent)) + geom_point() + ylab("% of variance explained") tidy_u %>% mutate(class = hpc_data$class[row]) %>% ggplot(aes(class, value)) + geom_boxplot() + facet_wrap(~PC, scale = "free_y")
library(modeldata) data(hpc_data) mat <- scale(as.matrix(hpc_data[, 2:5])) s <- svd(mat) tidy_u <- tidy(s, matrix = "u") tidy_u tidy_d <- tidy(s, matrix = "d") tidy_d tidy_v <- tidy(s, matrix = "v") tidy_v library(ggplot2) library(dplyr) ggplot(tidy_d, aes(PC, percent)) + geom_point() + ylab("% of variance explained") tidy_u %>% mutate(class = hpc_data$class[row]) %>% ggplot(aes(class, value)) + geom_boxplot() + facet_wrap(~PC, scale = "free_y")
Broom tidies a number of lists that are effectively S3
objects without a class attribute. For example, stats::optim()
,
svd() and interp::interp()
produce consistent output, but
because they do not have a class attribute, they cannot be handled by S3
dispatch.
These functions look at the elements of a list and determine if there is
an appropriate tidying method to apply to the list. Those tidiers are
implemented as functions of the form tidy_<function>
or
glance_<function>
and are not exported (but they are documented!).
If no appropriate tidying method is found, they throw an error.
xyz lists (lists where x
and y
are vectors of coordinates
and z
is a matrix of values) are typically used by functions such as
graphics::persp()
or graphics::image()
and returned
by interpolation functions such as interp::interp()
.
tidy_xyz(x, ...)
tidy_xyz(x, ...)
x |
A list with component |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble with vector columns x
, y
and z
.
tidy()
, graphics::persp()
, graphics::image()
,
interp::interp()
Other list tidiers:
glance_optim()
,
list_tidiers
,
tidy_irlba()
,
tidy_optim()
,
tidy_svd()
A <- list(x = 1:5, y = 1:3, z = matrix(runif(5 * 3), nrow = 5)) image(A) tidy(A)
A <- list(x = 1:5, y = 1:3, z = matrix(runif(5 * 3), nrow = 5)) image(A) tidy(A)
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'aareg' tidy(x, ...)
## S3 method for class 'aareg' tidy(x, ...)
x |
An |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
robust.se
is only present when x
was created with
dfbeta = TRUE
.
A tibble::tibble()
with columns:
estimate |
The estimated value of the regression term. |
p.value |
The two-sided p-value associated with the observed statistic. |
robust.se |
robust version of standard error estimate. |
statistic |
The value of a T-statistic to use in a hypothesis that the regression term is non-zero. |
std.error |
The standard error of the regression term. |
term |
The name of the regression term. |
z |
z score. |
Other aareg tidiers:
glance.aareg()
Other survival tidiers:
augment.coxph()
,
augment.survreg()
,
glance.aareg()
,
glance.cch()
,
glance.coxph()
,
glance.pyears()
,
glance.survdiff()
,
glance.survexp()
,
glance.survfit()
,
glance.survreg()
,
tidy.cch()
,
tidy.coxph()
,
tidy.pyears()
,
tidy.survdiff()
,
tidy.survexp()
,
tidy.survfit()
,
tidy.survreg()
# load libraries for models and data library(survival) # fit model afit <- aareg( Surv(time, status) ~ age + sex + ph.ecog, data = lung, dfbeta = TRUE ) # summarize model fit with tidiers tidy(afit)
# load libraries for models and data library(survival) # fit model afit <- aareg( Surv(time, status) ~ age + sex + ph.ecog, data = lung, dfbeta = TRUE ) # summarize model fit with tidiers tidy(afit)
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'acf' tidy(x, ...)
## S3 method for class 'acf' tidy(x, ...)
x |
An |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with columns:
acf |
Autocorrelation. |
lag |
Lag values. |
tidy()
, stats::acf()
, stats::pacf()
, stats::ccf()
Other time series tidiers:
tidy.spec()
,
tidy.ts()
,
tidy.zoo()
tidy(acf(lh, plot = FALSE)) tidy(ccf(mdeaths, fdeaths, plot = FALSE)) tidy(pacf(lh, plot = FALSE))
tidy(acf(lh, plot = FALSE)) tidy(ccf(mdeaths, fdeaths, plot = FALSE)) tidy(pacf(lh, plot = FALSE))
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'anova' tidy(x, ...)
## S3 method for class 'anova' tidy(x, ...)
x |
An |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
The term
column of an ANOVA table can come with leading or
trailing whitespace, which this tidying method trims.
For documentation on the tidier for car::leveneTest()
output, see
tidy.leveneTest()
A tibble::tibble()
with columns:
df |
Degrees of freedom used by this term in the model. |
meansq |
Mean sum of squares. Equal to total sum of squares divided by degrees of freedom. |
p.value |
The two-sided p-value associated with the observed statistic. |
statistic |
The value of a T-statistic to use in a hypothesis that the regression term is non-zero. |
sumsq |
Sum of squares explained by this term. |
term |
The name of the regression term. |
tidy()
, stats::anova()
, car::Anova()
, car::leveneTest()
Other anova tidiers:
glance.anova()
,
glance.aov()
,
tidy.TukeyHSD()
,
tidy.aov()
,
tidy.aovlist()
,
tidy.manova()
# fit models a <- lm(mpg ~ wt + qsec + disp, mtcars) b <- lm(mpg ~ wt + qsec, mtcars) mod <- anova(a, b) # summarize model fit with tidiers tidy(mod) glance(mod) # car::linearHypothesis() example library(car) mod_lht <- linearHypothesis(a, "wt - disp") tidy(mod_lht) glance(mod_lht)
# fit models a <- lm(mpg ~ wt + qsec + disp, mtcars) b <- lm(mpg ~ wt + qsec, mtcars) mod <- anova(a, b) # summarize model fit with tidiers tidy(mod) glance(mod) # car::linearHypothesis() example library(car) mod_lht <- linearHypothesis(a, "wt - disp") tidy(mod_lht) glance(mod_lht)
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'aov' tidy(x, intercept = FALSE, ...)
## S3 method for class 'aov' tidy(x, intercept = FALSE, ...)
x |
An |
intercept |
A logical indicating whether information on the intercept
ought to be included. Passed to |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
The term
column of an ANOVA table can come with leading or
trailing whitespace, which this tidying method trims.
For documentation on the tidier for car::leveneTest()
output, see
tidy.leveneTest()
Other anova tidiers:
glance.anova()
,
glance.aov()
,
tidy.TukeyHSD()
,
tidy.anova()
,
tidy.aovlist()
,
tidy.manova()
a <- aov(mpg ~ wt + qsec + disp, mtcars) tidy(a)
a <- aov(mpg ~ wt + qsec + disp, mtcars) tidy(a)
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'aovlist' tidy(x, ...)
## S3 method for class 'aovlist' tidy(x, ...)
x |
An |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
The term
column of an ANOVA table can come with leading or
trailing whitespace, which this tidying method trims.
For documentation on the tidier for car::leveneTest()
output, see
tidy.leveneTest()
A tibble::tibble()
with columns:
df |
Degrees of freedom used by this term in the model. |
meansq |
Mean sum of squares. Equal to total sum of squares divided by degrees of freedom. |
p.value |
The two-sided p-value associated with the observed statistic. |
statistic |
The value of a T-statistic to use in a hypothesis that the regression term is non-zero. |
stratum |
The error stratum. |
sumsq |
Sum of squares explained by this term. |
term |
The name of the regression term. |
Other anova tidiers:
glance.anova()
,
glance.aov()
,
tidy.TukeyHSD()
,
tidy.anova()
,
tidy.aov()
,
tidy.manova()
a <- aov(mpg ~ wt + qsec + Error(disp / am), mtcars) tidy(a)
a <- aov(mpg ~ wt + qsec + Error(disp / am), mtcars) tidy(a)
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'Arima' tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
## S3 method for class 'Arima' tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
x |
An object of class |
conf.int |
Logical indicating whether or not to include a confidence
interval in the tidied output. Defaults to |
conf.level |
The confidence level to use for the confidence interval
if |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with columns:
conf.high |
Upper bound on the confidence interval for the estimate. |
conf.low |
Lower bound on the confidence interval for the estimate. |
estimate |
The estimated value of the regression term. |
std.error |
The standard error of the regression term. |
term |
The name of the regression term. |
Other Arima tidiers:
glance.Arima()
# fit model fit <- arima(lh, order = c(1, 0, 0)) # summarize model fit with tidiers tidy(fit) glance(fit)
# fit model fit <- arima(lh, order = c(1, 0, 0)) # summarize model fit with tidiers tidy(fit) glance(fit)
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'betamfx' tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
## S3 method for class 'betamfx' tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
x |
A |
conf.int |
Logical indicating whether or not to include a confidence
interval in the tidied output. Defaults to |
conf.level |
The confidence level to use for the confidence interval
if |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
The mfx
package provides methods for calculating marginal effects
for various generalized linear models (GLMs). Unlike standard linear
models, estimated model coefficients in a GLM cannot be directly
interpreted as marginal effects (i.e., the change in the response variable
predicted after a one unit change in one of the regressors). This is
because the estimated coefficients are multiplicative, dependent on both
the link function that was used for the estimation and any other variables
that were included in the model. When calculating marginal effects, users
must typically choose whether they want to use i) the average observation
in the data, or ii) the average of the sample marginal effects. See
vignette("mfxarticle")
from the mfx
package for more details.
A tibble::tibble()
with columns:
conf.high |
Upper bound on the confidence interval for the estimate. |
conf.low |
Lower bound on the confidence interval for the estimate. |
estimate |
The estimated value of the regression term. |
p.value |
The two-sided p-value associated with the observed statistic. |
statistic |
The value of a T-statistic to use in a hypothesis that the regression term is non-zero. |
std.error |
The standard error of the regression term. |
term |
The name of the regression term. |
atmean |
TRUE if the marginal effects were originally calculated as the partial effects for the average observation. If FALSE, then these were instead calculated as average partial effects. |
tidy.betareg()
, mfx::betamfx()
Other mfx tidiers:
augment.betamfx()
,
augment.mfx()
,
glance.betamfx()
,
glance.mfx()
,
tidy.mfx()
library(mfx) # Simulate some data set.seed(12345) n <- 1000 x <- rnorm(n) # Beta outcome y <- rbeta(n, shape1 = plogis(1 + 0.5 * x), shape2 = (abs(0.2 * x))) # Use Smithson and Verkuilen correction y <- (y * (n - 1) + 0.5) / n d <- data.frame(y, x) mod_betamfx <- betamfx(y ~ x | x, data = d) tidy(mod_betamfx, conf.int = TRUE) # Compare with the naive model coefficients of the equivalent betareg call (not run) # tidy(betamfx(y ~ x | x, data = d), conf.int = TRUE) augment(mod_betamfx) glance(mod_betamfx)
library(mfx) # Simulate some data set.seed(12345) n <- 1000 x <- rnorm(n) # Beta outcome y <- rbeta(n, shape1 = plogis(1 + 0.5 * x), shape2 = (abs(0.2 * x))) # Use Smithson and Verkuilen correction y <- (y * (n - 1) + 0.5) / n d <- data.frame(y, x) mod_betamfx <- betamfx(y ~ x | x, data = d) tidy(mod_betamfx, conf.int = TRUE) # Compare with the naive model coefficients of the equivalent betareg call (not run) # tidy(betamfx(y ~ x | x, data = d), conf.int = TRUE) augment(mod_betamfx) glance(mod_betamfx)
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'betareg' tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
## S3 method for class 'betareg' tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
x |
A |
conf.int |
Logical indicating whether or not to include a confidence
interval in the tidied output. Defaults to |
conf.level |
The confidence level to use for the confidence interval
if |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
The tibble has one row for each term in the regression. The
component
column indicates whether a particular
term was used to model either the "mean"
or "precision"
. Here the
precision is the inverse of the variance, often referred to as phi
.
At least one term will have been used to model the precision phi
.
A tibble::tibble()
with columns:
conf.high |
Upper bound on the confidence interval for the estimate. |
conf.low |
Lower bound on the confidence interval for the estimate. |
estimate |
The estimated value of the regression term. |
p.value |
The two-sided p-value associated with the observed statistic. |
statistic |
The value of a T-statistic to use in a hypothesis that the regression term is non-zero. |
std.error |
The standard error of the regression term. |
term |
The name of the regression term. |
component |
Whether a particular term was used to model the mean or the precision in the regression. See details. |
# load libraries for models and data library(betareg) # load dats data("GasolineYield", package = "betareg") # fit model mod <- betareg(yield ~ batch + temp, data = GasolineYield) mod # summarize model fit with tidiers tidy(mod) tidy(mod, conf.int = TRUE) tidy(mod, conf.int = TRUE, conf.level = .99) augment(mod) glance(mod)
# load libraries for models and data library(betareg) # load dats data("GasolineYield", package = "betareg") # fit model mod <- betareg(yield ~ batch + temp, data = GasolineYield) mod # summarize model fit with tidiers tidy(mod) tidy(mod, conf.int = TRUE) tidy(mod, conf.int = TRUE, conf.level = .99) augment(mod) glance(mod)
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'biglm' tidy(x, conf.int = FALSE, conf.level = 0.95, exponentiate = FALSE, ...)
## S3 method for class 'biglm' tidy(x, conf.int = FALSE, conf.level = 0.95, exponentiate = FALSE, ...)
x |
A |
conf.int |
Logical indicating whether or not to include a confidence
interval in the tidied output. Defaults to |
conf.level |
The confidence level to use for the confidence interval
if |
exponentiate |
Logical indicating whether or not to exponentiate the
the coefficient estimates. This is typical for logistic and multinomial
regressions, but a bad idea if there is no log or logit link. Defaults
to |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with columns:
conf.high |
Upper bound on the confidence interval for the estimate. |
conf.low |
Lower bound on the confidence interval for the estimate. |
estimate |
The estimated value of the regression term. |
p.value |
The two-sided p-value associated with the observed statistic. |
statistic |
The value of a T-statistic to use in a hypothesis that the regression term is non-zero. |
std.error |
The standard error of the regression term. |
term |
The name of the regression term. |
tidy()
, biglm::biglm()
, biglm::bigglm()
Other biglm tidiers:
glance.biglm()
# load modeling library library(biglm) # fit model -- linear regression bfit <- biglm(mpg ~ wt + disp, mtcars) # summarize model fit with tidiers tidy(bfit) tidy(bfit, conf.int = TRUE) tidy(bfit, conf.int = TRUE, conf.level = .9) glance(bfit) # fit model -- logistic regression bgfit <- bigglm(am ~ mpg, mtcars, family = binomial()) # summarize model fit with tidiers tidy(bgfit) tidy(bgfit, exponentiate = TRUE) tidy(bgfit, conf.int = TRUE) tidy(bgfit, conf.int = TRUE, conf.level = .9) tidy(bgfit, conf.int = TRUE, conf.level = .9, exponentiate = TRUE) glance(bgfit)
# load modeling library library(biglm) # fit model -- linear regression bfit <- biglm(mpg ~ wt + disp, mtcars) # summarize model fit with tidiers tidy(bfit) tidy(bfit, conf.int = TRUE) tidy(bfit, conf.int = TRUE, conf.level = .9) glance(bfit) # fit model -- logistic regression bgfit <- bigglm(am ~ mpg, mtcars, family = binomial()) # summarize model fit with tidiers tidy(bgfit) tidy(bgfit, exponentiate = TRUE) tidy(bgfit, conf.int = TRUE) tidy(bgfit, conf.int = TRUE, conf.level = .9) tidy(bgfit, conf.int = TRUE, conf.level = .9, exponentiate = TRUE) glance(bgfit)
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'binDesign' tidy(x, ...)
## S3 method for class 'binDesign' tidy(x, ...)
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with columns:
n |
Number of trials in given iteration. |
power |
Power achieved for given value of n. |
Other bingroup tidiers:
glance.binDesign()
,
tidy.binWidth()
library(binGroup) des <- binDesign( nmax = 300, delta = 0.06, p.hyp = 0.1, power = .8 ) glance(des) tidy(des) # the ggplot2 equivalent of plot(des) library(ggplot2) ggplot(tidy(des), aes(n, power)) + geom_line()
library(binGroup) des <- binDesign( nmax = 300, delta = 0.06, p.hyp = 0.1, power = .8 ) glance(des) tidy(des) # the ggplot2 equivalent of plot(des) library(ggplot2) ggplot(tidy(des), aes(n, power)) + geom_line()
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'binWidth' tidy(x, ...)
## S3 method for class 'binWidth' tidy(x, ...)
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with columns:
alternative |
Alternative hypothesis (character). |
ci.width |
Expected width of confidence interval. |
p |
True proportion. |
n |
Total sample size |
Other bingroup tidiers:
glance.binDesign()
,
tidy.binDesign()
# load libraries library(binGroup) # fit model bw <- binWidth(100, .1) bw # summarize model fit with tidiers tidy(bw)
# load libraries library(binGroup) # fit model bw <- binWidth(100, .1) bw # summarize model fit with tidiers tidy(bw)
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'boot' tidy( x, conf.int = FALSE, conf.level = 0.95, conf.method = c("perc", "bca", "basic", "norm"), exponentiate = FALSE, ... )
## S3 method for class 'boot' tidy( x, conf.int = FALSE, conf.level = 0.95, conf.method = c("perc", "bca", "basic", "norm"), exponentiate = FALSE, ... )
x |
A |
conf.int |
Logical indicating whether or not to include a confidence
interval in the tidied output. Defaults to |
conf.level |
The confidence level to use for the confidence interval
if |
conf.method |
Passed to the |
exponentiate |
Logical indicating whether or not to exponentiate the
the coefficient estimates. This is typical for logistic and multinomial
regressions, but a bad idea if there is no log or logit link. Defaults
to |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
If weights were provided to the boot
function, an estimate
column is included showing the weighted bootstrap estimate, and the
standard error is of that estimate.
If there are no original statistics in the "boot" object, such as with a
call to tsboot
with orig.t = FALSE
, the original
and statistic
columns are omitted, and only estimate
and
std.error
columns shown.
A tibble::tibble()
with columns:
bias |
Bias of the statistic. |
std.error |
The standard error of the regression term. |
term |
The name of the regression term. |
statistic |
Original value of the statistic. |
tidy()
, boot::boot()
, boot::tsboot()
, boot::boot.ci()
,
rsample::bootstraps()
# load modeling library library(boot) clotting <- data.frame( u = c(5, 10, 15, 20, 30, 40, 60, 80, 100), lot1 = c(118, 58, 42, 35, 27, 25, 21, 19, 18), lot2 = c(69, 35, 26, 21, 18, 16, 13, 12, 12) ) # fit models g1 <- glm(lot2 ~ log(u), data = clotting, family = Gamma) bootfun <- function(d, i) { coef(update(g1, data = d[i, ])) } bootres <- boot(clotting, bootfun, R = 999) # summarize model fits with tidiers tidy(g1, conf.int = TRUE) tidy(bootres, conf.int = TRUE)
# load modeling library library(boot) clotting <- data.frame( u = c(5, 10, 15, 20, 30, 40, 60, 80, 100), lot1 = c(118, 58, 42, 35, 27, 25, 21, 19, 18), lot2 = c(69, 35, 26, 21, 18, 16, 13, 12, 12) ) # fit models g1 <- glm(lot2 ~ log(u), data = clotting, family = Gamma) bootfun <- function(d, i) { coef(update(g1, data = d[i, ])) } bootres <- boot(clotting, bootfun, R = 999) # summarize model fits with tidiers tidy(g1, conf.int = TRUE) tidy(bootres, conf.int = TRUE)
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
This method tidies the coefficients of a bootstrapped temporal exponential random graph model estimated with the xergm. It simply returns the coefficients and their confidence intervals.
## S3 method for class 'btergm' tidy(x, conf.level = 0.95, exponentiate = FALSE, ...)
## S3 method for class 'btergm' tidy(x, conf.level = 0.95, exponentiate = FALSE, ...)
x |
A |
conf.level |
Confidence level for confidence intervals. Defaults to 0.95. |
exponentiate |
Logical indicating whether or not to exponentiate the
the coefficient estimates. This is typical for logistic and multinomial
regressions, but a bad idea if there is no log or logit link. Defaults
to |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with columns:
conf.high |
Upper bound on the confidence interval for the estimate. |
conf.low |
Lower bound on the confidence interval for the estimate. |
estimate |
The estimated value of the regression term. |
term |
The name of the regression term. |
library(btergm) library(network) set.seed(5) # create 10 random networks with 10 actors networks <- list() for (i in 1:10) { mat <- matrix(rbinom(100, 1, .25), nrow = 10, ncol = 10) diag(mat) <- 0 nw <- network(mat) networks[[i]] <- nw } # create 10 matrices as covariates covariates <- list() for (i in 1:10) { mat <- matrix(rnorm(100), nrow = 10, ncol = 10) covariates[[i]] <- mat } # fit the model mod <- btergm(networks ~ edges + istar(2) + edgecov(covariates), R = 100) # summarize model fit with tidiers tidy(mod)
library(btergm) library(network) set.seed(5) # create 10 random networks with 10 actors networks <- list() for (i in 1:10) { mat <- matrix(rbinom(100, 1, .25), nrow = 10, ncol = 10) diag(mat) <- 0 nw <- network(mat) networks[[i]] <- nw } # create 10 matrices as covariates covariates <- list() for (i in 1:10) { mat <- matrix(rnorm(100), nrow = 10, ncol = 10) covariates[[i]] <- mat } # fit the model mod <- btergm(networks ~ edges + istar(2) + edgecov(covariates), R = 100) # summarize model fit with tidiers tidy(mod)
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'cch' tidy(x, conf.level = 0.95, ...)
## S3 method for class 'cch' tidy(x, conf.level = 0.95, ...)
x |
An |
conf.level |
confidence level for CI |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with columns:
conf.high |
Upper bound on the confidence interval for the estimate. |
conf.low |
Lower bound on the confidence interval for the estimate. |
estimate |
The estimated value of the regression term. |
p.value |
The two-sided p-value associated with the observed statistic. |
statistic |
The value of a T-statistic to use in a hypothesis that the regression term is non-zero. |
std.error |
The standard error of the regression term. |
term |
The name of the regression term. |
Other cch tidiers:
glance.cch()
,
glance.survfit()
Other survival tidiers:
augment.coxph()
,
augment.survreg()
,
glance.aareg()
,
glance.cch()
,
glance.coxph()
,
glance.pyears()
,
glance.survdiff()
,
glance.survexp()
,
glance.survfit()
,
glance.survreg()
,
tidy.aareg()
,
tidy.coxph()
,
tidy.pyears()
,
tidy.survdiff()
,
tidy.survexp()
,
tidy.survfit()
,
tidy.survreg()
# load libraries for models and data library(survival) # examples come from cch documentation subcoh <- nwtco$in.subcohort selccoh <- with(nwtco, rel == 1 | subcoh == 1) ccoh.data <- nwtco[selccoh, ] ccoh.data$subcohort <- subcoh[selccoh] # central-lab histology ccoh.data$histol <- factor(ccoh.data$histol, labels = c("FH", "UH")) # tumour stage ccoh.data$stage <- factor(ccoh.data$stage, labels = c("I", "II", "III", "IV")) ccoh.data$age <- ccoh.data$age / 12 # age in years # fit model fit.ccP <- cch(Surv(edrel, rel) ~ stage + histol + age, data = ccoh.data, subcoh = ~subcohort, id = ~seqno, cohort.size = 4028 ) # summarize model fit with tidiers + visualization tidy(fit.ccP) # coefficient plot library(ggplot2) ggplot(tidy(fit.ccP), aes(x = estimate, y = term)) + geom_point() + geom_errorbarh(aes(xmin = conf.low, xmax = conf.high), height = 0) + geom_vline(xintercept = 0)
# load libraries for models and data library(survival) # examples come from cch documentation subcoh <- nwtco$in.subcohort selccoh <- with(nwtco, rel == 1 | subcoh == 1) ccoh.data <- nwtco[selccoh, ] ccoh.data$subcohort <- subcoh[selccoh] # central-lab histology ccoh.data$histol <- factor(ccoh.data$histol, labels = c("FH", "UH")) # tumour stage ccoh.data$stage <- factor(ccoh.data$stage, labels = c("I", "II", "III", "IV")) ccoh.data$age <- ccoh.data$age / 12 # age in years # fit model fit.ccP <- cch(Surv(edrel, rel) ~ stage + histol + age, data = ccoh.data, subcoh = ~subcohort, id = ~seqno, cohort.size = 4028 ) # summarize model fit with tidiers + visualization tidy(fit.ccP) # coefficient plot library(ggplot2) ggplot(tidy(fit.ccP), aes(x = estimate, y = term)) + geom_point() + geom_errorbarh(aes(xmin = conf.low, xmax = conf.high), height = 0) + geom_vline(xintercept = 0)
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'cld' tidy(x, ...)
## S3 method for class 'cld' tidy(x, ...)
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with columns:
contrast |
Levels being compared. |
letters |
Compact letter display denoting all pair-wise comparisons. |
tidy()
, multcomp::cld()
, multcomp::summary.glht()
,
multcomp::confint.glht()
, multcomp::glht()
Other multcomp tidiers:
tidy.confint.glht()
,
tidy.glht()
,
tidy.summary.glht()
# load libraries for models and data library(multcomp) library(ggplot2) amod <- aov(breaks ~ wool + tension, data = warpbreaks) wht <- glht(amod, linfct = mcp(tension = "Tukey")) tidy(wht) ggplot(wht, aes(lhs, estimate)) + geom_point() CI <- confint(wht) tidy(CI) ggplot(CI, aes(lhs, estimate, ymin = lwr, ymax = upr)) + geom_pointrange() tidy(summary(wht)) ggplot(mapping = aes(lhs, estimate)) + geom_linerange(aes(ymin = lwr, ymax = upr), data = CI) + geom_point(aes(size = p), data = summary(wht)) + scale_size(trans = "reverse") cld <- cld(wht) tidy(cld)
# load libraries for models and data library(multcomp) library(ggplot2) amod <- aov(breaks ~ wool + tension, data = warpbreaks) wht <- glht(amod, linfct = mcp(tension = "Tukey")) tidy(wht) ggplot(wht, aes(lhs, estimate)) + geom_point() CI <- confint(wht) tidy(CI) ggplot(CI, aes(lhs, estimate, ymin = lwr, ymax = upr)) + geom_pointrange() tidy(summary(wht)) ggplot(mapping = aes(lhs, estimate)) + geom_linerange(aes(ymin = lwr, ymax = upr), data = CI) + geom_point(aes(size = p), data = summary(wht)) + scale_size(trans = "reverse") cld <- cld(wht) tidy(cld)
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'clm' tidy( x, conf.int = FALSE, conf.level = 0.95, conf.type = c("profile", "Wald"), exponentiate = FALSE, ... )
## S3 method for class 'clm' tidy( x, conf.int = FALSE, conf.level = 0.95, conf.type = c("profile", "Wald"), exponentiate = FALSE, ... )
x |
A |
conf.int |
Logical indicating whether or not to include a confidence
interval in the tidied output. Defaults to |
conf.level |
The confidence level to use for the confidence interval
if |
conf.type |
Whether to use |
exponentiate |
Logical indicating whether or not to exponentiate the
the coefficient estimates. This is typical for logistic and multinomial
regressions, but a bad idea if there is no log or logit link. Defaults
to |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
In broom 0.7.0
the coefficient_type
column was renamed to
coef.type
, and the contents were changed as well.
Note that intercept
type coefficients correspond to alpha
parameters, location
type coefficients correspond to beta
parameters, and scale
type coefficients correspond to zeta
parameters.
A tibble::tibble()
with columns:
conf.high |
Upper bound on the confidence interval for the estimate. |
conf.low |
Lower bound on the confidence interval for the estimate. |
estimate |
The estimated value of the regression term. |
p.value |
The two-sided p-value associated with the observed statistic. |
statistic |
The value of a T-statistic to use in a hypothesis that the regression term is non-zero. |
std.error |
The standard error of the regression term. |
term |
The name of the regression term. |
tidy, ordinal::clm()
, ordinal::confint.clm()
Other ordinal tidiers:
augment.clm()
,
augment.polr()
,
glance.clm()
,
glance.clmm()
,
glance.polr()
,
glance.svyolr()
,
tidy.clmm()
,
tidy.polr()
,
tidy.svyolr()
# load libraries for models and data library(ordinal) # fit model fit <- clm(rating ~ temp * contact, data = wine) # summarize model fit with tidiers tidy(fit) tidy(fit, conf.int = TRUE, conf.level = 0.9) tidy(fit, conf.int = TRUE, conf.type = "Wald", exponentiate = TRUE) glance(fit) augment(fit, type.predict = "prob") augment(fit, type.predict = "class") # ...and again with another model specification fit2 <- clm(rating ~ temp, nominal = ~contact, data = wine) tidy(fit2) glance(fit2)
# load libraries for models and data library(ordinal) # fit model fit <- clm(rating ~ temp * contact, data = wine) # summarize model fit with tidiers tidy(fit) tidy(fit, conf.int = TRUE, conf.level = 0.9) tidy(fit, conf.int = TRUE, conf.type = "Wald", exponentiate = TRUE) glance(fit) augment(fit, type.predict = "prob") augment(fit, type.predict = "class") # ...and again with another model specification fit2 <- clm(rating ~ temp, nominal = ~contact, data = wine) tidy(fit2) glance(fit2)
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'clmm' tidy(x, conf.int = FALSE, conf.level = 0.95, exponentiate = FALSE, ...)
## S3 method for class 'clmm' tidy(x, conf.int = FALSE, conf.level = 0.95, exponentiate = FALSE, ...)
x |
A |
conf.int |
Logical indicating whether or not to include a confidence
interval in the tidied output. Defaults to |
conf.level |
The confidence level to use for the confidence interval
if |
exponentiate |
Logical indicating whether or not to exponentiate the
the coefficient estimates. This is typical for logistic and multinomial
regressions, but a bad idea if there is no log or logit link. Defaults
to |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with columns:
conf.high |
Upper bound on the confidence interval for the estimate. |
conf.low |
Lower bound on the confidence interval for the estimate. |
estimate |
The estimated value of the regression term. |
p.value |
The two-sided p-value associated with the observed statistic. |
statistic |
The value of a T-statistic to use in a hypothesis that the regression term is non-zero. |
std.error |
The standard error of the regression term. |
term |
The name of the regression term. |
In broom 0.7.0
the coefficient_type
column was renamed to
coef.type
, and the contents were changed as well.
Note that intercept
type coefficients correspond to alpha
parameters, location
type coefficients correspond to beta
parameters, and scale
type coefficients correspond to zeta
parameters.
tidy, ordinal::clmm()
, ordinal::confint.clm()
Other ordinal tidiers:
augment.clm()
,
augment.polr()
,
glance.clm()
,
glance.clmm()
,
glance.polr()
,
glance.svyolr()
,
tidy.clm()
,
tidy.polr()
,
tidy.svyolr()
# load libraries for models and data library(ordinal) # fit model fit <- clmm(rating ~ temp + contact + (1 | judge), data = wine) # summarize model fit with tidiers tidy(fit) tidy(fit, conf.int = TRUE, conf.level = 0.9) tidy(fit, conf.int = TRUE, exponentiate = TRUE) glance(fit) # ...and again with another model specification fit2 <- clmm(rating ~ temp + (1 | judge), nominal = ~contact, data = wine) tidy(fit2) glance(fit2)
# load libraries for models and data library(ordinal) # fit model fit <- clmm(rating ~ temp + contact + (1 | judge), data = wine) # summarize model fit with tidiers tidy(fit) tidy(fit, conf.int = TRUE, conf.level = 0.9) tidy(fit, conf.int = TRUE, exponentiate = TRUE) glance(fit) # ...and again with another model specification fit2 <- clmm(rating ~ temp + (1 | judge), nominal = ~contact, data = wine) tidy(fit2) glance(fit2)
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'coeftest' tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
## S3 method for class 'coeftest' tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
x |
A |
conf.int |
Logical indicating whether or not to include a confidence
interval in the tidied output. Defaults to |
conf.level |
The confidence level to use for the confidence interval
if |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with columns:
conf.high |
Upper bound on the confidence interval for the estimate. |
conf.low |
Lower bound on the confidence interval for the estimate. |
estimate |
The estimated value of the regression term. |
p.value |
The two-sided p-value associated with the observed statistic. |
statistic |
The value of a T-statistic to use in a hypothesis that the regression term is non-zero. |
std.error |
The standard error of the regression term. |
term |
The name of the regression term. |
# load libraries for models and data library(lmtest) m <- lm(dist ~ speed, data = cars) coeftest(m) tidy(coeftest(m)) tidy(coeftest(m, conf.int = TRUE)) # a very common workflow is to combine lmtest::coeftest with alternate # variance-covariance matrices via the sandwich package. The lmtest # tidiers support this workflow too, enabling you to adjust the standard # errors of your tidied models on the fly. library(sandwich) # "HC3" (default) robust SEs tidy(coeftest(m, vcov = vcovHC)) # "HC2" robust SEs tidy(coeftest(m, vcov = vcovHC, type = "HC2")) # N-W HAC robust SEs tidy(coeftest(m, vcov = NeweyWest)) # the columns of the returned tibble for glance.coeftest() will vary # depending on whether the coeftest object retains the underlying model. # Users can control this with the "save = TRUE" argument of coeftest(). glance(coeftest(m)) glance(coeftest(m, save = TRUE))
# load libraries for models and data library(lmtest) m <- lm(dist ~ speed, data = cars) coeftest(m) tidy(coeftest(m)) tidy(coeftest(m, conf.int = TRUE)) # a very common workflow is to combine lmtest::coeftest with alternate # variance-covariance matrices via the sandwich package. The lmtest # tidiers support this workflow too, enabling you to adjust the standard # errors of your tidied models on the fly. library(sandwich) # "HC3" (default) robust SEs tidy(coeftest(m, vcov = vcovHC)) # "HC2" robust SEs tidy(coeftest(m, vcov = vcovHC, type = "HC2")) # N-W HAC robust SEs tidy(coeftest(m, vcov = NeweyWest)) # the columns of the returned tibble for glance.coeftest() will vary # depending on whether the coeftest object retains the underlying model. # Users can control this with the "save = TRUE" argument of coeftest(). glance(coeftest(m)) glance(coeftest(m, save = TRUE))
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'confint.glht' tidy(x, ...)
## S3 method for class 'confint.glht' tidy(x, ...)
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with columns:
conf.high |
Upper bound on the confidence interval for the estimate. |
conf.low |
Lower bound on the confidence interval for the estimate. |
contrast |
Levels being compared. |
estimate |
The estimated value of the regression term. |
tidy()
, multcomp::confint.glht()
, multcomp::glht()
Other multcomp tidiers:
tidy.cld()
,
tidy.glht()
,
tidy.summary.glht()
# load libraries for models and data library(multcomp) library(ggplot2) amod <- aov(breaks ~ wool + tension, data = warpbreaks) wht <- glht(amod, linfct = mcp(tension = "Tukey")) tidy(wht) ggplot(wht, aes(lhs, estimate)) + geom_point() CI <- confint(wht) tidy(CI) ggplot(CI, aes(lhs, estimate, ymin = lwr, ymax = upr)) + geom_pointrange() tidy(summary(wht)) ggplot(mapping = aes(lhs, estimate)) + geom_linerange(aes(ymin = lwr, ymax = upr), data = CI) + geom_point(aes(size = p), data = summary(wht)) + scale_size(trans = "reverse") cld <- cld(wht) tidy(cld)
# load libraries for models and data library(multcomp) library(ggplot2) amod <- aov(breaks ~ wool + tension, data = warpbreaks) wht <- glht(amod, linfct = mcp(tension = "Tukey")) tidy(wht) ggplot(wht, aes(lhs, estimate)) + geom_point() CI <- confint(wht) tidy(CI) ggplot(CI, aes(lhs, estimate, ymin = lwr, ymax = upr)) + geom_pointrange() tidy(summary(wht)) ggplot(mapping = aes(lhs, estimate)) + geom_linerange(aes(ymin = lwr, ymax = upr), data = CI) + geom_point(aes(size = p), data = summary(wht)) + scale_size(trans = "reverse") cld <- cld(wht) tidy(cld)
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'confusionMatrix' tidy(x, by_class = TRUE, ...)
## S3 method for class 'confusionMatrix' tidy(x, by_class = TRUE, ...)
x |
An object of class |
by_class |
Logical indicating whether or not to show performance
measures broken down by class. Defaults to |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with columns:
class |
The class under consideration. |
conf.high |
Upper bound on the confidence interval for the estimate. |
conf.low |
Lower bound on the confidence interval for the estimate. |
estimate |
The estimated value of the regression term. |
term |
The name of the regression term. |
p.value |
P-value for accuracy and kappa statistics. |
tidy()
, caret::confusionMatrix()
# load libraries for models and data library(caret) set.seed(27) # generate data two_class_sample1 <- as.factor(sample(letters[1:2], 100, TRUE)) two_class_sample2 <- as.factor(sample(letters[1:2], 100, TRUE)) two_class_cm <- confusionMatrix( two_class_sample1, two_class_sample2 ) # summarize model fit with tidiers tidy(two_class_cm) tidy(two_class_cm, by_class = FALSE) # multiclass example six_class_sample1 <- as.factor(sample(letters[1:6], 100, TRUE)) six_class_sample2 <- as.factor(sample(letters[1:6], 100, TRUE)) six_class_cm <- confusionMatrix( six_class_sample1, six_class_sample2 ) # summarize model fit with tidiers tidy(six_class_cm) tidy(six_class_cm, by_class = FALSE)
# load libraries for models and data library(caret) set.seed(27) # generate data two_class_sample1 <- as.factor(sample(letters[1:2], 100, TRUE)) two_class_sample2 <- as.factor(sample(letters[1:2], 100, TRUE)) two_class_cm <- confusionMatrix( two_class_sample1, two_class_sample2 ) # summarize model fit with tidiers tidy(two_class_cm) tidy(two_class_cm, by_class = FALSE) # multiclass example six_class_sample1 <- as.factor(sample(letters[1:6], 100, TRUE)) six_class_sample2 <- as.factor(sample(letters[1:6], 100, TRUE)) six_class_cm <- confusionMatrix( six_class_sample1, six_class_sample2 ) # summarize model fit with tidiers tidy(six_class_cm) tidy(six_class_cm, by_class = FALSE)
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'coxph' tidy(x, exponentiate = FALSE, conf.int = FALSE, conf.level = 0.95, ...)
## S3 method for class 'coxph' tidy(x, exponentiate = FALSE, conf.int = FALSE, conf.level = 0.95, ...)
x |
A |
exponentiate |
Logical indicating whether or not to exponentiate the
the coefficient estimates. This is typical for logistic and multinomial
regressions, but a bad idea if there is no log or logit link. Defaults
to |
conf.int |
Logical indicating whether or not to include a confidence
interval in the tidied output. Defaults to |
conf.level |
The confidence level to use for the confidence interval
if |
... |
For |
A tibble::tibble()
with columns:
estimate |
The estimated value of the regression term. |
p.value |
The two-sided p-value associated with the observed statistic. |
statistic |
The value of a T-statistic to use in a hypothesis that the regression term is non-zero. |
std.error |
The standard error of the regression term. |
Other coxph tidiers:
augment.coxph()
,
glance.coxph()
Other survival tidiers:
augment.coxph()
,
augment.survreg()
,
glance.aareg()
,
glance.cch()
,
glance.coxph()
,
glance.pyears()
,
glance.survdiff()
,
glance.survexp()
,
glance.survfit()
,
glance.survreg()
,
tidy.aareg()
,
tidy.cch()
,
tidy.pyears()
,
tidy.survdiff()
,
tidy.survexp()
,
tidy.survfit()
,
tidy.survreg()
# load libraries for models and data library(survival) # fit model cfit <- coxph(Surv(time, status) ~ age + sex, lung) # summarize model fit with tidiers tidy(cfit) tidy(cfit, exponentiate = TRUE) lp <- augment(cfit, lung) risks <- augment(cfit, lung, type.predict = "risk") expected <- augment(cfit, lung, type.predict = "expected") glance(cfit) # also works on clogit models resp <- levels(logan$occupation) n <- nrow(logan) indx <- rep(1:n, length(resp)) logan2 <- data.frame( logan[indx, ], id = indx, tocc = factor(rep(resp, each = n)) ) logan2$case <- (logan2$occupation == logan2$tocc) cl <- clogit(case ~ tocc + tocc:education + strata(id), logan2) tidy(cl) glance(cl) library(ggplot2) ggplot(lp, aes(age, .fitted, color = sex)) + geom_point() ggplot(risks, aes(age, .fitted, color = sex)) + geom_point() ggplot(expected, aes(time, .fitted, color = sex)) + geom_point()
# load libraries for models and data library(survival) # fit model cfit <- coxph(Surv(time, status) ~ age + sex, lung) # summarize model fit with tidiers tidy(cfit) tidy(cfit, exponentiate = TRUE) lp <- augment(cfit, lung) risks <- augment(cfit, lung, type.predict = "risk") expected <- augment(cfit, lung, type.predict = "expected") glance(cfit) # also works on clogit models resp <- levels(logan$occupation) n <- nrow(logan) indx <- rep(1:n, length(resp)) logan2 <- data.frame( logan[indx, ], id = indx, tocc = factor(rep(resp, each = n)) ) logan2$case <- (logan2$occupation == logan2$tocc) cl <- clogit(case ~ tocc + tocc:education + strata(id), logan2) tidy(cl) glance(cl) library(ggplot2) ggplot(lp, aes(age, .fitted, color = sex)) + geom_point() ggplot(risks, aes(age, .fitted, color = sex)) + geom_point() ggplot(expected, aes(time, .fitted, color = sex)) + geom_point()
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'crr' tidy(x, exponentiate = FALSE, conf.int = FALSE, conf.level = 0.95, ...)
## S3 method for class 'crr' tidy(x, exponentiate = FALSE, conf.int = FALSE, conf.level = 0.95, ...)
x |
A |
exponentiate |
Logical indicating whether or not to exponentiate the
the coefficient estimates. This is typical for logistic and multinomial
regressions, but a bad idea if there is no log or logit link. Defaults
to |
conf.int |
Logical indicating whether or not to include a confidence
interval in the tidied output. Defaults to |
conf.level |
The confidence level to use for the confidence interval
if |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with columns:
conf.high |
Upper bound on the confidence interval for the estimate. |
conf.low |
Lower bound on the confidence interval for the estimate. |
estimate |
The estimated value of the regression term. |
p.value |
The two-sided p-value associated with the observed statistic. |
statistic |
The value of a T-statistic to use in a hypothesis that the regression term is non-zero. |
std.error |
The standard error of the regression term. |
Other cmprsk tidiers:
glance.crr()
library(cmprsk) # time to loco-regional failure (lrf) lrf_time <- rexp(100) lrf_event <- sample(0:2, 100, replace = TRUE) trt <- sample(0:1, 100, replace = TRUE) strt <- sample(1:2, 100, replace = TRUE) # fit model x <- crr(lrf_time, lrf_event, cbind(trt, strt)) # summarize model fit with tidiers tidy(x, conf.int = TRUE) glance(x)
library(cmprsk) # time to loco-regional failure (lrf) lrf_time <- rexp(100) lrf_event <- sample(0:2, 100, replace = TRUE) trt <- sample(0:1, 100, replace = TRUE) strt <- sample(1:2, 100, replace = TRUE) # fit model x <- crr(lrf_time, lrf_event, cbind(trt, strt)) # summarize model fit with tidiers tidy(x, conf.int = TRUE) glance(x)
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'cv.glmnet' tidy(x, ...)
## S3 method for class 'cv.glmnet' tidy(x, ...)
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with columns:
lambda |
Value of penalty parameter lambda. |
nzero |
Number of non-zero coefficients for the given lambda. |
std.error |
The standard error of the regression term. |
conf.low |
lower bound on confidence interval for cross-validation estimated loss. |
conf.high |
upper bound on confidence interval for cross-validation estimated loss. |
estimate |
Median loss across all cross-validation folds for a given lamdba |
Other glmnet tidiers:
glance.cv.glmnet()
,
glance.glmnet()
,
tidy.glmnet()
# load libraries for models and data library(glmnet) set.seed(27) nobs <- 100 nvar <- 50 real <- 5 x <- matrix(rnorm(nobs * nvar), nobs, nvar) beta <- c(rnorm(real, 0, 1), rep(0, nvar - real)) y <- c(t(beta) %*% t(x)) + rnorm(nvar, sd = 3) cvfit1 <- cv.glmnet(x, y) tidy(cvfit1) glance(cvfit1) library(ggplot2) tidied_cv <- tidy(cvfit1) glance_cv <- glance(cvfit1) # plot of MSE as a function of lambda g <- ggplot(tidied_cv, aes(lambda, estimate)) + geom_line() + scale_x_log10() g # plot of MSE as a function of lambda with confidence ribbon g <- g + geom_ribbon(aes(ymin = conf.low, ymax = conf.high), alpha = .25) g # plot of MSE as a function of lambda with confidence ribbon and choices # of minimum lambda marked g <- g + geom_vline(xintercept = glance_cv$lambda.min) + geom_vline(xintercept = glance_cv$lambda.1se, lty = 2) g # plot of number of zeros for each choice of lambda ggplot(tidied_cv, aes(lambda, nzero)) + geom_line() + scale_x_log10() # coefficient plot with min lambda shown tidied <- tidy(cvfit1$glmnet.fit) ggplot(tidied, aes(lambda, estimate, group = term)) + scale_x_log10() + geom_line() + geom_vline(xintercept = glance_cv$lambda.min) + geom_vline(xintercept = glance_cv$lambda.1se, lty = 2)
# load libraries for models and data library(glmnet) set.seed(27) nobs <- 100 nvar <- 50 real <- 5 x <- matrix(rnorm(nobs * nvar), nobs, nvar) beta <- c(rnorm(real, 0, 1), rep(0, nvar - real)) y <- c(t(beta) %*% t(x)) + rnorm(nvar, sd = 3) cvfit1 <- cv.glmnet(x, y) tidy(cvfit1) glance(cvfit1) library(ggplot2) tidied_cv <- tidy(cvfit1) glance_cv <- glance(cvfit1) # plot of MSE as a function of lambda g <- ggplot(tidied_cv, aes(lambda, estimate)) + geom_line() + scale_x_log10() g # plot of MSE as a function of lambda with confidence ribbon g <- g + geom_ribbon(aes(ymin = conf.low, ymax = conf.high), alpha = .25) g # plot of MSE as a function of lambda with confidence ribbon and choices # of minimum lambda marked g <- g + geom_vline(xintercept = glance_cv$lambda.min) + geom_vline(xintercept = glance_cv$lambda.1se, lty = 2) g # plot of number of zeros for each choice of lambda ggplot(tidied_cv, aes(lambda, nzero)) + geom_line() + scale_x_log10() # coefficient plot with min lambda shown tidied <- tidy(cvfit1$glmnet.fit) ggplot(tidied, aes(lambda, estimate, group = term)) + scale_x_log10() + geom_line() + geom_vline(xintercept = glance_cv$lambda.min) + geom_vline(xintercept = glance_cv$lambda.1se, lty = 2)
(Deprecated) Tidy density objects
## S3 method for class 'density' tidy(x, ...)
## S3 method for class 'density' tidy(x, ...)
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble with two columns: points x
where the density
is estimated, and estimated density y
.
Other deprecated:
bootstrap()
,
confint_tidy()
,
data.frame_tidiers
,
finish_glance()
,
fix_data_frame()
,
summary_tidiers
,
tidy.dist()
,
tidy.ftable()
,
tidy.numeric()
(Deprecated) Tidy dist objects
## S3 method for class 'dist' tidy(x, diagonal = attr(x, "Diag"), upper = attr(x, "Upper"), ...)
## S3 method for class 'dist' tidy(x, diagonal = attr(x, "Diag"), upper = attr(x, "Upper"), ...)
x |
A |
diagonal |
Logical indicating whether or not to tidy the diagonal
elements of the distance matrix. Defaults to whatever was based to the
|
upper |
Logical indicating whether or not to tidy the upper half of
the distance matrix. Defaults to whatever was based to the
|
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
If the distance matrix does not include an upper triangle and/or diagonal, the tidied version will not either.
A tibble::tibble with one row for each pair of items in the distance matrix, with columns:
item1 |
First item |
item2 |
Second item |
distance |
Distance between items |
Other deprecated:
bootstrap()
,
confint_tidy()
,
data.frame_tidiers
,
finish_glance()
,
fix_data_frame()
,
summary_tidiers
,
tidy.density()
,
tidy.ftable()
,
tidy.numeric()
cars_dist <- dist(t(mtcars[, 1:4])) cars_dist tidy(cars_dist) tidy(cars_dist, upper = TRUE) tidy(cars_dist, diagonal = TRUE)
cars_dist <- dist(t(mtcars[, 1:4])) cars_dist tidy(cars_dist) tidy(cars_dist, upper = TRUE) tidy(cars_dist, diagonal = TRUE)
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'drc' tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
## S3 method for class 'drc' tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
x |
A |
conf.int |
Logical indicating whether or not to include a confidence
interval in the tidied output. Defaults to |
conf.level |
The confidence level to use for the confidence interval
if |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
The tibble has one row for each curve and term in the regression.
The curveid
column indicates the curve.
A tibble::tibble()
with columns:
conf.high |
Upper bound on the confidence interval for the estimate. |
conf.low |
Lower bound on the confidence interval for the estimate. |
estimate |
The estimated value of the regression term. |
p.value |
The two-sided p-value associated with the observed statistic. |
statistic |
The value of a T-statistic to use in a hypothesis that the regression term is non-zero. |
std.error |
The standard error of the regression term. |
term |
The name of the regression term. |
curve |
Index identifying the curve. |
Other drc tidiers:
augment.drc()
,
glance.drc()
# load libraries for models and data library(drc) # fit model mod <- drm(dead / total ~ conc, type, weights = total, data = selenium, fct = LL.2(), type = "binomial" ) # summarize model fit with tidiers tidy(mod) tidy(mod, conf.int = TRUE) glance(mod) augment(mod, selenium)
# load libraries for models and data library(drc) # fit model mod <- drm(dead / total ~ conc, type, weights = total, data = selenium, fct = LL.2(), type = "binomial" ) # summarize model fit with tidiers tidy(mod) tidy(mod, conf.int = TRUE) glance(mod) augment(mod, selenium)
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'emmGrid' tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
## S3 method for class 'emmGrid' tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
x |
An |
conf.int |
Logical indicating whether or not to include a confidence
interval in the tidied output. Defaults to |
conf.level |
The confidence level to use for the confidence interval
if |
... |
Additional arguments passed to |
Returns a data frame with one observation for each estimated marginal mean, and one column for each combination of factors. When the input is a contrast, each row will contain one estimated contrast.
There are a large number of arguments that can be
passed on to emmeans::summary.emmGrid()
or lsmeans::summary.ref.grid()
.
A tibble::tibble()
with columns:
conf.high |
Upper bound on the confidence interval for the estimate. |
conf.low |
Lower bound on the confidence interval for the estimate. |
df |
Degrees of freedom used by this term in the model. |
p.value |
The two-sided p-value associated with the observed statistic. |
std.error |
The standard error of the regression term. |
estimate |
Expected marginal mean |
statistic |
T-ratio statistic |
tidy()
, emmeans::ref_grid()
, emmeans::emmeans()
,
emmeans::contrast()
Other emmeans tidiers:
tidy.lsmobj()
,
tidy.ref.grid()
,
tidy.summary_emm()
# load libraries for models and data library(emmeans) # linear model for sales of oranges per day oranges_lm1 <- lm(sales1 ~ price1 + price2 + day + store, data = oranges) # reference grid; see vignette("basics", package = "emmeans") oranges_rg1 <- ref_grid(oranges_lm1) td <- tidy(oranges_rg1) td # marginal averages marginal <- emmeans(oranges_rg1, "day") tidy(marginal) # contrasts tidy(contrast(marginal)) tidy(contrast(marginal, method = "pairwise")) # plot confidence intervals library(ggplot2) ggplot(tidy(marginal, conf.int = TRUE), aes(day, estimate)) + geom_point() + geom_errorbar(aes(ymin = conf.low, ymax = conf.high)) # by multiple prices by_price <- emmeans(oranges_lm1, "day", by = "price2", at = list( price1 = 50, price2 = c(40, 60, 80), day = c("2", "3", "4") ) ) by_price tidy(by_price) ggplot(tidy(by_price, conf.int = TRUE), aes(price2, estimate, color = day)) + geom_line() + geom_errorbar(aes(ymin = conf.low, ymax = conf.high)) # joint_tests tidy(joint_tests(oranges_lm1))
# load libraries for models and data library(emmeans) # linear model for sales of oranges per day oranges_lm1 <- lm(sales1 ~ price1 + price2 + day + store, data = oranges) # reference grid; see vignette("basics", package = "emmeans") oranges_rg1 <- ref_grid(oranges_lm1) td <- tidy(oranges_rg1) td # marginal averages marginal <- emmeans(oranges_rg1, "day") tidy(marginal) # contrasts tidy(contrast(marginal)) tidy(contrast(marginal, method = "pairwise")) # plot confidence intervals library(ggplot2) ggplot(tidy(marginal, conf.int = TRUE), aes(day, estimate)) + geom_point() + geom_errorbar(aes(ymin = conf.low, ymax = conf.high)) # by multiple prices by_price <- emmeans(oranges_lm1, "day", by = "price2", at = list( price1 = 50, price2 = c(40, 60, 80), day = c("2", "3", "4") ) ) by_price tidy(by_price) ggplot(tidy(by_price, conf.int = TRUE), aes(price2, estimate, color = day)) + geom_line() + geom_errorbar(aes(ymin = conf.low, ymax = conf.high)) # joint_tests tidy(joint_tests(oranges_lm1))
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'epi.2by2' tidy(x, parameters = c("moa", "stat"), ...)
## S3 method for class 'epi.2by2' tidy(x, parameters = c("moa", "stat"), ...)
x |
A |
parameters |
Return measures of association ( |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
The tibble has a column for each of the measures of association
or tests contained in massoc
or massoc.detail
when epiR::epi.2by2()
is called.
A tibble::tibble()
with columns:
conf.high |
Upper bound on the confidence interval for the estimate. |
conf.low |
Lower bound on the confidence interval for the estimate. |
df |
Degrees of freedom used by this term in the model. |
p.value |
The two-sided p-value associated with the observed statistic. |
statistic |
The value of a T-statistic to use in a hypothesis that the regression term is non-zero. |
term |
The name of the regression term. |
estimate |
Estimated measure of association |
# load libraries for models and data library(epiR) # generate data dat <- matrix(c(13, 2163, 5, 3349), nrow = 2, byrow = TRUE) rownames(dat) <- c("DF+", "DF-") colnames(dat) <- c("FUS+", "FUS-") # fit model fit <- epi.2by2( dat = as.table(dat), method = "cross.sectional", conf.level = 0.95, units = 100, outcome = "as.columns" ) # summarize model fit with tidiers tidy(fit, parameters = "moa") tidy(fit, parameters = "stat")
# load libraries for models and data library(epiR) # generate data dat <- matrix(c(13, 2163, 5, 3349), nrow = 2, byrow = TRUE) rownames(dat) <- c("DF+", "DF-") colnames(dat) <- c("FUS+", "FUS-") # fit model fit <- epi.2by2( dat = as.table(dat), method = "cross.sectional", conf.level = 0.95, units = 100, outcome = "as.columns" ) # summarize model fit with tidiers tidy(fit, parameters = "moa") tidy(fit, parameters = "stat")
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
The methods should work with any model that conforms to the ergm class, such as those produced from weighted networks by the ergm.count package.
## S3 method for class 'ergm' tidy(x, conf.int = FALSE, conf.level = 0.95, exponentiate = FALSE, ...)
## S3 method for class 'ergm' tidy(x, conf.int = FALSE, conf.level = 0.95, exponentiate = FALSE, ...)
x |
An |
conf.int |
Logical indicating whether or not to include a confidence
interval in the tidied output. Defaults to |
conf.level |
The confidence level to use for the confidence interval
if |
exponentiate |
Logical indicating whether or not to exponentiate the
the coefficient estimates. This is typical for logistic and multinomial
regressions, but a bad idea if there is no log or logit link. Defaults
to |
... |
Additional arguments to pass to |
A tibble::tibble with one row for each coefficient in the exponential random graph model, with columns:
term |
The term in the model being estimated and tested |
estimate |
The estimated coefficient |
std.error |
The standard error |
mcmc.error |
The MCMC error |
p.value |
The two-sided p-value |
Hunter DR, Handcock MS, Butts CT, Goodreau SM, Morris M (2008b). ergm: A Package to Fit, Simulate and Diagnose Exponential-Family Models for Networks. Journal of Statistical Software, 24(3). https://www.jstatsoft.org/v24/i03/.
tidy()
, ergm::ergm()
, ergm::control.ergm()
,
ergm::summary()
Other ergm tidiers:
glance.ergm()
# load libraries for models and data library(ergm) # load the Florentine marriage network data data(florentine) # fit a model where the propensity to form ties between # families depends on the absolute difference in wealth gest <- ergm(flomarriage ~ edges + absdiff("wealth")) # show terms, coefficient estimates and errors tidy(gest) # show coefficients as odds ratios with a 99% CI tidy(gest, exponentiate = TRUE, conf.int = TRUE, conf.level = 0.99) # take a look at likelihood measures and other # control parameters used during MCMC estimation glance(gest) glance(gest, deviance = TRUE) glance(gest, mcmc = TRUE)
# load libraries for models and data library(ergm) # load the Florentine marriage network data data(florentine) # fit a model where the propensity to form ties between # families depends on the absolute difference in wealth gest <- ergm(flomarriage ~ edges + absdiff("wealth")) # show terms, coefficient estimates and errors tidy(gest) # show coefficients as odds ratios with a 99% CI tidy(gest, exponentiate = TRUE, conf.int = TRUE, conf.level = 0.99) # take a look at likelihood measures and other # control parameters used during MCMC estimation glance(gest) glance(gest, deviance = TRUE) glance(gest, mcmc = TRUE)
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'factanal' tidy(x, ...)
## S3 method for class 'factanal' tidy(x, ...)
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with columns:
variable |
Variable under consideration. |
uniqueness |
Proportion of residual, or unexplained variance |
flX |
Factor loading for level X. |
Other factanal tidiers:
augment.factanal()
,
glance.factanal()
set.seed(123) # generate data library(dplyr) library(purrr) m1 <- tibble( v1 = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 4, 5, 6), v2 = c(1, 2, 1, 1, 1, 1, 2, 1, 2, 1, 3, 4, 3, 3, 3, 4, 6, 5), v3 = c(3, 3, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 4, 6), v4 = c(3, 3, 4, 3, 3, 1, 1, 2, 1, 1, 1, 1, 2, 1, 1, 5, 6, 4), v5 = c(1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 1, 1, 1, 1, 1, 6, 4, 5), v6 = c(1, 1, 1, 2, 1, 3, 3, 3, 4, 3, 1, 1, 1, 2, 1, 6, 5, 4) ) # new data m2 <- map_dfr(m1, rev) # factor analysis objects fit1 <- factanal(m1, factors = 3, scores = "Bartlett") fit2 <- factanal(m1, factors = 3, scores = "regression") # tidying the object tidy(fit1) tidy(fit2) # augmented dataframe augment(fit1) augment(fit2) # augmented dataframe (with new data) augment(fit1, data = m2) augment(fit2, data = m2)
set.seed(123) # generate data library(dplyr) library(purrr) m1 <- tibble( v1 = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 4, 5, 6), v2 = c(1, 2, 1, 1, 1, 1, 2, 1, 2, 1, 3, 4, 3, 3, 3, 4, 6, 5), v3 = c(3, 3, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 4, 6), v4 = c(3, 3, 4, 3, 3, 1, 1, 2, 1, 1, 1, 1, 2, 1, 1, 5, 6, 4), v5 = c(1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 1, 1, 1, 1, 1, 6, 4, 5), v6 = c(1, 1, 1, 2, 1, 3, 3, 3, 4, 3, 1, 1, 1, 2, 1, 6, 5, 4) ) # new data m2 <- map_dfr(m1, rev) # factor analysis objects fit1 <- factanal(m1, factors = 3, scores = "Bartlett") fit2 <- factanal(m1, factors = 3, scores = "regression") # tidying the object tidy(fit1) tidy(fit2) # augmented dataframe augment(fit1) augment(fit2) # augmented dataframe (with new data) augment(fit1, data = m2) augment(fit2, data = m2)
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'felm' tidy( x, conf.int = FALSE, conf.level = 0.95, fe = FALSE, se.type = c("default", "iid", "robust", "cluster"), ... )
## S3 method for class 'felm' tidy( x, conf.int = FALSE, conf.level = 0.95, fe = FALSE, se.type = c("default", "iid", "robust", "cluster"), ... )
x |
A |
conf.int |
Logical indicating whether or not to include a confidence
interval in the tidied output. Defaults to |
conf.level |
The confidence level to use for the confidence interval
if |
fe |
Logical indicating whether or not to include estimates of
fixed effects. Defaults to |
se.type |
Character indicating the type of standard errors. Defaults to using those of the underlying felm() model object, e.g. clustered errors for models that were provided a cluster specification. Users can override these defaults by specifying an appropriate alternative: "iid" (for homoskedastic errors), "robust" (for Eicker-Huber-White robust errors), or "cluster" (for clustered standard errors; if the model object supports it). |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with columns:
conf.high |
Upper bound on the confidence interval for the estimate. |
conf.low |
Lower bound on the confidence interval for the estimate. |
estimate |
The estimated value of the regression term. |
p.value |
The two-sided p-value associated with the observed statistic. |
statistic |
The value of a T-statistic to use in a hypothesis that the regression term is non-zero. |
std.error |
The standard error of the regression term. |
term |
The name of the regression term. |
Other felm tidiers:
augment.felm()
# load libraries for models and data library(lfe) # use built-in `airquality` dataset head(airquality) # no FEs; same as lm() est0 <- felm(Ozone ~ Temp + Wind + Solar.R, airquality) # summarize model fit with tidiers tidy(est0) augment(est0) # add month fixed effects est1 <- felm(Ozone ~ Temp + Wind + Solar.R | Month, airquality) # summarize model fit with tidiers tidy(est1) tidy(est1, fe = TRUE) augment(est1) glance(est1) # the "se.type" argument can be used to switch out different standard errors # types on the fly. In turn, this can be useful exploring the effect of # different error structures on model inference. tidy(est1, se.type = "iid") tidy(est1, se.type = "robust") # add clustered SEs (also by month) est2 <- felm(Ozone ~ Temp + Wind + Solar.R | Month | 0 | Month, airquality) # summarize model fit with tidiers tidy(est2, conf.int = TRUE) tidy(est2, conf.int = TRUE, se.type = "cluster") tidy(est2, conf.int = TRUE, se.type = "robust") tidy(est2, conf.int = TRUE, se.type = "iid")
# load libraries for models and data library(lfe) # use built-in `airquality` dataset head(airquality) # no FEs; same as lm() est0 <- felm(Ozone ~ Temp + Wind + Solar.R, airquality) # summarize model fit with tidiers tidy(est0) augment(est0) # add month fixed effects est1 <- felm(Ozone ~ Temp + Wind + Solar.R | Month, airquality) # summarize model fit with tidiers tidy(est1) tidy(est1, fe = TRUE) augment(est1) glance(est1) # the "se.type" argument can be used to switch out different standard errors # types on the fly. In turn, this can be useful exploring the effect of # different error structures on model inference. tidy(est1, se.type = "iid") tidy(est1, se.type = "robust") # add clustered SEs (also by month) est2 <- felm(Ozone ~ Temp + Wind + Solar.R | Month | 0 | Month, airquality) # summarize model fit with tidiers tidy(est2, conf.int = TRUE) tidy(est2, conf.int = TRUE, se.type = "cluster") tidy(est2, conf.int = TRUE, se.type = "robust") tidy(est2, conf.int = TRUE, se.type = "iid")
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'fitdistr' tidy(x, ...)
## S3 method for class 'fitdistr' tidy(x, ...)
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with columns:
estimate |
The estimated value of the regression term. |
std.error |
The standard error of the regression term. |
term |
The name of the regression term. |
Other fitdistr tidiers:
glance.fitdistr()
# load libraries for models and data library(MASS) # generate data set.seed(2015) x <- rnorm(100, 5, 2) # fit models fit <- fitdistr(x, dnorm, list(mean = 3, sd = 1)) # summarize model fit with tidiers tidy(fit) glance(fit)
# load libraries for models and data library(MASS) # generate data set.seed(2015) x <- rnorm(100, 5, 2) # fit models fit <- fitdistr(x, dnorm, list(mean = 3, sd = 1)) # summarize model fit with tidiers tidy(fit) glance(fit)
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'fixest' tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
## S3 method for class 'fixest' tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
x |
A |
conf.int |
Logical indicating whether or not to include a confidence
interval in the tidied output. Defaults to |
conf.level |
The confidence level to use for the confidence interval
if |
... |
Additional arguments passed to |
The fixest
package provides a family of functions for estimating
models with arbitrary numbers of fixed-effects, in both an OLS and a GLM
context. The package also supports robust (i.e. White) and clustered
standard error reporting via the generic summary.fixest()
command. In a
similar vein, the tidy()
method for these models allows users to specify
a desired standard error correction either 1) implicitly via the supplied
fixest object, or 2) explicitly as part of the tidy call. See examples
below.
Note that fixest confidence intervals are calculated assuming a normal distribution – this assumes infinite degrees of freedom for the CI. (This assumption is distinct from the degrees of freedom used to calculate the standard errors. For more on degrees of freedom with clusters and fixed effects, see https://github.com/lrberge/fixest/issues/6 and https://github.com/sgaure/lfe/issues/1#issuecomment-530646990)
A tibble::tibble()
with columns:
conf.high |
Upper bound on the confidence interval for the estimate. |
conf.low |
Lower bound on the confidence interval for the estimate. |
estimate |
The estimated value of the regression term. |
p.value |
The two-sided p-value associated with the observed statistic. |
statistic |
The value of a T-statistic to use in a hypothesis that the regression term is non-zero. |
std.error |
The standard error of the regression term. |
term |
The name of the regression term. |
tidy()
, fixest::feglm()
, fixest::fenegbin()
,
fixest::feNmlm()
, fixest::femlm()
, fixest::feols()
, fixest::fepois()
Other fixest tidiers:
augment.fixest()
# load libraries for models and data library(fixest) gravity <- feols( log(Euros) ~ log(dist_km) | Origin + Destination + Product + Year, trade ) tidy(gravity) glance(gravity) augment(gravity, trade) # to get robust or clustered SEs, users can either: # 1) specify the arguments directly in the `tidy()` call tidy(gravity, conf.int = TRUE, cluster = c("Product", "Year")) tidy(gravity, conf.int = TRUE, se = "threeway") # 2) or, feed tidy() a summary.fixest object that has already accepted # these arguments gravity_summ <- summary(gravity, cluster = c("Product", "Year")) tidy(gravity_summ, conf.int = TRUE) # approach (1) is preferred.
# load libraries for models and data library(fixest) gravity <- feols( log(Euros) ~ log(dist_km) | Origin + Destination + Product + Year, trade ) tidy(gravity) glance(gravity) augment(gravity, trade) # to get robust or clustered SEs, users can either: # 1) specify the arguments directly in the `tidy()` call tidy(gravity, conf.int = TRUE, cluster = c("Product", "Year")) tidy(gravity, conf.int = TRUE, se = "threeway") # 2) or, feed tidy() a summary.fixest object that has already accepted # these arguments gravity_summ <- summary(gravity, cluster = c("Product", "Year")) tidy(gravity_summ, conf.int = TRUE) # approach (1) is preferred.
This function is deprecated. Please use tibble::as_tibble()
instead.
## S3 method for class 'ftable' tidy(x, ...)
## S3 method for class 'ftable' tidy(x, ...)
x |
An |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
An ftable contains a "flat" contingency table. This melts it into a
tibble::tibble with one column for each variable, then a Freq
column.
Other deprecated:
bootstrap()
,
confint_tidy()
,
data.frame_tidiers
,
finish_glance()
,
fix_data_frame()
,
summary_tidiers
,
tidy.density()
,
tidy.dist()
,
tidy.numeric()
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'gam' tidy( x, parametric = FALSE, conf.int = FALSE, conf.level = 0.95, exponentiate = FALSE, ... )
## S3 method for class 'gam' tidy( x, parametric = FALSE, conf.int = FALSE, conf.level = 0.95, exponentiate = FALSE, ... )
x |
A |
parametric |
Logical indicating if parametric or smooth terms should
be tidied. Defaults to |
conf.int |
Logical indicating whether or not to include a confidence
interval in the tidied output. Defaults to |
conf.level |
The confidence level to use for the confidence interval
if |
exponentiate |
Logical indicating whether or not to exponentiate the
the coefficient estimates. This is typical for logistic and multinomial
regressions, but a bad idea if there is no log or logit link. Defaults
to |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
When parametric = FALSE
return columns edf
and ref.df
rather
than estimate
and std.error
.
A tibble::tibble()
with columns:
estimate |
The estimated value of the regression term. |
p.value |
The two-sided p-value associated with the observed statistic. |
statistic |
The value of a T-statistic to use in a hypothesis that the regression term is non-zero. |
std.error |
The standard error of the regression term. |
term |
The name of the regression term. |
edf |
The effective degrees of freedom. Only reported when 'parametric = FALSE' |
ref.df |
The reference degrees of freedom. Only reported when 'parametric = FALSE' |
Other mgcv tidiers:
glance.gam()
# load libraries for models and data library(mgcv) # fit model g <- gam(mpg ~ s(hp) + am + qsec, data = mtcars) # summarize model fit with tidiers tidy(g) tidy(g, parametric = TRUE) glance(g) augment(g)
# load libraries for models and data library(mgcv) # fit model g <- gam(mpg ~ s(hp) + am + qsec, data = mtcars) # summarize model fit with tidiers tidy(g) tidy(g, parametric = TRUE) glance(g) augment(g)
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'Gam' tidy(x, ...)
## S3 method for class 'Gam' tidy(x, ...)
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Tidy gam
objects created by calls to mgcv::gam()
with
tidy.gam()
.
A tibble::tibble()
with columns:
df |
Degrees of freedom used by this term in the model. |
meansq |
Mean sum of squares. Equal to total sum of squares divided by degrees of freedom. |
p.value |
The two-sided p-value associated with the observed statistic. |
statistic |
The value of a T-statistic to use in a hypothesis that the regression term is non-zero. |
sumsq |
Sum of squares explained by this term. |
term |
The name of the regression term. |
tidy()
, gam::gam()
, tidy.anova()
, tidy.gam()
Other gam tidiers:
glance.Gam()
# load libraries for models and data library(gam) # fit model g <- gam(mpg ~ s(hp, 4) + am + qsec, data = mtcars) # summarize model fit with tidiers tidy(g) glance(g)
# load libraries for models and data library(gam) # fit model g <- gam(mpg ~ s(hp, 4) + am + qsec, data = mtcars) # summarize model fit with tidiers tidy(g) glance(g)
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'garch' tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
## S3 method for class 'garch' tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
x |
A |
conf.int |
Logical indicating whether or not to include a confidence
interval in the tidied output. Defaults to |
conf.level |
The confidence level to use for the confidence interval
if |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with columns:
conf.high |
Upper bound on the confidence interval for the estimate. |
conf.low |
Lower bound on the confidence interval for the estimate. |
estimate |
The estimated value of the regression term. |
p.value |
The two-sided p-value associated with the observed statistic. |
statistic |
The value of a T-statistic to use in a hypothesis that the regression term is non-zero. |
std.error |
The standard error of the regression term. |
term |
The name of the regression term. |
Other garch tidiers:
glance.garch()
# load libraries for models and data library(tseries) # load data data(EuStockMarkets) # fit model dax <- diff(log(EuStockMarkets))[, "DAX"] dax.garch <- garch(dax) dax.garch # summarize model fit with tidiers tidy(dax.garch) glance(dax.garch)
# load libraries for models and data library(tseries) # load data data(EuStockMarkets) # fit model dax <- diff(log(EuStockMarkets))[, "DAX"] dax.garch <- garch(dax) dax.garch # summarize model fit with tidiers tidy(dax.garch) glance(dax.garch)
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'geeglm' tidy(x, conf.int = FALSE, conf.level = 0.95, exponentiate = FALSE, ...)
## S3 method for class 'geeglm' tidy(x, conf.int = FALSE, conf.level = 0.95, exponentiate = FALSE, ...)
x |
A |
conf.int |
Logical indicating whether or not to include a confidence
interval in the tidied output. Defaults to |
conf.level |
The confidence level to use for the confidence interval
if |
exponentiate |
Logical indicating whether or not to exponentiate the
the coefficient estimates. This is typical for logistic and multinomial
regressions, but a bad idea if there is no log or logit link. Defaults
to |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
If conf.int = TRUE
, the confidence interval is computed with
the an internal confint.geeglm()
function.
If you have missing values in your model data, you may need to
refit the model with na.action = na.exclude
or deal with the
missingness in the data beforehand.
A tibble::tibble()
with columns:
conf.high |
Upper bound on the confidence interval for the estimate. |
conf.low |
Lower bound on the confidence interval for the estimate. |
estimate |
The estimated value of the regression term. |
p.value |
The two-sided p-value associated with the observed statistic. |
statistic |
The value of a T-statistic to use in a hypothesis that the regression term is non-zero. |
std.error |
The standard error of the regression term. |
term |
The name of the regression term. |
# load modeling library library(geepack) # load data data(state) ds <- data.frame(state.region, state.x77) # fit model geefit <- geeglm(Income ~ Frost + Murder, id = state.region, data = ds, corstr = "exchangeable" ) # summarize model fit with tidiers tidy(geefit) tidy(geefit, conf.int = TRUE)
# load modeling library library(geepack) # load data data(state) ds <- data.frame(state.region, state.x77) # fit model geefit <- geeglm(Income ~ Frost + Murder, id = state.region, data = ds, corstr = "exchangeable" ) # summarize model fit with tidiers tidy(geefit) tidy(geefit, conf.int = TRUE)
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'glht' tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
## S3 method for class 'glht' tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
x |
A |
conf.int |
Logical indicating whether or not to include a confidence
interval in the tidied output. Defaults to |
conf.level |
The confidence level to use for the confidence interval
if |
... |
Additional arguments passed to |
A tibble::tibble()
with columns:
contrast |
Levels being compared. |
estimate |
The estimated value of the regression term. |
null.value |
Value to which the estimate is compared. |
Other multcomp tidiers:
tidy.cld()
,
tidy.confint.glht()
,
tidy.summary.glht()
# load libraries for models and data library(multcomp) library(ggplot2) amod <- aov(breaks ~ wool + tension, data = warpbreaks) wht <- glht(amod, linfct = mcp(tension = "Tukey")) tidy(wht) ggplot(wht, aes(lhs, estimate)) + geom_point() CI <- confint(wht) tidy(CI) ggplot(CI, aes(lhs, estimate, ymin = lwr, ymax = upr)) + geom_pointrange() tidy(summary(wht)) ggplot(mapping = aes(lhs, estimate)) + geom_linerange(aes(ymin = lwr, ymax = upr), data = CI) + geom_point(aes(size = p), data = summary(wht)) + scale_size(trans = "reverse") cld <- cld(wht) tidy(cld)
# load libraries for models and data library(multcomp) library(ggplot2) amod <- aov(breaks ~ wool + tension, data = warpbreaks) wht <- glht(amod, linfct = mcp(tension = "Tukey")) tidy(wht) ggplot(wht, aes(lhs, estimate)) + geom_point() CI <- confint(wht) tidy(CI) ggplot(CI, aes(lhs, estimate, ymin = lwr, ymax = upr)) + geom_pointrange() tidy(summary(wht)) ggplot(mapping = aes(lhs, estimate)) + geom_linerange(aes(ymin = lwr, ymax = upr), data = CI) + geom_point(aes(size = p), data = summary(wht)) + scale_size(trans = "reverse") cld <- cld(wht) tidy(cld)
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'glm' tidy(x, conf.int = FALSE, conf.level = 0.95, exponentiate = FALSE, ...)
## S3 method for class 'glm' tidy(x, conf.int = FALSE, conf.level = 0.95, exponentiate = FALSE, ...)
x |
A |
conf.int |
Logical indicating whether or not to include a confidence
interval in the tidied output. Defaults to |
conf.level |
The confidence level to use for the confidence interval
if |
exponentiate |
Logical indicating whether or not to exponentiate the
the coefficient estimates. This is typical for logistic and multinomial
regressions, but a bad idea if there is no log or logit link. Defaults
to |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Other lm tidiers:
augment.glm()
,
augment.lm()
,
glance.glm()
,
glance.lm()
,
glance.summary.lm()
,
glance.svyglm()
,
tidy.lm()
,
tidy.lm.beta()
,
tidy.mlm()
,
tidy.summary.lm()
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'glmnet' tidy(x, return_zeros = FALSE, ...)
## S3 method for class 'glmnet' tidy(x, return_zeros = FALSE, ...)
x |
A |
return_zeros |
Logical indicating whether coefficients with value zero
zero should be included in the results. Defaults to |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Note that while this representation of GLMs is much easier to plot and combine than the default structure, it is also much more memory-intensive. Do not use for large, sparse matrices.
No augment
method is yet provided even though the model produces
predictions, because the input data is not tidy (it is a matrix that
may be very wide) and therefore combining predictions with it is not
logical. Furthermore, predictions make sense only with a specific
choice of lambda.
A tibble::tibble()
with columns:
dev.ratio |
Fraction of null deviance explained at each value of lambda. |
estimate |
The estimated value of the regression term. |
lambda |
Value of penalty parameter lambda. |
step |
Which step of lambda choices was used. |
term |
The name of the regression term. |
Other glmnet tidiers:
glance.cv.glmnet()
,
glance.glmnet()
,
tidy.cv.glmnet()
# load libraries for models and data library(glmnet) set.seed(2014) x <- matrix(rnorm(100 * 20), 100, 20) y <- rnorm(100) fit1 <- glmnet(x, y) # summarize model fit with tidiers + visualization tidy(fit1) glance(fit1) library(dplyr) library(ggplot2) tidied <- tidy(fit1) %>% filter(term != "(Intercept)") ggplot(tidied, aes(step, estimate, group = term)) + geom_line() ggplot(tidied, aes(lambda, estimate, group = term)) + geom_line() + scale_x_log10() ggplot(tidied, aes(lambda, dev.ratio)) + geom_line() # works for other types of regressions as well, such as logistic g2 <- sample(1:2, 100, replace = TRUE) fit2 <- glmnet(x, g2, family = "binomial") tidy(fit2)
# load libraries for models and data library(glmnet) set.seed(2014) x <- matrix(rnorm(100 * 20), 100, 20) y <- rnorm(100) fit1 <- glmnet(x, y) # summarize model fit with tidiers + visualization tidy(fit1) glance(fit1) library(dplyr) library(ggplot2) tidied <- tidy(fit1) %>% filter(term != "(Intercept)") ggplot(tidied, aes(step, estimate, group = term)) + geom_line() ggplot(tidied, aes(lambda, estimate, group = term)) + geom_line() + scale_x_log10() ggplot(tidied, aes(lambda, dev.ratio)) + geom_line() # works for other types of regressions as well, such as logistic g2 <- sample(1:2, 100, replace = TRUE) fit2 <- glmnet(x, g2, family = "binomial") tidy(fit2)
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'glmrob' tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
## S3 method for class 'glmrob' tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
x |
A |
conf.int |
Logical indicating whether or not to include a confidence
interval in the tidied output. Defaults to |
conf.level |
The confidence level to use for the confidence interval
if |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
For tidiers for robust models from the MASS package see
tidy.rlm()
.
A tibble::tibble()
with columns:
conf.high |
Upper bound on the confidence interval for the estimate. |
conf.low |
Lower bound on the confidence interval for the estimate. |
estimate |
The estimated value of the regression term. |
p.value |
The two-sided p-value associated with the observed statistic. |
statistic |
The value of a T-statistic to use in a hypothesis that the regression term is non-zero. |
std.error |
The standard error of the regression term. |
term |
The name of the regression term. |
Other robustbase tidiers:
augment.glmrob()
,
augment.lmrob()
,
glance.lmrob()
,
tidy.lmrob()
if (requireNamespace("robustbase", quietly = TRUE)) { # load libraries for models and data library(robustbase) data(coleman) set.seed(0) m <- lmrob(Y ~ ., data = coleman) tidy(m) augment(m) glance(m) data(carrots) Rfit <- glmrob(cbind(success, total - success) ~ logdose + block, family = binomial, data = carrots, method = "Mqle", control = glmrobMqle.control(tcc = 1.2) ) tidy(Rfit) augment(Rfit) }
if (requireNamespace("robustbase", quietly = TRUE)) { # load libraries for models and data library(robustbase) data(coleman) set.seed(0) m <- lmrob(Y ~ ., data = coleman) tidy(m) augment(m) glance(m) data(carrots) Rfit <- glmrob(cbind(success, total - success) ~ logdose + block, family = binomial, data = carrots, method = "Mqle", control = glmrobMqle.control(tcc = 1.2) ) tidy(Rfit) augment(Rfit) }
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'glmRob' tidy(x, ...)
## S3 method for class 'glmRob' tidy(x, ...)
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
For tidiers for robust models from the MASS package see
tidy.rlm()
.
Other robust tidiers:
augment.lmRob()
,
glance.glmRob()
,
glance.lmRob()
,
tidy.lmRob()
# load libraries for models and data library(robust) # fit model gm <- glmRob(am ~ wt, data = mtcars, family = "binomial") # summarize model fit with tidiers tidy(gm) glance(gm)
# load libraries for models and data library(robust) # fit model gm <- glmRob(am ~ wt, data = mtcars, family = "binomial") # summarize model fit with tidiers tidy(gm) glance(gm)
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'gmm' tidy(x, conf.int = FALSE, conf.level = 0.95, exponentiate = FALSE, ...)
## S3 method for class 'gmm' tidy(x, conf.int = FALSE, conf.level = 0.95, exponentiate = FALSE, ...)
x |
A |
conf.int |
Logical indicating whether or not to include a confidence
interval in the tidied output. Defaults to |
conf.level |
The confidence level to use for the confidence interval
if |
exponentiate |
Logical indicating whether or not to exponentiate the
the coefficient estimates. This is typical for logistic and multinomial
regressions, but a bad idea if there is no log or logit link. Defaults
to |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with columns:
conf.high |
Upper bound on the confidence interval for the estimate. |
conf.low |
Lower bound on the confidence interval for the estimate. |
estimate |
The estimated value of the regression term. |
p.value |
The two-sided p-value associated with the observed statistic. |
statistic |
The value of a T-statistic to use in a hypothesis that the regression term is non-zero. |
std.error |
The standard error of the regression term. |
term |
The name of the regression term. |
Other gmm tidiers:
glance.gmm()
# load libraries for models and data library(gmm) # examples come from the "gmm" package # CAPM test with GMM data(Finance) r <- Finance[1:300, 1:10] rm <- Finance[1:300, "rm"] rf <- Finance[1:300, "rf"] z <- as.matrix(r - rf) t <- nrow(z) zm <- rm - rf h <- matrix(zm, t, 1) res <- gmm(z ~ zm, x = h) # tidy result tidy(res) tidy(res, conf.int = TRUE) tidy(res, conf.int = TRUE, conf.level = .99) # coefficient plot library(ggplot2) library(dplyr) tidy(res, conf.int = TRUE) %>% mutate(variable = reorder(term, estimate)) %>% ggplot(aes(estimate, variable)) + geom_point() + geom_errorbarh(aes(xmin = conf.low, xmax = conf.high)) + geom_vline(xintercept = 0, color = "red", lty = 2) # from a function instead of a matrix g <- function(theta, x) { e <- x[, 2:11] - theta[1] - (x[, 1] - theta[1]) %*% matrix(theta[2:11], 1, 10) gmat <- cbind(e, e * c(x[, 1])) return(gmat) } x <- as.matrix(cbind(rm, r)) res_black <- gmm(g, x = x, t0 = rep(0, 11)) tidy(res_black) tidy(res_black, conf.int = TRUE) # APT test with Fama-French factors and GMM f1 <- zm f2 <- Finance[1:300, "hml"] - rf f3 <- Finance[1:300, "smb"] - rf h <- cbind(f1, f2, f3) res2 <- gmm(z ~ f1 + f2 + f3, x = h) td2 <- tidy(res2, conf.int = TRUE) td2 # coefficient plot td2 %>% mutate(variable = reorder(term, estimate)) %>% ggplot(aes(estimate, variable)) + geom_point() + geom_errorbarh(aes(xmin = conf.low, xmax = conf.high)) + geom_vline(xintercept = 0, color = "red", lty = 2)
# load libraries for models and data library(gmm) # examples come from the "gmm" package # CAPM test with GMM data(Finance) r <- Finance[1:300, 1:10] rm <- Finance[1:300, "rm"] rf <- Finance[1:300, "rf"] z <- as.matrix(r - rf) t <- nrow(z) zm <- rm - rf h <- matrix(zm, t, 1) res <- gmm(z ~ zm, x = h) # tidy result tidy(res) tidy(res, conf.int = TRUE) tidy(res, conf.int = TRUE, conf.level = .99) # coefficient plot library(ggplot2) library(dplyr) tidy(res, conf.int = TRUE) %>% mutate(variable = reorder(term, estimate)) %>% ggplot(aes(estimate, variable)) + geom_point() + geom_errorbarh(aes(xmin = conf.low, xmax = conf.high)) + geom_vline(xintercept = 0, color = "red", lty = 2) # from a function instead of a matrix g <- function(theta, x) { e <- x[, 2:11] - theta[1] - (x[, 1] - theta[1]) %*% matrix(theta[2:11], 1, 10) gmat <- cbind(e, e * c(x[, 1])) return(gmat) } x <- as.matrix(cbind(rm, r)) res_black <- gmm(g, x = x, t0 = rep(0, 11)) tidy(res_black) tidy(res_black, conf.int = TRUE) # APT test with Fama-French factors and GMM f1 <- zm f2 <- Finance[1:300, "hml"] - rf f3 <- Finance[1:300, "smb"] - rf h <- cbind(f1, f2, f3) res2 <- gmm(z ~ f1 + f2 + f3, x = h) td2 <- tidy(res2, conf.int = TRUE) td2 # coefficient plot td2 %>% mutate(variable = reorder(term, estimate)) %>% ggplot(aes(estimate, variable)) + geom_point() + geom_errorbarh(aes(xmin = conf.low, xmax = conf.high)) + geom_vline(xintercept = 0, color = "red", lty = 2)
For models that have only a single component, the tidy()
and
glance()
methods are identical. Please see the documentation for both
of those methods.
## S3 method for class 'htest' tidy(x, ...) ## S3 method for class 'htest' glance(x, ...)
## S3 method for class 'htest' tidy(x, ...) ## S3 method for class 'htest' glance(x, ...)
x |
An |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with columns:
alternative |
Alternative hypothesis (character). |
conf.high |
Upper bound on the confidence interval for the estimate. |
conf.low |
Lower bound on the confidence interval for the estimate. |
estimate |
The estimated value of the regression term. |
estimate1 |
Sometimes two estimates are computed, such as in a two-sample t-test. |
estimate2 |
Sometimes two estimates are computed, such as in a two-sample t-test. |
method |
Method used. |
p.value |
The two-sided p-value associated with the observed statistic. |
parameter |
The parameter being modeled. |
statistic |
The value of a T-statistic to use in a hypothesis that the regression term is non-zero. |
tidy()
, stats::cor.test()
, stats::t.test()
,
stats::wilcox.test()
, stats::chisq.test()
Other htest tidiers:
augment.htest()
,
tidy.pairwise.htest()
,
tidy.power.htest()
tt <- t.test(rnorm(10)) tidy(tt) # the glance output will be the same for each of the below tests glance(tt) tt <- t.test(mpg ~ am, data = mtcars) tidy(tt) wt <- wilcox.test(mpg ~ am, data = mtcars, conf.int = TRUE, exact = FALSE) tidy(wt) ct <- cor.test(mtcars$wt, mtcars$mpg) tidy(ct) chit <- chisq.test(xtabs(Freq ~ Sex + Class, data = as.data.frame(Titanic))) tidy(chit) augment(chit)
tt <- t.test(rnorm(10)) tidy(tt) # the glance output will be the same for each of the below tests glance(tt) tt <- t.test(mpg ~ am, data = mtcars) tidy(tt) wt <- wilcox.test(mpg ~ am, data = mtcars, conf.int = TRUE, exact = FALSE) tidy(wt) ct <- cor.test(mtcars$wt, mtcars$mpg) tidy(ct) chit <- chisq.test(xtabs(Freq ~ Sex + Class, data = as.data.frame(Titanic))) tidy(chit) augment(chit)
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'ivreg' tidy(x, conf.int = FALSE, conf.level = 0.95, instruments = FALSE, ...)
## S3 method for class 'ivreg' tidy(x, conf.int = FALSE, conf.level = 0.95, instruments = FALSE, ...)
x |
An |
conf.int |
Logical indicating whether or not to include a confidence
interval in the tidied output. Defaults to |
conf.level |
The confidence level to use for the confidence interval
if |
instruments |
Logical indicating whether to return
coefficients from the second-stage or diagnostics tests for
each endogenous regressor (F-statistics). Defaults to |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
This tidier currently only supports ivreg
-classed objects
outputted by the AER
package. The ivreg
package also outputs
objects of class ivreg
, and will be supported in a later release.
A tibble::tibble()
with columns:
conf.high |
Upper bound on the confidence interval for the estimate. |
conf.low |
Lower bound on the confidence interval for the estimate. |
estimate |
The estimated value of the regression term. |
p.value |
The two-sided p-value associated with the observed statistic. |
p.value.Sargan |
p-value for Sargan test of overidentifying restrictions. |
p.value.weakinst |
p-value for weak instruments test. |
p.value.Wu.Hausman |
p-value for Wu-Hausman weak instruments test for endogeneity. |
statistic |
The value of a T-statistic to use in a hypothesis that the regression term is non-zero. |
statistic.Sargan |
Statistic for Sargan test of overidentifying restrictions. |
statistic.weakinst |
Statistic for Wu-Hausman test. |
statistic.Wu.Hausman |
Statistic for Wu-Hausman weak instruments test for endogeneity. |
std.error |
The standard error of the regression term. |
term |
The name of the regression term. |
Other ivreg tidiers:
augment.ivreg()
,
glance.ivreg()
# load libraries for models and data library(AER) # load data data("CigarettesSW", package = "AER") # fit model ivr <- ivreg( log(packs) ~ income | population, data = CigarettesSW, subset = year == "1995" ) # summarize model fit with tidiers tidy(ivr) tidy(ivr, conf.int = TRUE) tidy(ivr, conf.int = TRUE, instruments = TRUE) augment(ivr) augment(ivr, data = CigarettesSW) augment(ivr, newdata = CigarettesSW) glance(ivr)
# load libraries for models and data library(AER) # load data data("CigarettesSW", package = "AER") # fit model ivr <- ivreg( log(packs) ~ income | population, data = CigarettesSW, subset = year == "1995" ) # summarize model fit with tidiers tidy(ivr) tidy(ivr, conf.int = TRUE) tidy(ivr, conf.int = TRUE, instruments = TRUE) augment(ivr) augment(ivr, data = CigarettesSW) augment(ivr, newdata = CigarettesSW) glance(ivr)
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'kappa' tidy(x, ...)
## S3 method for class 'kappa' tidy(x, ...)
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Note that confidence level (alpha) for the confidence interval
cannot be set in tidy
. Instead you must set the alpha
argument
to psych::cohen.kappa()
when creating the kappa
object.
A tibble::tibble()
with columns:
conf.high |
Upper bound on the confidence interval for the estimate. |
conf.low |
Lower bound on the confidence interval for the estimate. |
estimate |
The estimated value of the regression term. |
type |
Either 'weighted' or 'unweighted'. |
# load libraries for models and data library(psych) # generate example data rater1 <- 1:9 rater2 <- c(1, 3, 1, 6, 1, 5, 5, 6, 7) # fit model ck <- cohen.kappa(cbind(rater1, rater2)) # summarize model fit with tidiers + visualization tidy(ck) # graph the confidence intervals library(ggplot2) ggplot(tidy(ck), aes(estimate, type)) + geom_point() + geom_errorbarh(aes(xmin = conf.low, xmax = conf.high))
# load libraries for models and data library(psych) # generate example data rater1 <- 1:9 rater2 <- c(1, 3, 1, 6, 1, 5, 5, 6, 7) # fit model ck <- cohen.kappa(cbind(rater1, rater2)) # summarize model fit with tidiers + visualization tidy(ck) # graph the confidence intervals library(ggplot2) ggplot(tidy(ck), aes(estimate, type)) + geom_point() + geom_errorbarh(aes(xmin = conf.low, xmax = conf.high))
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'kde' tidy(x, ...)
## S3 method for class 'kde' tidy(x, ...)
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Returns a data frame in long format with four columns. Use
tidyr::pivot_wider(..., names_from = variable, values_from = value)
on the output to return to a wide format.
A tibble::tibble()
with columns:
estimate |
The estimated value of the regression term. |
obs |
weighted observed number of events in each group. |
value |
The value/estimate of the component. Results from data reshaping. |
variable |
Variable under consideration. |
# load libraries for models and data library(ks) # generate data dat <- replicate(2, rnorm(100)) k <- kde(dat) # summarize model fit with tidiers + visualization td <- tidy(k) td library(ggplot2) library(dplyr) library(tidyr) td %>% pivot_wider(c(obs, estimate), names_from = variable, values_from = value ) %>% ggplot(aes(x1, x2, fill = estimate)) + geom_tile() + theme_void() # also works with 3 dimensions dat3 <- replicate(3, rnorm(100)) k3 <- kde(dat3) td3 <- tidy(k3) td3
# load libraries for models and data library(ks) # generate data dat <- replicate(2, rnorm(100)) k <- kde(dat) # summarize model fit with tidiers + visualization td <- tidy(k) td library(ggplot2) library(dplyr) library(tidyr) td %>% pivot_wider(c(obs, estimate), names_from = variable, values_from = value ) %>% ggplot(aes(x1, x2, fill = estimate)) + geom_tile() + theme_void() # also works with 3 dimensions dat3 <- replicate(3, rnorm(100)) k3 <- kde(dat3) td3 <- tidy(k3) td3
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'Kendall' tidy(x, ...)
## S3 method for class 'Kendall' tidy(x, ...)
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with columns:
kendall_score |
Kendall score. |
p.value |
The two-sided p-value associated with the observed statistic. |
var_kendall_score |
Variance of the kendall_score. |
statistic |
Kendall's tau statistic |
denominator |
The denominator, which is tau=kendall_score/denominator. |
tidy()
, Kendall::Kendall()
, Kendall::MannKendall()
,
Kendall::SeasonalMannKendall()
# load libraries for models and data library(Kendall) A <- c(2.5, 2.5, 2.5, 2.5, 5, 6.5, 6.5, 10, 10, 10, 10, 10, 14, 14, 14, 16, 17) B <- c(1, 1, 1, 1, 2, 1, 1, 2, 1, 1, 1, 1, 1, 1, 2, 2, 2) # fit models and summarize results f_res <- Kendall(A, B) tidy(f_res) s_res <- MannKendall(B) tidy(s_res) t_res <- SeasonalMannKendall(ts(A)) tidy(t_res)
# load libraries for models and data library(Kendall) A <- c(2.5, 2.5, 2.5, 2.5, 5, 6.5, 6.5, 10, 10, 10, 10, 10, 14, 14, 14, 16, 17) B <- c(1, 1, 1, 1, 2, 1, 1, 2, 1, 1, 1, 1, 1, 1, 2, 2, 2) # fit models and summarize results f_res <- Kendall(A, B) tidy(f_res) s_res <- MannKendall(B) tidy(s_res) t_res <- SeasonalMannKendall(ts(A)) tidy(t_res)
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'kmeans' tidy(x, col.names = colnames(x$centers), ...)
## S3 method for class 'kmeans' tidy(x, col.names = colnames(x$centers), ...)
x |
A |
col.names |
Dimension names. Defaults to the names of the variables
in x. Set to NULL to get names |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with columns:
cluster |
A factor describing the cluster from 1:k. |
size |
Number of points assigned to cluster. |
withinss |
The within-cluster sum of squares. |
Other kmeans tidiers:
augment.kmeans()
,
glance.kmeans()
library(cluster) library(modeldata) library(dplyr) data(hpc_data) x <- hpc_data[, 2:5] fit <- pam(x, k = 4) tidy(fit) glance(fit) augment(fit, x)
library(cluster) library(modeldata) library(dplyr) data(hpc_data) x <- hpc_data[, 2:5] fit <- pam(x, k = 4) tidy(fit) glance(fit) augment(fit, x)
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'lavaan' tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
## S3 method for class 'lavaan' tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
x |
A |
conf.int |
Logical indicating whether or not to include a confidence
interval in the tidied output. Defaults to |
conf.level |
The confidence level to use for the confidence interval
if |
... |
Additional arguments passed to |
A tibble::tibble()
with one row for each estimated parameter and
columns:
term |
The result of paste(lhs, op, rhs) |
op |
The operator in the model syntax (e.g. |
group |
The group (if specified) in the lavaan model |
estimate |
The parameter estimate (may be standardized) |
std.error |
|
statistic |
The z value returned by |
p.value |
|
conf.low |
|
conf.high |
|
std.lv |
Standardized estimates based on the variances of the (continuous) latent variables only |
std.all |
Standardized estimates based on both the variances of both (continuous) observed and latent variables. |
std.nox |
Standardized estimates based on both the variances of both (continuous) observed and latent variables, but not the variances of exogenous covariates. |
tidy()
, lavaan::cfa()
, lavaan::sem()
,
lavaan::parameterEstimates()
Other lavaan tidiers:
glance.lavaan()
# load libraries for models and data library(lavaan) cfa.fit <- cfa("F =~ x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9", data = HolzingerSwineford1939, group = "school" ) tidy(cfa.fit)
# load libraries for models and data library(lavaan) cfa.fit <- cfa("F =~ x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9", data = HolzingerSwineford1939, group = "school" ) tidy(cfa.fit)
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'lm' tidy(x, conf.int = FALSE, conf.level = 0.95, exponentiate = FALSE, ...)
## S3 method for class 'lm' tidy(x, conf.int = FALSE, conf.level = 0.95, exponentiate = FALSE, ...)
x |
An |
conf.int |
Logical indicating whether or not to include a confidence
interval in the tidied output. Defaults to |
conf.level |
The confidence level to use for the confidence interval
if |
exponentiate |
Logical indicating whether or not to exponentiate the
the coefficient estimates. This is typical for logistic and multinomial
regressions, but a bad idea if there is no log or logit link. Defaults
to |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
If the linear model is an mlm
object (multiple linear model),
there is an additional column response
. See tidy.mlm()
.
A tibble::tibble()
with columns:
conf.high |
Upper bound on the confidence interval for the estimate. |
conf.low |
Lower bound on the confidence interval for the estimate. |
estimate |
The estimated value of the regression term. |
p.value |
The two-sided p-value associated with the observed statistic. |
statistic |
The value of a T-statistic to use in a hypothesis that the regression term is non-zero. |
std.error |
The standard error of the regression term. |
term |
The name of the regression term. |
Other lm tidiers:
augment.glm()
,
augment.lm()
,
glance.glm()
,
glance.lm()
,
glance.summary.lm()
,
glance.svyglm()
,
tidy.glm()
,
tidy.lm.beta()
,
tidy.mlm()
,
tidy.summary.lm()
library(ggplot2) library(dplyr) mod <- lm(mpg ~ wt + qsec, data = mtcars) tidy(mod) glance(mod) # coefficient plot d <- tidy(mod, conf.int = TRUE) ggplot(d, aes(estimate, term, xmin = conf.low, xmax = conf.high, height = 0)) + geom_point() + geom_vline(xintercept = 0, lty = 4) + geom_errorbarh() # aside: There are tidy() and glance() methods for lm.summary objects too. # this can be useful when you want to conserve memory by converting large lm # objects into their leaner summary.lm equivalents. s <- summary(mod) tidy(s, conf.int = TRUE) glance(s) augment(mod) augment(mod, mtcars, interval = "confidence") # predict on new data newdata <- mtcars %>% head(6) %>% mutate(wt = wt + 1) augment(mod, newdata = newdata) # ggplot2 example where we also construct 95% prediction interval # simpler bivariate model since we're plotting in 2D mod2 <- lm(mpg ~ wt, data = mtcars) au <- augment(mod2, newdata = newdata, interval = "prediction") ggplot(au, aes(wt, mpg)) + geom_point() + geom_line(aes(y = .fitted)) + geom_ribbon(aes(ymin = .lower, ymax = .upper), col = NA, alpha = 0.3) # predict on new data without outcome variable. Output does not include .resid newdata <- newdata %>% select(-mpg) augment(mod, newdata = newdata) au <- augment(mod, data = mtcars) ggplot(au, aes(.hat, .std.resid)) + geom_vline(size = 2, colour = "white", xintercept = 0) + geom_hline(size = 2, colour = "white", yintercept = 0) + geom_point() + geom_smooth(se = FALSE) plot(mod, which = 6) ggplot(au, aes(.hat, .cooksd)) + geom_vline(xintercept = 0, colour = NA) + geom_abline(slope = seq(0, 3, by = 0.5), colour = "white") + geom_smooth(se = FALSE) + geom_point() # column-wise models a <- matrix(rnorm(20), nrow = 10) b <- a + rnorm(length(a)) result <- lm(b ~ a) tidy(result)
library(ggplot2) library(dplyr) mod <- lm(mpg ~ wt + qsec, data = mtcars) tidy(mod) glance(mod) # coefficient plot d <- tidy(mod, conf.int = TRUE) ggplot(d, aes(estimate, term, xmin = conf.low, xmax = conf.high, height = 0)) + geom_point() + geom_vline(xintercept = 0, lty = 4) + geom_errorbarh() # aside: There are tidy() and glance() methods for lm.summary objects too. # this can be useful when you want to conserve memory by converting large lm # objects into their leaner summary.lm equivalents. s <- summary(mod) tidy(s, conf.int = TRUE) glance(s) augment(mod) augment(mod, mtcars, interval = "confidence") # predict on new data newdata <- mtcars %>% head(6) %>% mutate(wt = wt + 1) augment(mod, newdata = newdata) # ggplot2 example where we also construct 95% prediction interval # simpler bivariate model since we're plotting in 2D mod2 <- lm(mpg ~ wt, data = mtcars) au <- augment(mod2, newdata = newdata, interval = "prediction") ggplot(au, aes(wt, mpg)) + geom_point() + geom_line(aes(y = .fitted)) + geom_ribbon(aes(ymin = .lower, ymax = .upper), col = NA, alpha = 0.3) # predict on new data without outcome variable. Output does not include .resid newdata <- newdata %>% select(-mpg) augment(mod, newdata = newdata) au <- augment(mod, data = mtcars) ggplot(au, aes(.hat, .std.resid)) + geom_vline(size = 2, colour = "white", xintercept = 0) + geom_hline(size = 2, colour = "white", yintercept = 0) + geom_point() + geom_smooth(se = FALSE) plot(mod, which = 6) ggplot(au, aes(.hat, .cooksd)) + geom_vline(xintercept = 0, colour = NA) + geom_abline(slope = seq(0, 3, by = 0.5), colour = "white") + geom_smooth(se = FALSE) + geom_point() # column-wise models a <- matrix(rnorm(20), nrow = 10) b <- a + rnorm(length(a)) result <- lm(b ~ a) tidy(result)
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'lm.beta' tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
## S3 method for class 'lm.beta' tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
x |
An |
conf.int |
Logical indicating whether or not to include a confidence
interval in the tidied output. Defaults to |
conf.level |
The confidence level to use for the confidence interval
if |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
If the linear model is an mlm
object (multiple linear model),
there is an additional column response
.
If you have missing values in your model data, you may need to refit
the model with na.action = na.exclude
.
A tibble::tibble()
with columns:
conf.high |
Upper bound on the confidence interval for the estimate. |
conf.low |
Lower bound on the confidence interval for the estimate. |
estimate |
The estimated value of the regression term. |
p.value |
The two-sided p-value associated with the observed statistic. |
statistic |
The value of a T-statistic to use in a hypothesis that the regression term is non-zero. |
std.error |
The standard error of the regression term. |
term |
The name of the regression term. |
Other lm tidiers:
augment.glm()
,
augment.lm()
,
glance.glm()
,
glance.lm()
,
glance.summary.lm()
,
glance.svyglm()
,
tidy.glm()
,
tidy.lm()
,
tidy.mlm()
,
tidy.summary.lm()
# load libraries for models and data library(lm.beta) # fit models mod <- stats::lm(speed ~ ., data = cars) std <- lm.beta(mod) # summarize model fit with tidiers tidy(std, conf.int = TRUE) # generate data ctl <- c(4.17, 5.58, 5.18, 6.11, 4.50, 4.61, 5.17, 4.53, 5.33, 5.14) trt <- c(4.81, 4.17, 4.41, 3.59, 5.87, 3.83, 6.03, 4.89, 4.32, 4.69) group <- gl(2, 10, 20, labels = c("Ctl", "Trt")) weight <- c(ctl, trt) # fit models mod2 <- lm(weight ~ group) std2 <- lm.beta(mod2) # summarize model fit with tidiers tidy(std2, conf.int = TRUE)
# load libraries for models and data library(lm.beta) # fit models mod <- stats::lm(speed ~ ., data = cars) std <- lm.beta(mod) # summarize model fit with tidiers tidy(std, conf.int = TRUE) # generate data ctl <- c(4.17, 5.58, 5.18, 6.11, 4.50, 4.61, 5.17, 4.53, 5.33, 5.14) trt <- c(4.81, 4.17, 4.41, 3.59, 5.87, 3.83, 6.03, 4.89, 4.32, 4.69) group <- gl(2, 10, 20, labels = c("Ctl", "Trt")) weight <- c(ctl, trt) # fit models mod2 <- lm(weight ~ group) std2 <- lm.beta(mod2) # summarize model fit with tidiers tidy(std2, conf.int = TRUE)
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'lmodel2' tidy(x, ...)
## S3 method for class 'lmodel2' tidy(x, ...)
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
There are always only two terms in an lmodel2
: "Intercept"
and "Slope"
. These are computed by four methods: OLS
(ordinary least squares), MA (major axis), SMA (standard major
axis), and RMA (ranged major axis).
The returned p-value is one-tailed and calculated via a permutation test.
A permutational test is used because distributional assumptions may not
be valid. More information can be found in
vignette("mod2user", package = "lmodel2")
.
A tibble::tibble()
with columns:
conf.high |
Upper bound on the confidence interval for the estimate. |
conf.low |
Lower bound on the confidence interval for the estimate. |
estimate |
The estimated value of the regression term. |
p.value |
The two-sided p-value associated with the observed statistic. |
term |
The name of the regression term. |
method |
Either OLS/MA/SMA/RMA |
Other lmodel2 tidiers:
glance.lmodel2()
# load libraries for models and data library(lmodel2) data(mod2ex2) Ex2.res <- lmodel2(Prey ~ Predators, data = mod2ex2, "relative", "relative", 99) Ex2.res # summarize model fit with tidiers + visualization tidy(Ex2.res) glance(Ex2.res) # this allows coefficient plots with ggplot2 library(ggplot2) ggplot(tidy(Ex2.res), aes(estimate, term, color = method)) + geom_point() + geom_errorbarh(aes(xmin = conf.low, xmax = conf.high)) + geom_errorbarh(aes(xmin = conf.low, xmax = conf.high))
# load libraries for models and data library(lmodel2) data(mod2ex2) Ex2.res <- lmodel2(Prey ~ Predators, data = mod2ex2, "relative", "relative", 99) Ex2.res # summarize model fit with tidiers + visualization tidy(Ex2.res) glance(Ex2.res) # this allows coefficient plots with ggplot2 library(ggplot2) ggplot(tidy(Ex2.res), aes(estimate, term, color = method)) + geom_point() + geom_errorbarh(aes(xmin = conf.low, xmax = conf.high)) + geom_errorbarh(aes(xmin = conf.low, xmax = conf.high))
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'lmrob' tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
## S3 method for class 'lmrob' tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
x |
A |
conf.int |
Logical indicating whether or not to include a confidence
interval in the tidied output. Defaults to |
conf.level |
The confidence level to use for the confidence interval
if |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
For tidiers for robust models from the MASS package see
tidy.rlm()
.
Other robustbase tidiers:
augment.glmrob()
,
augment.lmrob()
,
glance.lmrob()
,
tidy.glmrob()
if (requireNamespace("robustbase", quietly = TRUE)) { # load libraries for models and data library(robustbase) data(coleman) set.seed(0) m <- lmrob(Y ~ ., data = coleman) tidy(m) augment(m) glance(m) data(carrots) Rfit <- glmrob(cbind(success, total - success) ~ logdose + block, family = binomial, data = carrots, method = "Mqle", control = glmrobMqle.control(tcc = 1.2) ) tidy(Rfit) augment(Rfit) }
if (requireNamespace("robustbase", quietly = TRUE)) { # load libraries for models and data library(robustbase) data(coleman) set.seed(0) m <- lmrob(Y ~ ., data = coleman) tidy(m) augment(m) glance(m) data(carrots) Rfit <- glmrob(cbind(success, total - success) ~ logdose + block, family = binomial, data = carrots, method = "Mqle", control = glmrobMqle.control(tcc = 1.2) ) tidy(Rfit) augment(Rfit) }
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'lmRob' tidy(x, ...)
## S3 method for class 'lmRob' tidy(x, ...)
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
For tidiers for robust models from the MASS package see
tidy.rlm()
.
Other robust tidiers:
augment.lmRob()
,
glance.glmRob()
,
glance.lmRob()
,
tidy.glmRob()
# load modeling library library(robust) # fit model m <- lmRob(mpg ~ wt, data = mtcars) # summarize model fit with tidiers tidy(m) augment(m) glance(m)
# load modeling library library(robust) # fit model m <- lmRob(mpg ~ wt, data = mtcars) # summarize model fit with tidiers tidy(m) augment(m) glance(m)
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'lsmobj' tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
## S3 method for class 'lsmobj' tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
x |
An |
conf.int |
Logical indicating whether or not to include a confidence
interval in the tidied output. Defaults to |
conf.level |
The confidence level to use for the confidence interval
if |
... |
Additional arguments passed to |
Returns a data frame with one observation for each estimated marginal mean, and one column for each combination of factors. When the input is a contrast, each row will contain one estimated contrast.
There are a large number of arguments that can be
passed on to emmeans::summary.emmGrid()
or lsmeans::summary.ref.grid()
.
A tibble::tibble()
with columns:
conf.high |
Upper bound on the confidence interval for the estimate. |
conf.low |
Lower bound on the confidence interval for the estimate. |
contrast |
Levels being compared. |
df |
Degrees of freedom used by this term in the model. |
null.value |
Value to which the estimate is compared. |
p.value |
The two-sided p-value associated with the observed statistic. |
std.error |
The standard error of the regression term. |
estimate |
Expected marginal mean |
statistic |
T-ratio statistic |
tidy()
, emmeans::ref_grid()
, emmeans::emmeans()
,
emmeans::contrast()
Other emmeans tidiers:
tidy.emmGrid()
,
tidy.ref.grid()
,
tidy.summary_emm()
# load libraries for models and data library(emmeans) # linear model for sales of oranges per day oranges_lm1 <- lm(sales1 ~ price1 + price2 + day + store, data = oranges) # reference grid; see vignette("basics", package = "emmeans") oranges_rg1 <- ref_grid(oranges_lm1) td <- tidy(oranges_rg1) td # marginal averages marginal <- emmeans(oranges_rg1, "day") tidy(marginal) # contrasts tidy(contrast(marginal)) tidy(contrast(marginal, method = "pairwise")) # plot confidence intervals library(ggplot2) ggplot(tidy(marginal, conf.int = TRUE), aes(day, estimate)) + geom_point() + geom_errorbar(aes(ymin = conf.low, ymax = conf.high)) # by multiple prices by_price <- emmeans(oranges_lm1, "day", by = "price2", at = list( price1 = 50, price2 = c(40, 60, 80), day = c("2", "3", "4") ) ) by_price tidy(by_price) ggplot(tidy(by_price, conf.int = TRUE), aes(price2, estimate, color = day)) + geom_line() + geom_errorbar(aes(ymin = conf.low, ymax = conf.high)) # joint_tests tidy(joint_tests(oranges_lm1))
# load libraries for models and data library(emmeans) # linear model for sales of oranges per day oranges_lm1 <- lm(sales1 ~ price1 + price2 + day + store, data = oranges) # reference grid; see vignette("basics", package = "emmeans") oranges_rg1 <- ref_grid(oranges_lm1) td <- tidy(oranges_rg1) td # marginal averages marginal <- emmeans(oranges_rg1, "day") tidy(marginal) # contrasts tidy(contrast(marginal)) tidy(contrast(marginal, method = "pairwise")) # plot confidence intervals library(ggplot2) ggplot(tidy(marginal, conf.int = TRUE), aes(day, estimate)) + geom_point() + geom_errorbar(aes(ymin = conf.low, ymax = conf.high)) # by multiple prices by_price <- emmeans(oranges_lm1, "day", by = "price2", at = list( price1 = 50, price2 = c(40, 60, 80), day = c("2", "3", "4") ) ) by_price tidy(by_price) ggplot(tidy(by_price, conf.int = TRUE), aes(price2, estimate, color = day)) + geom_line() + geom_errorbar(aes(ymin = conf.low, ymax = conf.high)) # joint_tests tidy(joint_tests(oranges_lm1))
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'manova' tidy(x, test = "Pillai", ...)
## S3 method for class 'manova' tidy(x, test = "Pillai", ...)
x |
A |
test |
One of "Pillai" (Pillai's trace), "Wilks" (Wilk's lambda), "Hotelling-Lawley" (Hotelling-Lawley trace) or "Roy" (Roy's greatest root) indicating which test statistic should be used. Defaults to "Pillai". |
... |
Arguments passed on to
|
Depending on which test statistic is specified only one of pillai
,
wilks
, hl
or roy
is included.
A tibble::tibble()
with columns:
den.df |
Degrees of freedom of the denominator. |
num.df |
Degrees of freedom. |
p.value |
The two-sided p-value associated with the observed statistic. |
statistic |
The value of a T-statistic to use in a hypothesis that the regression term is non-zero. |
term |
The name of the regression term. |
pillai |
Pillai's trace. |
wilks |
Wilk's lambda. |
hl |
Hotelling-Lawley trace. |
roy |
Roy's greatest root. |
tidy()
, stats::summary.manova()
Other anova tidiers:
glance.anova()
,
glance.aov()
,
tidy.TukeyHSD()
,
tidy.anova()
,
tidy.aov()
,
tidy.aovlist()
npk2 <- within(npk, foo <- rnorm(24)) m <- manova(cbind(yield, foo) ~ block + N * P * K, npk2) tidy(m)
npk2 <- within(npk, foo <- rnorm(24)) m <- manova(cbind(yield, foo) ~ block + N * P * K, npk2) tidy(m)
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'map' tidy(x, ...)
## S3 method for class 'map' tidy(x, ...)
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with columns:
term |
The name of the regression term. |
long |
Longitude. |
lat |
Latitude. |
Remaining columns give information on geographic attributes and depend on the inputted map object. See ?maps::map for more information.
# load libraries for models and data library(maps) library(ggplot2) ca <- map("county", "ca", plot = FALSE, fill = TRUE) tidy(ca) qplot(long, lat, data = ca, geom = "polygon", group = group) tx <- map("county", "texas", plot = FALSE, fill = TRUE) tidy(tx) qplot(long, lat, data = tx, geom = "polygon", group = group, colour = I("white") )
# load libraries for models and data library(maps) library(ggplot2) ca <- map("county", "ca", plot = FALSE, fill = TRUE) tidy(ca) qplot(long, lat, data = ca, geom = "polygon", group = group) tx <- map("county", "texas", plot = FALSE, fill = TRUE) tidy(tx) qplot(long, lat, data = tx, geom = "polygon", group = group, colour = I("white") )
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'margins' tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
## S3 method for class 'margins' tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
x |
A |
conf.int |
Logical indicating whether or not to include a confidence
interval in the tidied output. Defaults to |
conf.level |
The confidence level to use for the confidence interval
if |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
The margins
package provides a way to obtain coefficient marginal
effects for a variety of (non-linear) models, such as logit or models with
multiway interaction terms. Note that the glance.margins()
method
requires rerunning the underlying model again, which can take some time.
Similarly, an augment.margins()
method is not currently supported, but
users can simply run the underlying model to obtain the same information.
A tibble::tibble()
with columns:
conf.high |
Upper bound on the confidence interval for the estimate. |
conf.low |
Lower bound on the confidence interval for the estimate. |
estimate |
The estimated value of the regression term. |
p.value |
The two-sided p-value associated with the observed statistic. |
statistic |
The value of a T-statistic to use in a hypothesis that the regression term is non-zero. |
std.error |
The standard error of the regression term. |
term |
The name of the regression term. |
# load libraries for models and data library(margins) # example 1: logit model mod_log <- glm(am ~ cyl + hp + wt, data = mtcars, family = binomial) # get tidied "naive" model coefficients tidy(mod_log) # convert to marginal effects with margins() marg_log <- margins(mod_log) # get tidied marginal effects tidy(marg_log) tidy(marg_log, conf.int = TRUE) # requires running the underlying model again. quick for this example glance(marg_log) # augmenting `margins` outputs isn't supported, but # you can get the same info by running on the underlying model augment(mod_log) # example 2: threeway interaction terms mod_ie <- lm(mpg ~ wt * cyl * disp, data = mtcars) # get tidied "naive" model coefficients tidy(mod_ie) # convert to marginal effects with margins() marg_ie0 <- margins(mod_ie) # get tidied marginal effects tidy(marg_ie0) glance(marg_ie0) # marginal effects evaluated at specific values of a variable (here: cyl) marg_ie1 <- margins(mod_ie, at = list(cyl = c(4,6,8))) # summarize model fit with tidiers tidy(marg_ie1) # marginal effects of one interaction variable (here: wt), modulated at # specific values of the two other interaction variables (here: cyl and drat) marg_ie2 <- margins(mod_ie, variables = "wt", at = list(cyl = c(4,6,8), drat = c(3, 3.5, 4))) # summarize model fit with tidiers tidy(marg_ie2)
# load libraries for models and data library(margins) # example 1: logit model mod_log <- glm(am ~ cyl + hp + wt, data = mtcars, family = binomial) # get tidied "naive" model coefficients tidy(mod_log) # convert to marginal effects with margins() marg_log <- margins(mod_log) # get tidied marginal effects tidy(marg_log) tidy(marg_log, conf.int = TRUE) # requires running the underlying model again. quick for this example glance(marg_log) # augmenting `margins` outputs isn't supported, but # you can get the same info by running on the underlying model augment(mod_log) # example 2: threeway interaction terms mod_ie <- lm(mpg ~ wt * cyl * disp, data = mtcars) # get tidied "naive" model coefficients tidy(mod_ie) # convert to marginal effects with margins() marg_ie0 <- margins(mod_ie) # get tidied marginal effects tidy(marg_ie0) glance(marg_ie0) # marginal effects evaluated at specific values of a variable (here: cyl) marg_ie1 <- margins(mod_ie, at = list(cyl = c(4,6,8))) # summarize model fit with tidiers tidy(marg_ie1) # marginal effects of one interaction variable (here: wt), modulated at # specific values of the two other interaction variables (here: cyl and drat) marg_ie2 <- margins(mod_ie, variables = "wt", at = list(cyl = c(4,6,8), drat = c(3, 3.5, 4))) # summarize model fit with tidiers tidy(marg_ie2)
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'Mclust' tidy(x, ...)
## S3 method for class 'Mclust' tidy(x, ...)
x |
An |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with columns:
proportion |
The mixing proportion of each component |
size |
Number of points assigned to cluster. |
mean |
The mean for each component. In case of 2+ dimensional models, a column with the mean is added for each dimension. NA for noise component |
variance |
In case of one-dimensional and spherical models, the variance for each component, omitted otherwise. NA for noise component |
component |
Cluster id as a factor. |
Other mclust tidiers:
augment.Mclust()
# load library for models and data library(mclust) # load data manipulation libraries library(dplyr) library(tibble) library(purrr) library(tidyr) set.seed(27) centers <- tibble( cluster = factor(1:3), # number points in each cluster num_points = c(100, 150, 50), # x1 coordinate of cluster center x1 = c(5, 0, -3), # x2 coordinate of cluster center x2 = c(-1, 1, -2) ) points <- centers %>% mutate( x1 = map2(num_points, x1, rnorm), x2 = map2(num_points, x2, rnorm) ) %>% select(-num_points, -cluster) %>% unnest(c(x1, x2)) # fit model m <- Mclust(points) # summarize model fit with tidiers tidy(m) augment(m, points) glance(m)
# load library for models and data library(mclust) # load data manipulation libraries library(dplyr) library(tibble) library(purrr) library(tidyr) set.seed(27) centers <- tibble( cluster = factor(1:3), # number points in each cluster num_points = c(100, 150, 50), # x1 coordinate of cluster center x1 = c(5, 0, -3), # x2 coordinate of cluster center x2 = c(-1, 1, -2) ) points <- centers %>% mutate( x1 = map2(num_points, x1, rnorm), x2 = map2(num_points, x2, rnorm) ) %>% select(-num_points, -cluster) %>% unnest(c(x1, x2)) # fit model m <- Mclust(points) # summarize model fit with tidiers tidy(m) augment(m, points) glance(m)
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'mediate' tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
## S3 method for class 'mediate' tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
x |
A |
conf.int |
Logical indicating whether or not to include a confidence
interval in the tidied output. Defaults to |
conf.level |
The confidence level to use for the confidence interval
if |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
The tibble has four rows. The first two indicate the mediated effect in the control and treatment groups, respectively. And the last two the direct effect in each group.
A tibble::tibble()
with columns:
conf.high |
Upper bound on the confidence interval for the estimate. |
conf.low |
Lower bound on the confidence interval for the estimate. |
estimate |
The estimated value of the regression term. |
p.value |
The two-sided p-value associated with the observed statistic. |
statistic |
The value of a T-statistic to use in a hypothesis that the regression term is non-zero. |
std.error |
The standard error of the regression term. |
term |
The name of the regression term. |
# load libraries for models and data library(mediation) data(jobs) # fit models b <- lm(job_seek ~ treat + econ_hard + sex + age, data = jobs) c <- lm(depress2 ~ treat + job_seek + econ_hard + sex + age, data = jobs) mod <- mediate(b, c, sims = 50, treat = "treat", mediator = "job_seek") # summarize model fit with tidiers tidy(mod) tidy(mod, conf.int = TRUE) tidy(mod, conf.int = TRUE, conf.level = .99)
# load libraries for models and data library(mediation) data(jobs) # fit models b <- lm(job_seek ~ treat + econ_hard + sex + age, data = jobs) c <- lm(depress2 ~ treat + job_seek + econ_hard + sex + age, data = jobs) mod <- mediate(b, c, sims = 50, treat = "treat", mediator = "job_seek") # summarize model fit with tidiers tidy(mod) tidy(mod, conf.int = TRUE) tidy(mod, conf.int = TRUE, conf.level = .99)
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
The particular functions below provide generic tidy methods for
objects returned by the mfx
package, preserving the calculated marginal
effects instead of the naive model coefficients. The returned tidy tibble
will also include an additional "atmean" column indicating how the marginal
effects were originally calculated (see Details below).
## S3 method for class 'mfx' tidy(x, conf.int = FALSE, conf.level = 0.95, ...) ## S3 method for class 'logitmfx' tidy(x, conf.int = FALSE, conf.level = 0.95, ...) ## S3 method for class 'negbinmfx' tidy(x, conf.int = FALSE, conf.level = 0.95, ...) ## S3 method for class 'poissonmfx' tidy(x, conf.int = FALSE, conf.level = 0.95, ...) ## S3 method for class 'probitmfx' tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
## S3 method for class 'mfx' tidy(x, conf.int = FALSE, conf.level = 0.95, ...) ## S3 method for class 'logitmfx' tidy(x, conf.int = FALSE, conf.level = 0.95, ...) ## S3 method for class 'negbinmfx' tidy(x, conf.int = FALSE, conf.level = 0.95, ...) ## S3 method for class 'poissonmfx' tidy(x, conf.int = FALSE, conf.level = 0.95, ...) ## S3 method for class 'probitmfx' tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
x |
A |
conf.int |
Logical indicating whether or not to include a confidence
interval in the tidied output. Defaults to |
conf.level |
The confidence level to use for the confidence interval
if |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
The mfx
package provides methods for calculating marginal effects
for various generalized linear models (GLMs). Unlike standard linear
models, estimated model coefficients in a GLM cannot be directly
interpreted as marginal effects (i.e., the change in the response variable
predicted after a one unit change in one of the regressors). This is
because the estimated coefficients are multiplicative, dependent on both
the link function that was used for the estimation and any other variables
that were included in the model. When calculating marginal effects, users
must typically choose whether they want to use i) the average observation
in the data, or ii) the average of the sample marginal effects. See
vignette("mfxarticle")
from the mfx
package for more details.
A tibble::tibble()
with columns:
conf.high |
Upper bound on the confidence interval for the estimate. |
conf.low |
Lower bound on the confidence interval for the estimate. |
estimate |
The estimated value of the regression term. |
p.value |
The two-sided p-value associated with the observed statistic. |
statistic |
The value of a T-statistic to use in a hypothesis that the regression term is non-zero. |
std.error |
The standard error of the regression term. |
term |
The name of the regression term. |
atmean |
TRUE if the marginal effects were originally calculated as the partial effects for the average observation. If FALSE, then these were instead calculated as average partial effects. |
tidy()
, mfx::logitmfx()
, mfx::negbinmfx()
, mfx::poissonmfx()
, mfx::probitmfx()
Other mfx tidiers:
augment.betamfx()
,
augment.mfx()
,
glance.betamfx()
,
glance.mfx()
,
tidy.betamfx()
# load libraries for models and data library(mfx) # get the marginal effects from a logit regression mod_logmfx <- logitmfx(am ~ cyl + hp + wt, atmean = TRUE, data = mtcars) tidy(mod_logmfx, conf.int = TRUE) # compare with the naive model coefficients of the same logit call tidy( glm(am ~ cyl + hp + wt, family = binomial, data = mtcars), conf.int = TRUE ) augment(mod_logmfx) glance(mod_logmfx) # another example, this time using probit regression mod_probmfx <- probitmfx(am ~ cyl + hp + wt, atmean = TRUE, data = mtcars) tidy(mod_probmfx, conf.int = TRUE) augment(mod_probmfx) glance(mod_probmfx)
# load libraries for models and data library(mfx) # get the marginal effects from a logit regression mod_logmfx <- logitmfx(am ~ cyl + hp + wt, atmean = TRUE, data = mtcars) tidy(mod_logmfx, conf.int = TRUE) # compare with the naive model coefficients of the same logit call tidy( glm(am ~ cyl + hp + wt, family = binomial, data = mtcars), conf.int = TRUE ) augment(mod_logmfx) glance(mod_logmfx) # another example, this time using probit regression mod_probmfx <- probitmfx(am ~ cyl + hp + wt, atmean = TRUE, data = mtcars) tidy(mod_probmfx, conf.int = TRUE) augment(mod_probmfx) glance(mod_probmfx)
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'mjoint' tidy( x, component = "survival", conf.int = FALSE, conf.level = 0.95, boot_se = NULL, ... )
## S3 method for class 'mjoint' tidy( x, component = "survival", conf.int = FALSE, conf.level = 0.95, boot_se = NULL, ... )
x |
An |
component |
Character specifying whether to tidy the survival or
the longitudinal component of the model. Must be either |
conf.int |
Logical indicating whether or not to include a confidence
interval in the tidied output. Defaults to |
conf.level |
The confidence level to use for the confidence interval
if |
boot_se |
Optionally a |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with columns:
conf.high |
Upper bound on the confidence interval for the estimate. |
conf.low |
Lower bound on the confidence interval for the estimate. |
estimate |
The estimated value of the regression term. |
p.value |
The two-sided p-value associated with the observed statistic. |
statistic |
The value of a T-statistic to use in a hypothesis that the regression term is non-zero. |
std.error |
The standard error of the regression term. |
term |
The name of the regression term. |
tidy()
, joineRML::mjoint()
, joineRML::bootSE()
Other mjoint tidiers:
glance.mjoint()
# broom only skips running these examples because the example models take a # while to generate—they should run just fine, though! ## Not run: # load libraries for models and data library(joineRML) # fit a joint model with bivariate longitudinal outcomes data(heart.valve) hvd <- heart.valve[!is.na(heart.valve$log.grad) & !is.na(heart.valve$log.lvmi) & heart.valve$num <= 50, ] fit <- mjoint( formLongFixed = list( "grad" = log.grad ~ time + sex + hs, "lvmi" = log.lvmi ~ time + sex ), formLongRandom = list( "grad" = ~ 1 | num, "lvmi" = ~ time | num ), formSurv = Surv(fuyrs, status) ~ age, data = hvd, inits = list("gamma" = c(0.11, 1.51, 0.80)), timeVar = "time" ) # extract the survival fixed effects tidy(fit) # extract the longitudinal fixed effects tidy(fit, component = "longitudinal") # extract the survival fixed effects with confidence intervals tidy(fit, ci = TRUE) # extract the survival fixed effects with confidence intervals based # on bootstrapped standard errors bSE <- bootSE(fit, nboot = 5, safe.boot = TRUE) tidy(fit, boot_se = bSE, ci = TRUE) # augment original data with fitted longitudinal values and residuals hvd2 <- augment(fit) # extract model statistics glance(fit) ## End(Not run)
# broom only skips running these examples because the example models take a # while to generate—they should run just fine, though! ## Not run: # load libraries for models and data library(joineRML) # fit a joint model with bivariate longitudinal outcomes data(heart.valve) hvd <- heart.valve[!is.na(heart.valve$log.grad) & !is.na(heart.valve$log.lvmi) & heart.valve$num <= 50, ] fit <- mjoint( formLongFixed = list( "grad" = log.grad ~ time + sex + hs, "lvmi" = log.lvmi ~ time + sex ), formLongRandom = list( "grad" = ~ 1 | num, "lvmi" = ~ time | num ), formSurv = Surv(fuyrs, status) ~ age, data = hvd, inits = list("gamma" = c(0.11, 1.51, 0.80)), timeVar = "time" ) # extract the survival fixed effects tidy(fit) # extract the longitudinal fixed effects tidy(fit, component = "longitudinal") # extract the survival fixed effects with confidence intervals tidy(fit, ci = TRUE) # extract the survival fixed effects with confidence intervals based # on bootstrapped standard errors bSE <- bootSE(fit, nboot = 5, safe.boot = TRUE) tidy(fit, boot_se = bSE, ci = TRUE) # augment original data with fitted longitudinal values and residuals hvd2 <- augment(fit) # extract model statistics glance(fit) ## End(Not run)
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'mle2' tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
## S3 method for class 'mle2' tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
x |
An |
conf.int |
Logical indicating whether or not to include a confidence
interval in the tidied output. Defaults to |
conf.level |
The confidence level to use for the confidence interval
if |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with columns:
conf.high |
Upper bound on the confidence interval for the estimate. |
conf.low |
Lower bound on the confidence interval for the estimate. |
estimate |
The estimated value of the regression term. |
p.value |
The two-sided p-value associated with the observed statistic. |
statistic |
The value of a T-statistic to use in a hypothesis that the regression term is non-zero. |
std.error |
The standard error of the regression term. |
term |
The name of the regression term. |
tidy()
, bbmle::mle2()
, tidy_optim()
# load libraries for models and data library(bbmle) # generate data x <- 0:10 y <- c(26, 17, 13, 12, 20, 5, 9, 8, 5, 4, 8) d <- data.frame(x, y) # fit model fit <- mle2(y ~ dpois(lambda = ymean), start = list(ymean = mean(y)), data = d ) # summarize model fit with tidiers tidy(fit)
# load libraries for models and data library(bbmle) # generate data x <- 0:10 y <- c(26, 17, 13, 12, 20, 5, 9, 8, 5, 4, 8) d <- data.frame(x, y) # fit model fit <- mle2(y ~ dpois(lambda = ymean), start = list(ymean = mean(y)), data = d ) # summarize model fit with tidiers tidy(fit)
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'mlm' tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
## S3 method for class 'mlm' tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
x |
An |
conf.int |
Logical indicating whether or not to include a confidence
interval in the tidied output. Defaults to |
conf.level |
The confidence level to use for the confidence interval
if |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
In contrast to lm
object (simple linear model), tidy output for
mlm
(multiple linear model) objects contain an additional column
response
.
If you have missing values in your model data, you may need to refit
the model with na.action = na.exclude
.
A tibble::tibble()
with columns:
conf.high |
Upper bound on the confidence interval for the estimate. |
conf.low |
Lower bound on the confidence interval for the estimate. |
estimate |
The estimated value of the regression term. |
p.value |
The two-sided p-value associated with the observed statistic. |
statistic |
The value of a T-statistic to use in a hypothesis that the regression term is non-zero. |
std.error |
The standard error of the regression term. |
term |
The name of the regression term. |
Other lm tidiers:
augment.glm()
,
augment.lm()
,
glance.glm()
,
glance.lm()
,
glance.summary.lm()
,
glance.svyglm()
,
tidy.glm()
,
tidy.lm()
,
tidy.lm.beta()
,
tidy.summary.lm()
# fit model mod <- lm(cbind(mpg, disp) ~ wt, mtcars) # summarize model fit with tidiers tidy(mod, conf.int = TRUE)
# fit model mod <- lm(cbind(mpg, disp) ~ wt, mtcars) # summarize model fit with tidiers tidy(mod, conf.int = TRUE)
These methods tidy the coefficients of mnl and nl models generated
by the functions of the mlogit
package.
## S3 method for class 'mlogit' tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
## S3 method for class 'mlogit' tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
x |
an object returned from |
conf.int |
Logical indicating whether or not to include a confidence
interval in the tidied output. Defaults to |
conf.level |
The confidence level to use for the confidence interval
if |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with columns:
conf.high |
Upper bound on the confidence interval for the estimate. |
conf.low |
Lower bound on the confidence interval for the estimate. |
estimate |
The estimated value of the regression term. |
p.value |
The two-sided p-value associated with the observed statistic. |
statistic |
The value of a T-statistic to use in a hypothesis that the regression term is non-zero. |
std.error |
The standard error of the regression term. |
term |
The name of the regression term. |
Other mlogit tidiers:
augment.mlogit()
,
glance.mlogit()
# load libraries for models and data library(mlogit) data("Fishing", package = "mlogit") Fish <- dfidx(Fishing, varying = 2:9, shape = "wide", choice = "mode") # fit model m <- mlogit(mode ~ price + catch | income, data = Fish) # summarize model fit with tidiers tidy(m) augment(m) glance(m)
# load libraries for models and data library(mlogit) data("Fishing", package = "mlogit") Fish <- dfidx(Fishing, varying = 2:9, shape = "wide", choice = "mode") # fit model m <- mlogit(mode ~ price + catch | income, data = Fish) # summarize model fit with tidiers tidy(m) augment(m) glance(m)
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'muhaz' tidy(x, ...)
## S3 method for class 'muhaz' tidy(x, ...)
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with columns:
time |
Point in time. |
estimate |
Estimated hazard rate. |
Other muhaz tidiers:
glance.muhaz()
# load libraries for models and data library(muhaz) library(survival) # fit model x <- muhaz(ovarian$futime, ovarian$fustat) # summarize model fit with tidiers tidy(x) glance(x)
# load libraries for models and data library(muhaz) library(survival) # fit model x <- muhaz(ovarian$futime, ovarian$fustat) # summarize model fit with tidiers tidy(x) glance(x)
These methods tidy the coefficients of multinomial logistic regression
models generated by multinom
of the nnet
package.
## S3 method for class 'multinom' tidy(x, conf.int = FALSE, conf.level = 0.95, exponentiate = FALSE, ...)
## S3 method for class 'multinom' tidy(x, conf.int = FALSE, conf.level = 0.95, exponentiate = FALSE, ...)
x |
A |
conf.int |
Logical indicating whether or not to include a confidence
interval in the tidied output. Defaults to |
conf.level |
The confidence level to use for the confidence interval
if |
exponentiate |
Logical indicating whether or not to exponentiate the
the coefficient estimates. This is typical for logistic and multinomial
regressions, but a bad idea if there is no log or logit link. Defaults
to |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with columns:
conf.high |
Upper bound on the confidence interval for the estimate. |
conf.low |
Lower bound on the confidence interval for the estimate. |
estimate |
The estimated value of the regression term. |
p.value |
The two-sided p-value associated with the observed statistic. |
statistic |
The value of a T-statistic to use in a hypothesis that the regression term is non-zero. |
std.error |
The standard error of the regression term. |
term |
The name of the regression term. |
y.value |
The response level. |
Other multinom tidiers:
glance.multinom()
# load libraries for models and data library(nnet) library(MASS) example(birthwt) bwt.mu <- multinom(low ~ ., bwt) tidy(bwt.mu) glance(bwt.mu) # or, for output from a multinomial logistic regression fit.gear <- multinom(gear ~ mpg + factor(am), data = mtcars) tidy(fit.gear) glance(fit.gear)
# load libraries for models and data library(nnet) library(MASS) example(birthwt) bwt.mu <- multinom(low ~ ., bwt) tidy(bwt.mu) glance(bwt.mu) # or, for output from a multinomial logistic regression fit.gear <- multinom(gear ~ mpg + factor(am), data = mtcars) tidy(fit.gear) glance(fit.gear)
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'negbin' tidy(x, conf.int = FALSE, conf.level = 0.95, exponentiate = FALSE, ...)
## S3 method for class 'negbin' tidy(x, conf.int = FALSE, conf.level = 0.95, exponentiate = FALSE, ...)
x |
A |
conf.int |
Logical indicating whether or not to include a confidence
interval in the tidied output. Defaults to |
conf.level |
The confidence level to use for the confidence interval
if |
exponentiate |
Logical indicating whether or not to exponentiate the
the coefficient estimates. This is typical for logistic and multinomial
regressions, but a bad idea if there is no log or logit link. Defaults
to |
... |
For |
Other glm.nb tidiers:
glance.negbin()
# load libraries for models and data library(MASS) # fit model r <- glm.nb(Days ~ Sex / (Age + Eth * Lrn), data = quine) # summarize model fit with tidiers tidy(r) glance(r)
# load libraries for models and data library(MASS) # fit model r <- glm.nb(Days ~ Sex / (Age + Eth * Lrn), data = quine) # summarize model fit with tidiers tidy(r) glance(r)
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'nlrq' tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
## S3 method for class 'nlrq' tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
x |
A |
conf.int |
Logical indicating whether or not to include a confidence
interval in the tidied output. Defaults to |
conf.level |
The confidence level to use for the confidence interval
if |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with columns:
conf.high |
Upper bound on the confidence interval for the estimate. |
conf.low |
Lower bound on the confidence interval for the estimate. |
estimate |
The estimated value of the regression term. |
p.value |
The two-sided p-value associated with the observed statistic. |
statistic |
The value of a T-statistic to use in a hypothesis that the regression term is non-zero. |
std.error |
The standard error of the regression term. |
term |
The name of the regression term. |
Other quantreg tidiers:
augment.nlrq()
,
augment.rq()
,
augment.rqs()
,
glance.nlrq()
,
glance.rq()
,
tidy.rq()
,
tidy.rqs()
# load modeling library library(quantreg) # build artificial data with multiplicative error set.seed(1) dat <- NULL dat$x <- rep(1:25, 20) dat$y <- SSlogis(dat$x, 10, 12, 2) * rnorm(500, 1, 0.1) # fit the median using nlrq mod <- nlrq(y ~ SSlogis(x, Asym, mid, scal), data = dat, tau = 0.5, trace = TRUE ) # summarize model fit with tidiers tidy(mod) glance(mod) augment(mod)
# load modeling library library(quantreg) # build artificial data with multiplicative error set.seed(1) dat <- NULL dat$x <- rep(1:25, 20) dat$y <- SSlogis(dat$x, 10, 12, 2) * rnorm(500, 1, 0.1) # fit the median using nlrq mod <- nlrq(y ~ SSlogis(x, Asym, mid, scal), data = dat, tau = 0.5, trace = TRUE ) # summarize model fit with tidiers tidy(mod) glance(mod) augment(mod)
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'nls' tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
## S3 method for class 'nls' tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
x |
An |
conf.int |
Logical indicating whether or not to include a confidence
interval in the tidied output. Defaults to |
conf.level |
The confidence level to use for the confidence interval
if |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with columns:
conf.high |
Upper bound on the confidence interval for the estimate. |
conf.low |
Lower bound on the confidence interval for the estimate. |
estimate |
The estimated value of the regression term. |
p.value |
The two-sided p-value associated with the observed statistic. |
statistic |
The value of a T-statistic to use in a hypothesis that the regression term is non-zero. |
std.error |
The standard error of the regression term. |
term |
The name of the regression term. |
tidy, stats::nls()
, stats::summary.nls()
Other nls tidiers:
augment.nls()
,
glance.nls()
# fit model n <- nls(mpg ~ k * e^wt, data = mtcars, start = list(k = 1, e = 2)) # summarize model fit with tidiers + visualization tidy(n) augment(n) glance(n) library(ggplot2) ggplot(augment(n), aes(wt, mpg)) + geom_point() + geom_line(aes(y = .fitted)) newdata <- head(mtcars) newdata$wt <- newdata$wt + 1 augment(n, newdata = newdata)
# fit model n <- nls(mpg ~ k * e^wt, data = mtcars, start = list(k = 1, e = 2)) # summarize model fit with tidiers + visualization tidy(n) augment(n) glance(n) library(ggplot2) ggplot(augment(n), aes(wt, mpg)) + geom_point() + geom_line(aes(y = .fitted)) newdata <- head(mtcars) newdata$wt <- newdata$wt + 1 augment(n, newdata = newdata)
Vector tidiers are deprecated and will be removed from an upcoming release of broom.
## S3 method for class 'numeric' tidy(x, ...) ## S3 method for class 'character' tidy(x, ...) ## S3 method for class 'logical' tidy(x, ...)
## S3 method for class 'numeric' tidy(x, ...) ## S3 method for class 'character' tidy(x, ...) ## S3 method for class 'logical' tidy(x, ...)
x |
An object of class "numeric", "integer", "character", or "logical". Most likely a named vector |
... |
Extra arguments (not used) |
Turn atomic vectors into data frames, where the names of the vector (if they exist) are a column and the values of the vector are a column.
Other deprecated:
bootstrap()
,
confint_tidy()
,
data.frame_tidiers
,
finish_glance()
,
fix_data_frame()
,
summary_tidiers
,
tidy.density()
,
tidy.dist()
,
tidy.ftable()
Other deprecated:
bootstrap()
,
confint_tidy()
,
data.frame_tidiers
,
finish_glance()
,
fix_data_frame()
,
summary_tidiers
,
tidy.density()
,
tidy.dist()
,
tidy.ftable()
Other deprecated:
bootstrap()
,
confint_tidy()
,
data.frame_tidiers
,
finish_glance()
,
fix_data_frame()
,
summary_tidiers
,
tidy.density()
,
tidy.dist()
,
tidy.ftable()
## Not run: x <- 1:5 names(x) <- letters[1:5] tidy(x) ## End(Not run)
## Not run: x <- 1:5 names(x) <- letters[1:5] tidy(x) ## End(Not run)
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'orcutt' tidy(x, ...)
## S3 method for class 'orcutt' tidy(x, ...)
x |
An |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with columns:
estimate |
The estimated value of the regression term. |
p.value |
The two-sided p-value associated with the observed statistic. |
statistic |
The value of a T-statistic to use in a hypothesis that the regression term is non-zero. |
std.error |
The standard error of the regression term. |
term |
The name of the regression term. |
Other orcutt tidiers:
glance.orcutt()
# load libraries for models and data library(orcutt) # fit model and summarize results reg <- lm(mpg ~ wt + qsec + disp, mtcars) tidy(reg) co <- cochrane.orcutt(reg) tidy(co) glance(co)
# load libraries for models and data library(orcutt) # fit model and summarize results reg <- lm(mpg ~ wt + qsec + disp, mtcars) tidy(reg) co <- cochrane.orcutt(reg) tidy(co) glance(co)
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'pairwise.htest' tidy(x, ...)
## S3 method for class 'pairwise.htest' tidy(x, ...)
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Note that in one-sided tests, the alternative hypothesis of each test can be stated as "group1 is greater/less than group2".
Note also that the columns of group1 and group2 will always be a factor, even if the original input is (e.g.) numeric.
A tibble::tibble()
with columns:
group1 |
First group being compared. |
group2 |
Second group being compared. |
p.value |
The two-sided p-value associated with the observed statistic. |
stats::pairwise.t.test()
, stats::pairwise.wilcox.test()
,
tidy()
Other htest tidiers:
augment.htest()
,
tidy.htest()
,
tidy.power.htest()
attach(airquality) Month <- factor(Month, labels = month.abb[5:9]) ptt <- pairwise.t.test(Ozone, Month) tidy(ptt) library(modeldata) data(hpc_data) attach(hpc_data) ptt2 <- pairwise.t.test(compounds, class) tidy(ptt2) tidy(pairwise.t.test(compounds, class, alternative = "greater")) tidy(pairwise.t.test(compounds, class, alternative = "less")) tidy(pairwise.wilcox.test(compounds, class))
attach(airquality) Month <- factor(Month, labels = month.abb[5:9]) ptt <- pairwise.t.test(Ozone, Month) tidy(ptt) library(modeldata) data(hpc_data) attach(hpc_data) ptt2 <- pairwise.t.test(compounds, class) tidy(ptt2) tidy(pairwise.t.test(compounds, class, alternative = "greater")) tidy(pairwise.t.test(compounds, class, alternative = "less")) tidy(pairwise.wilcox.test(compounds, class))
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'pam' tidy(x, col.names = paste0("x", 1:ncol(x$medoids)), ...)
## S3 method for class 'pam' tidy(x, col.names = paste0("x", 1:ncol(x$medoids)), ...)
x |
An |
col.names |
Column names in the input data frame. Defaults to the names of the variables in x. |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
For examples, see the pam vignette.
A tibble::tibble()
with columns:
size |
Size of each cluster. |
max.diss |
Maximal dissimilarity between the observations in the cluster and that cluster's medoid. |
avg.diss |
Average dissimilarity between the observations in the cluster and that cluster's medoid. |
diameter |
Diameter of the cluster. |
separation |
Separation of the cluster. |
avg.width |
Average silhouette width of the cluster. |
cluster |
A factor describing the cluster from 1:k. |
Other pam tidiers:
augment.pam()
,
glance.pam()
# load libraries for models and data library(dplyr) library(ggplot2) library(cluster) library(modeldata) data(hpc_data) x <- hpc_data[, 2:5] p <- pam(x, k = 4) # summarize model fit with tidiers + visualization tidy(p) glance(p) augment(p, x) augment(p, x) %>% ggplot(aes(compounds, input_fields)) + geom_point(aes(color = .cluster)) + geom_text(aes(label = cluster), data = tidy(p), size = 10)
# load libraries for models and data library(dplyr) library(ggplot2) library(cluster) library(modeldata) data(hpc_data) x <- hpc_data[, 2:5] p <- pam(x, k = 4) # summarize model fit with tidiers + visualization tidy(p) glance(p) augment(p, x) augment(p, x) %>% ggplot(aes(compounds, input_fields)) + geom_point(aes(color = .cluster)) + geom_text(aes(label = cluster), data = tidy(p), size = 10)
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'plm' tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
## S3 method for class 'plm' tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
x |
A |
conf.int |
Logical indicating whether or not to include a confidence
interval in the tidied output. Defaults to |
conf.level |
The confidence level to use for the confidence interval
if |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with columns:
conf.high |
Upper bound on the confidence interval for the estimate. |
conf.low |
Lower bound on the confidence interval for the estimate. |
estimate |
The estimated value of the regression term. |
p.value |
The two-sided p-value associated with the observed statistic. |
statistic |
The value of a T-statistic to use in a hypothesis that the regression term is non-zero. |
std.error |
The standard error of the regression term. |
term |
The name of the regression term. |
Other plm tidiers:
augment.plm()
,
glance.plm()
# load libraries for models and data library(plm) # load data data("Produc", package = "plm") # fit model zz <- plm(log(gsp) ~ log(pcap) + log(pc) + log(emp) + unemp, data = Produc, index = c("state", "year") ) # summarize model fit with tidiers summary(zz) tidy(zz) tidy(zz, conf.int = TRUE) tidy(zz, conf.int = TRUE, conf.level = 0.9) augment(zz) glance(zz)
# load libraries for models and data library(plm) # load data data("Produc", package = "plm") # fit model zz <- plm(log(gsp) ~ log(pcap) + log(pc) + log(emp) + unemp, data = Produc, index = c("state", "year") ) # summarize model fit with tidiers summary(zz) tidy(zz) tidy(zz, conf.int = TRUE) tidy(zz, conf.int = TRUE, conf.level = 0.9) augment(zz) glance(zz)
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'poLCA' tidy(x, ...)
## S3 method for class 'poLCA' tidy(x, ...)
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with columns:
class |
The class under consideration. |
outcome |
Outcome of manifest variable. |
std.error |
The standard error of the regression term. |
variable |
Manifest variable |
estimate |
Estimated class-conditional response probability |
Other poLCA tidiers:
augment.poLCA()
,
glance.poLCA()
# load libraries for models and data library(poLCA) library(dplyr) # generate data data(values) f <- cbind(A, B, C, D) ~ 1 # fit model M1 <- poLCA(f, values, nclass = 2, verbose = FALSE) M1 # summarize model fit with tidiers + visualization tidy(M1) augment(M1) glance(M1) library(ggplot2) ggplot(tidy(M1), aes(factor(class), estimate, fill = factor(outcome))) + geom_bar(stat = "identity", width = 1) + facet_wrap(~variable) # three-class model with a single covariate. data(election) f2a <- cbind( MORALG, CARESG, KNOWG, LEADG, DISHONG, INTELG, MORALB, CARESB, KNOWB, LEADB, DISHONB, INTELB ) ~ PARTY nes2a <- poLCA(f2a, election, nclass = 3, nrep = 5, verbose = FALSE) td <- tidy(nes2a) td ggplot(td, aes(outcome, estimate, color = factor(class), group = class)) + geom_line() + facet_wrap(~variable, nrow = 2) + theme(axis.text.x = element_text(angle = 90, hjust = 1)) au <- augment(nes2a) au count(au, .class) # if the original data is provided, it leads to NAs in new columns # for rows that weren't predicted au2 <- augment(nes2a, data = election) au2 dim(au2)
# load libraries for models and data library(poLCA) library(dplyr) # generate data data(values) f <- cbind(A, B, C, D) ~ 1 # fit model M1 <- poLCA(f, values, nclass = 2, verbose = FALSE) M1 # summarize model fit with tidiers + visualization tidy(M1) augment(M1) glance(M1) library(ggplot2) ggplot(tidy(M1), aes(factor(class), estimate, fill = factor(outcome))) + geom_bar(stat = "identity", width = 1) + facet_wrap(~variable) # three-class model with a single covariate. data(election) f2a <- cbind( MORALG, CARESG, KNOWG, LEADG, DISHONG, INTELG, MORALB, CARESB, KNOWB, LEADB, DISHONB, INTELB ) ~ PARTY nes2a <- poLCA(f2a, election, nclass = 3, nrep = 5, verbose = FALSE) td <- tidy(nes2a) td ggplot(td, aes(outcome, estimate, color = factor(class), group = class)) + geom_line() + facet_wrap(~variable, nrow = 2) + theme(axis.text.x = element_text(angle = 90, hjust = 1)) au <- augment(nes2a) au count(au, .class) # if the original data is provided, it leads to NAs in new columns # for rows that weren't predicted au2 <- augment(nes2a, data = election) au2 dim(au2)
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'polr' tidy( x, conf.int = FALSE, conf.level = 0.95, exponentiate = FALSE, p.values = FALSE, ... )
## S3 method for class 'polr' tidy( x, conf.int = FALSE, conf.level = 0.95, exponentiate = FALSE, p.values = FALSE, ... )
x |
A |
conf.int |
Logical indicating whether or not to include a confidence
interval in the tidied output. Defaults to |
conf.level |
The confidence level to use for the confidence interval
if |
exponentiate |
Logical indicating whether or not to exponentiate the
the coefficient estimates. This is typical for logistic and multinomial
regressions, but a bad idea if there is no log or logit link. Defaults
to |
p.values |
Logical. Should p-values be returned,
based on chi-squared tests from |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
In broom 0.7.0
the coefficient_type
column was renamed to
coef.type
, and the contents were changed as well. Now the contents
are coefficient
and scale
, rather than coefficient
and zeta
.
Calculating p.values with the dropterm()
function is the approach
suggested by the MASS package author. This
approach is computationally intensive so that p.values are only
returned if requested explicitly. Additionally, it only works for
models containing no variables with more than two categories. If this
condition is not met, a message is shown and NA is returned instead of
p-values.
A tibble::tibble()
with columns:
conf.high |
Upper bound on the confidence interval for the estimate. |
conf.low |
Lower bound on the confidence interval for the estimate. |
estimate |
The estimated value of the regression term. |
p.value |
The two-sided p-value associated with the observed statistic. |
statistic |
The value of a T-statistic to use in a hypothesis that the regression term is non-zero. |
std.error |
The standard error of the regression term. |
term |
The name of the regression term. |
Other ordinal tidiers:
augment.clm()
,
augment.polr()
,
glance.clm()
,
glance.clmm()
,
glance.polr()
,
glance.svyolr()
,
tidy.clm()
,
tidy.clmm()
,
tidy.svyolr()
# load libraries for models and data library(MASS) # fit model fit <- polr(Sat ~ Infl + Type + Cont, weights = Freq, data = housing) # summarize model fit with tidiers tidy(fit, exponentiate = TRUE, conf.int = TRUE) glance(fit) augment(fit, type.predict = "class") fit2 <- polr(factor(gear) ~ am + mpg + qsec, data = mtcars) tidy(fit, p.values = TRUE)
# load libraries for models and data library(MASS) # fit model fit <- polr(Sat ~ Infl + Type + Cont, weights = Freq, data = housing) # summarize model fit with tidiers tidy(fit, exponentiate = TRUE, conf.int = TRUE) glance(fit) augment(fit, type.predict = "class") fit2 <- polr(factor(gear) ~ am + mpg + qsec, data = mtcars) tidy(fit, p.values = TRUE)
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'power.htest' tidy(x, ...)
## S3 method for class 'power.htest' tidy(x, ...)
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with columns:
delta |
True difference in means. |
n |
Number of observations by component. |
power |
Power achieved for given value of n. |
sd |
Standard deviation. |
sig.level |
Significance level (Type I error probability). |
Other htest tidiers:
augment.htest()
,
tidy.htest()
,
tidy.pairwise.htest()
ptt <- power.t.test(n = 2:30, delta = 1) tidy(ptt) library(ggplot2) ggplot(tidy(ptt), aes(n, power)) + geom_line()
ptt <- power.t.test(n = 2:30, delta = 1) tidy(ptt) library(ggplot2) ggplot(tidy(ptt), aes(n, power)) + geom_line()
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'prcomp' tidy(x, matrix = "u", ...)
## S3 method for class 'prcomp' tidy(x, matrix = "u", ...)
x |
A |
matrix |
Character specifying which component of the PCA should be tidied.
|
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
See https://stats.stackexchange.com/questions/134282/relationship-between-svd-and-pca-how-to-use-svd-to-perform-pca for information on how to interpret the various tidied matrices. Note that SVD is only equivalent to PCA on centered data.
A tibble::tibble with columns depending on the component of PCA being tidied.
If matrix
is "u"
, "samples"
, "scores"
, or "x"
each row in the
tidied output corresponds to the original data in PCA space. The columns
are:
row |
ID of the original observation (i.e. rowname from original data). |
PC |
Integer indicating a principal component. |
value |
The score of the observation for that particular principal component. That is, the location of the observation in PCA space. |
If matrix
is "v"
, "rotation"
, "loadings"
or "variables"
, each
row in the tidied output corresponds to information about the principle
components in the original space. The columns are:
row |
The variable labels (colnames) of the data set on which PCA was performed. |
PC |
An integer vector indicating the principal component. |
value |
The value of the eigenvector (axis score) on the indicated principal component. |
If matrix
is "d"
, "eigenvalues"
or "pcs"
, the columns are:
PC |
An integer vector indicating the principal component. |
std.dev |
Standard deviation explained by this PC. |
percent |
Fraction of variation explained by this component (a numeric value between 0 and 1). |
cumulative |
Cumulative fraction of variation explained by principle components up to this component (a numeric value between 0 and 1). |
Other svd tidiers:
augment.prcomp()
,
tidy_irlba()
,
tidy_svd()
pc <- prcomp(USArrests, scale = TRUE) # information about rotation tidy(pc) # information about samples (states) tidy(pc, "samples") # information about PCs tidy(pc, "pcs") # state map library(dplyr) library(ggplot2) library(maps) pc %>% tidy(matrix = "samples") %>% mutate(region = tolower(row)) %>% inner_join(map_data("state"), by = "region") %>% ggplot(aes(long, lat, group = group, fill = value)) + geom_polygon() + facet_wrap(~PC) + theme_void() + ggtitle("Principal components of arrest data") au <- augment(pc, data = USArrests) au ggplot(au, aes(.fittedPC1, .fittedPC2)) + geom_point() + geom_text(aes(label = .rownames), vjust = 1, hjust = 1)
pc <- prcomp(USArrests, scale = TRUE) # information about rotation tidy(pc) # information about samples (states) tidy(pc, "samples") # information about PCs tidy(pc, "pcs") # state map library(dplyr) library(ggplot2) library(maps) pc %>% tidy(matrix = "samples") %>% mutate(region = tolower(row)) %>% inner_join(map_data("state"), by = "region") %>% ggplot(aes(long, lat, group = group, fill = value)) + geom_polygon() + facet_wrap(~PC) + theme_void() + ggtitle("Principal components of arrest data") au <- augment(pc, data = USArrests) au ggplot(au, aes(.fittedPC1, .fittedPC2)) + geom_point() + geom_text(aes(label = .rownames), vjust = 1, hjust = 1)
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'pyears' tidy(x, ...)
## S3 method for class 'pyears' tidy(x, ...)
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
expected
is only present in the output when if a ratetable
term is present.
If the data.frame = TRUE
argument is supplied to pyears
,
this is simply the contents of x$data
.
A tibble::tibble()
with columns:
expected |
Expected number of events. |
pyears |
Person-years of exposure. |
n |
number of subjects contributing time |
event |
observed number of events |
Other pyears tidiers:
glance.pyears()
Other survival tidiers:
augment.coxph()
,
augment.survreg()
,
glance.aareg()
,
glance.cch()
,
glance.coxph()
,
glance.pyears()
,
glance.survdiff()
,
glance.survexp()
,
glance.survfit()
,
glance.survreg()
,
tidy.aareg()
,
tidy.cch()
,
tidy.coxph()
,
tidy.survdiff()
,
tidy.survexp()
,
tidy.survfit()
,
tidy.survreg()
# load libraries for models and data library(survival) # generate and format data temp.yr <- tcut(mgus$dxyr, 55:92, labels = as.character(55:91)) temp.age <- tcut(mgus$age, 34:101, labels = as.character(34:100)) ptime <- ifelse(is.na(mgus$pctime), mgus$futime, mgus$pctime) pstat <- ifelse(is.na(mgus$pctime), 0, 1) pfit <- pyears(Surv(ptime / 365.25, pstat) ~ temp.yr + temp.age + sex, mgus, data.frame = TRUE ) # summarize model fit with tidiers tidy(pfit) glance(pfit) # if data.frame argument is not given, different information is present in # output pfit2 <- pyears(Surv(ptime / 365.25, pstat) ~ temp.yr + temp.age + sex, mgus) tidy(pfit2) glance(pfit2)
# load libraries for models and data library(survival) # generate and format data temp.yr <- tcut(mgus$dxyr, 55:92, labels = as.character(55:91)) temp.age <- tcut(mgus$age, 34:101, labels = as.character(34:100)) ptime <- ifelse(is.na(mgus$pctime), mgus$futime, mgus$pctime) pstat <- ifelse(is.na(mgus$pctime), 0, 1) pfit <- pyears(Surv(ptime / 365.25, pstat) ~ temp.yr + temp.age + sex, mgus, data.frame = TRUE ) # summarize model fit with tidiers tidy(pfit) glance(pfit) # if data.frame argument is not given, different information is present in # output pfit2 <- pyears(Surv(ptime / 365.25, pstat) ~ temp.yr + temp.age + sex, mgus) tidy(pfit2) glance(pfit2)
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'rcorr' tidy(x, diagonal = FALSE, ...)
## S3 method for class 'rcorr' tidy(x, diagonal = FALSE, ...)
x |
An |
diagonal |
Logical indicating whether or not to include diagonal
elements of the correlation matrix, or the correlation of a column with
itself. For the elements, |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Suppose the original data has columns A and B. In the correlation
matrix from rcorr
there may be entries for both the cor(A, B)
and
cor(B, A)
. Only one of these pairs will ever be present in the tidy
output.
A tibble::tibble()
with columns:
column1 |
Name or index of the first column being described. |
column2 |
Name or index of the second column being described. |
estimate |
The estimated value of the regression term. |
p.value |
The two-sided p-value associated with the observed statistic. |
n |
Number of observations used to compute the correlation |
# load libraries for models and data library(Hmisc) mat <- replicate(52, rnorm(100)) # add some NAs mat[sample(length(mat), 2000)] <- NA # also, column names colnames(mat) <- c(LETTERS, letters) # fit model rc <- rcorr(mat) # summarize model fit with tidiers + visualization td <- tidy(rc) td library(ggplot2) ggplot(td, aes(p.value)) + geom_histogram(binwidth = .1) ggplot(td, aes(estimate, p.value)) + geom_point() + scale_y_log10()
# load libraries for models and data library(Hmisc) mat <- replicate(52, rnorm(100)) # add some NAs mat[sample(length(mat), 2000)] <- NA # also, column names colnames(mat) <- c(LETTERS, letters) # fit model rc <- rcorr(mat) # summarize model fit with tidiers + visualization td <- tidy(rc) td library(ggplot2) ggplot(td, aes(p.value)) + geom_histogram(binwidth = .1) ggplot(td, aes(estimate, p.value)) + geom_point() + scale_y_log10()
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'ref.grid' tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
## S3 method for class 'ref.grid' tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
x |
A |
conf.int |
Logical indicating whether or not to include a confidence
interval in the tidied output. Defaults to |
conf.level |
The confidence level to use for the confidence interval
if |
... |
Additional arguments passed to |
Returns a data frame with one observation for each estimated marginal mean, and one column for each combination of factors. When the input is a contrast, each row will contain one estimated contrast.
There are a large number of arguments that can be
passed on to emmeans::summary.emmGrid()
or lsmeans::summary.ref.grid()
.
A tibble::tibble()
with columns:
conf.high |
Upper bound on the confidence interval for the estimate. |
conf.low |
Lower bound on the confidence interval for the estimate. |
df |
Degrees of freedom used by this term in the model. |
p.value |
The two-sided p-value associated with the observed statistic. |
std.error |
The standard error of the regression term. |
estimate |
Expected marginal mean |
statistic |
T-ratio statistic |
tidy()
, emmeans::ref_grid()
, emmeans::emmeans()
,
emmeans::contrast()
Other emmeans tidiers:
tidy.emmGrid()
,
tidy.lsmobj()
,
tidy.summary_emm()
# load libraries for models and data library(emmeans) # linear model for sales of oranges per day oranges_lm1 <- lm(sales1 ~ price1 + price2 + day + store, data = oranges) # reference grid; see vignette("basics", package = "emmeans") oranges_rg1 <- ref_grid(oranges_lm1) td <- tidy(oranges_rg1) td # marginal averages marginal <- emmeans(oranges_rg1, "day") tidy(marginal) # contrasts tidy(contrast(marginal)) tidy(contrast(marginal, method = "pairwise")) # plot confidence intervals library(ggplot2) ggplot(tidy(marginal, conf.int = TRUE), aes(day, estimate)) + geom_point() + geom_errorbar(aes(ymin = conf.low, ymax = conf.high)) # by multiple prices by_price <- emmeans(oranges_lm1, "day", by = "price2", at = list( price1 = 50, price2 = c(40, 60, 80), day = c("2", "3", "4") ) ) by_price tidy(by_price) ggplot(tidy(by_price, conf.int = TRUE), aes(price2, estimate, color = day)) + geom_line() + geom_errorbar(aes(ymin = conf.low, ymax = conf.high)) # joint_tests tidy(joint_tests(oranges_lm1))
# load libraries for models and data library(emmeans) # linear model for sales of oranges per day oranges_lm1 <- lm(sales1 ~ price1 + price2 + day + store, data = oranges) # reference grid; see vignette("basics", package = "emmeans") oranges_rg1 <- ref_grid(oranges_lm1) td <- tidy(oranges_rg1) td # marginal averages marginal <- emmeans(oranges_rg1, "day") tidy(marginal) # contrasts tidy(contrast(marginal)) tidy(contrast(marginal, method = "pairwise")) # plot confidence intervals library(ggplot2) ggplot(tidy(marginal, conf.int = TRUE), aes(day, estimate)) + geom_point() + geom_errorbar(aes(ymin = conf.low, ymax = conf.high)) # by multiple prices by_price <- emmeans(oranges_lm1, "day", by = "price2", at = list( price1 = 50, price2 = c(40, 60, 80), day = c("2", "3", "4") ) ) by_price tidy(by_price) ggplot(tidy(by_price, conf.int = TRUE), aes(price2, estimate, color = day)) + geom_line() + geom_errorbar(aes(ymin = conf.low, ymax = conf.high)) # joint_tests tidy(joint_tests(oranges_lm1))
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'regsubsets' tidy(x, ...)
## S3 method for class 'regsubsets' tidy(x, ...)
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with columns:
r.squared |
R squared statistic, or the percent of variation explained by the model. |
adj.r.squared |
Adjusted R squared statistic |
BIC |
Bayesian information criterion for the component. |
mallows_cp |
Mallow's Cp statistic. |
# load libraries for models and data library(leaps) # fit model all_fits <- regsubsets(hp ~ ., mtcars) # summarize model fit with tidiers tidy(all_fits)
# load libraries for models and data library(leaps) # fit model all_fits <- regsubsets(hp ~ ., mtcars) # summarize model fit with tidiers tidy(all_fits)
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'ridgelm' tidy(x, ...)
## S3 method for class 'ridgelm' tidy(x, ...)
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with columns:
GCV |
Generalized cross validation error estimate. |
lambda |
Value of penalty parameter lambda. |
term |
The name of the regression term. |
estimate |
estimate of scaled coefficient using this lambda |
scale |
Scaling factor of estimated coefficient |
Other ridgelm tidiers:
glance.ridgelm()
# load libraries for models and data library(MASS) names(longley)[1] <- "y" # fit model and summarizd results fit1 <- lm.ridge(y ~ ., longley) tidy(fit1) fit2 <- lm.ridge(y ~ ., longley, lambda = seq(0.001, .05, .001)) td2 <- tidy(fit2) g2 <- glance(fit2) # coefficient plot library(ggplot2) ggplot(td2, aes(lambda, estimate, color = term)) + geom_line() # GCV plot ggplot(td2, aes(lambda, GCV)) + geom_line() # add line for the GCV minimizing estimate ggplot(td2, aes(lambda, GCV)) + geom_line() + geom_vline(xintercept = g2$lambdaGCV, col = "red", lty = 2)
# load libraries for models and data library(MASS) names(longley)[1] <- "y" # fit model and summarizd results fit1 <- lm.ridge(y ~ ., longley) tidy(fit1) fit2 <- lm.ridge(y ~ ., longley, lambda = seq(0.001, .05, .001)) td2 <- tidy(fit2) g2 <- glance(fit2) # coefficient plot library(ggplot2) ggplot(td2, aes(lambda, estimate, color = term)) + geom_line() # GCV plot ggplot(td2, aes(lambda, GCV)) + geom_line() # add line for the GCV minimizing estimate ggplot(td2, aes(lambda, GCV)) + geom_line() + geom_vline(xintercept = g2$lambdaGCV, col = "red", lty = 2)
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'rlm' tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
## S3 method for class 'rlm' tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
x |
An |
conf.int |
Logical indicating whether or not to include a confidence
interval in the tidied output. Defaults to |
conf.level |
The confidence level to use for the confidence interval
if |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Other rlm tidiers:
augment.rlm()
,
glance.rlm()
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'rma' tidy( x, conf.int = FALSE, conf.level = 0.95, exponentiate = FALSE, include_studies = FALSE, measure = "GEN", ... )
## S3 method for class 'rma' tidy( x, conf.int = FALSE, conf.level = 0.95, exponentiate = FALSE, include_studies = FALSE, measure = "GEN", ... )
x |
An |
conf.int |
Logical indicating whether or not to include a confidence
interval in the tidied output. Defaults to |
conf.level |
The confidence level to use for the confidence interval
if |
exponentiate |
Logical indicating whether or not to exponentiate the
the coefficient estimates. This is typical for logistic and multinomial
regressions, but a bad idea if there is no log or logit link. Defaults
to |
include_studies |
Logical. Should individual studies be included in the
output? Defaults to |
measure |
Measure type. See |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with columns:
conf.high |
Upper bound on the confidence interval for the estimate. |
conf.low |
Lower bound on the confidence interval for the estimate. |
estimate |
The estimated value of the regression term. |
p.value |
The two-sided p-value associated with the observed statistic. |
statistic |
The value of a T-statistic to use in a hypothesis that the regression term is non-zero. |
std.error |
The standard error of the regression term. |
term |
The name of the individual study |
type |
The estimate type (summary vs individual study) |
# load libraries for models and data library(metafor) df <- escalc( measure = "RR", ai = tpos, bi = tneg, ci = cpos, di = cneg, data = dat.bcg ) meta_analysis <- rma(yi, vi, data = df, method = "EB") tidy(meta_analysis)
# load libraries for models and data library(metafor) df <- escalc( measure = "RR", ai = tpos, bi = tneg, ci = cpos, di = cneg, data = dat.bcg ) meta_analysis <- rma(yi, vi, data = df, method = "EB") tidy(meta_analysis)
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'roc' tidy(x, ...)
## S3 method for class 'roc' tidy(x, ...)
x |
An |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with columns:
cutoff |
The cutoff used for classification. Observations with predicted probabilities above this value were assigned class 1, and observations with predicted probabilities below this value were assigned class 0. |
fpr |
False positive rate. |
tpr |
The true positive rate at the given cutoff. |
# load libraries for models and data library(AUC) # load data data(churn) # fit model r <- roc(churn$predictions, churn$labels) # summarize with tidiers + visualization td <- tidy(r) td library(ggplot2) ggplot(td, aes(fpr, tpr)) + geom_line() # compare the ROC curves for two prediction algorithms library(dplyr) library(tidyr) rocs <- churn %>% pivot_longer(contains("predictions"), names_to = "algorithm", values_to = "value" ) %>% nest(data = -algorithm) %>% mutate(tidy_roc = purrr::map(data, ~ tidy(roc(.x$value, .x$labels)))) %>% unnest(tidy_roc) ggplot(rocs, aes(fpr, tpr, color = algorithm)) + geom_line()
# load libraries for models and data library(AUC) # load data data(churn) # fit model r <- roc(churn$predictions, churn$labels) # summarize with tidiers + visualization td <- tidy(r) td library(ggplot2) ggplot(td, aes(fpr, tpr)) + geom_line() # compare the ROC curves for two prediction algorithms library(dplyr) library(tidyr) rocs <- churn %>% pivot_longer(contains("predictions"), names_to = "algorithm", values_to = "value" ) %>% nest(data = -algorithm) %>% mutate(tidy_roc = purrr::map(data, ~ tidy(roc(.x$value, .x$labels)))) %>% unnest(tidy_roc) ggplot(rocs, aes(fpr, tpr, color = algorithm)) + geom_line()
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'rq' tidy(x, se.type = NULL, conf.int = FALSE, conf.level = 0.95, ...)
## S3 method for class 'rq' tidy(x, se.type = NULL, conf.int = FALSE, conf.level = 0.95, ...)
x |
An |
se.type |
Character specifying the method to use to calculate
standard errors. Passed to |
conf.int |
Logical indicating whether or not to include a confidence
interval in the tidied output. Defaults to |
conf.level |
The confidence level to use for the confidence interval
if |
... |
Additional arguments passed to |
If se.type = "rank"
confidence intervals are calculated by
summary.rq
and statistic
and p.value
values are not returned.
When only a single predictor is included in the model,
no confidence intervals are calculated and the confidence limits are
set to NA.
A tibble::tibble()
with columns:
conf.high |
Upper bound on the confidence interval for the estimate. |
conf.low |
Lower bound on the confidence interval for the estimate. |
estimate |
The estimated value of the regression term. |
p.value |
The two-sided p-value associated with the observed statistic. |
statistic |
The value of a T-statistic to use in a hypothesis that the regression term is non-zero. |
std.error |
The standard error of the regression term. |
term |
The name of the regression term. |
Other quantreg tidiers:
augment.nlrq()
,
augment.rq()
,
augment.rqs()
,
glance.nlrq()
,
glance.rq()
,
tidy.nlrq()
,
tidy.rqs()
# load modeling library and data library(quantreg) data(stackloss) # median (l1) regression fit for the stackloss data. mod1 <- rq(stack.loss ~ stack.x, .5) # weighted sample median mod2 <- rq(rnorm(50) ~ 1, weights = runif(50)) # summarize model fit with tidiers tidy(mod1) glance(mod1) augment(mod1) tidy(mod2) glance(mod2) augment(mod2) # varying tau to generate an rqs object mod3 <- rq(stack.loss ~ stack.x, tau = c(.25, .5)) tidy(mod3) augment(mod3) # glance cannot handle rqs objects like `mod3`--use a purrr # `map`-based workflow instead
# load modeling library and data library(quantreg) data(stackloss) # median (l1) regression fit for the stackloss data. mod1 <- rq(stack.loss ~ stack.x, .5) # weighted sample median mod2 <- rq(rnorm(50) ~ 1, weights = runif(50)) # summarize model fit with tidiers tidy(mod1) glance(mod1) augment(mod1) tidy(mod2) glance(mod2) augment(mod2) # varying tau to generate an rqs object mod3 <- rq(stack.loss ~ stack.x, tau = c(.25, .5)) tidy(mod3) augment(mod3) # glance cannot handle rqs objects like `mod3`--use a purrr # `map`-based workflow instead
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'rqs' tidy(x, se.type = "rank", conf.int = FALSE, conf.level = 0.95, ...)
## S3 method for class 'rqs' tidy(x, se.type = "rank", conf.int = FALSE, conf.level = 0.95, ...)
x |
An |
se.type |
Character specifying the method to use to calculate
standard errors. Passed to |
conf.int |
Logical indicating whether or not to include a confidence
interval in the tidied output. Defaults to |
conf.level |
The confidence level to use for the confidence interval
if |
... |
Additional arguments passed to |
If se.type = "rank"
confidence intervals are calculated by
summary.rq
. When only a single predictor is included in the model,
no confidence intervals are calculated and the confidence limits are
set to NA.
A tibble::tibble()
with columns:
conf.high |
Upper bound on the confidence interval for the estimate. |
conf.low |
Lower bound on the confidence interval for the estimate. |
estimate |
The estimated value of the regression term. |
p.value |
The two-sided p-value associated with the observed statistic. |
statistic |
The value of a T-statistic to use in a hypothesis that the regression term is non-zero. |
std.error |
The standard error of the regression term. |
term |
The name of the regression term. |
quantile |
Linear conditional quantile. |
Other quantreg tidiers:
augment.nlrq()
,
augment.rq()
,
augment.rqs()
,
glance.nlrq()
,
glance.rq()
,
tidy.nlrq()
,
tidy.rq()
# load modeling library and data library(quantreg) data(stackloss) # median (l1) regression fit for the stackloss data. mod1 <- rq(stack.loss ~ stack.x, .5) # weighted sample median mod2 <- rq(rnorm(50) ~ 1, weights = runif(50)) # summarize model fit with tidiers tidy(mod1) glance(mod1) augment(mod1) tidy(mod2) glance(mod2) augment(mod2) # varying tau to generate an rqs object mod3 <- rq(stack.loss ~ stack.x, tau = c(.25, .5)) tidy(mod3) augment(mod3) # glance cannot handle rqs objects like `mod3`--use a purrr # `map`-based workflow instead
# load modeling library and data library(quantreg) data(stackloss) # median (l1) regression fit for the stackloss data. mod1 <- rq(stack.loss ~ stack.x, .5) # weighted sample median mod2 <- rq(rnorm(50) ~ 1, weights = runif(50)) # summarize model fit with tidiers tidy(mod1) glance(mod1) augment(mod1) tidy(mod2) glance(mod2) augment(mod2) # varying tau to generate an rqs object mod3 <- rq(stack.loss ~ stack.x, tau = c(.25, .5)) tidy(mod3) augment(mod3) # glance cannot handle rqs objects like `mod3`--use a purrr # `map`-based workflow instead
These methods tidy the coefficients of spatial autoregression
models generated by functions in the spatialreg
package.
## S3 method for class 'sarlm' tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
## S3 method for class 'sarlm' tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
x |
An object returned from |
conf.int |
Logical indicating whether or not to include a confidence
interval in the tidied output. Defaults to |
conf.level |
The confidence level to use for the confidence interval
if |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with columns:
conf.high |
Upper bound on the confidence interval for the estimate. |
conf.low |
Lower bound on the confidence interval for the estimate. |
estimate |
The estimated value of the regression term. |
p.value |
The two-sided p-value associated with the observed statistic. |
statistic |
The value of a T-statistic to use in a hypothesis that the regression term is non-zero. |
std.error |
The standard error of the regression term. |
term |
The name of the regression term. |
tidy()
, spatialreg::lagsarlm()
, spatialreg::errorsarlm()
,
spatialreg::sacsarlm()
Other spatialreg tidiers:
augment.sarlm()
,
glance.sarlm()
# load libraries for models and data library(spatialreg) library(spdep) # load data data(oldcol, package = "spdep") listw <- nb2listw(COL.nb, style = "W") # fit model crime_sar <- lagsarlm(CRIME ~ INC + HOVAL, data = COL.OLD, listw = listw, method = "eigen" ) # summarize model fit with tidiers tidy(crime_sar) tidy(crime_sar, conf.int = TRUE) glance(crime_sar) augment(crime_sar) # fit another model crime_sem <- errorsarlm(CRIME ~ INC + HOVAL, data = COL.OLD, listw) # summarize model fit with tidiers tidy(crime_sem) tidy(crime_sem, conf.int = TRUE) glance(crime_sem) augment(crime_sem) # fit another model crime_sac <- sacsarlm(CRIME ~ INC + HOVAL, data = COL.OLD, listw) # summarize model fit with tidiers tidy(crime_sac) tidy(crime_sac, conf.int = TRUE) glance(crime_sac) augment(crime_sac)
# load libraries for models and data library(spatialreg) library(spdep) # load data data(oldcol, package = "spdep") listw <- nb2listw(COL.nb, style = "W") # fit model crime_sar <- lagsarlm(CRIME ~ INC + HOVAL, data = COL.OLD, listw = listw, method = "eigen" ) # summarize model fit with tidiers tidy(crime_sar) tidy(crime_sar, conf.int = TRUE) glance(crime_sar) augment(crime_sar) # fit another model crime_sem <- errorsarlm(CRIME ~ INC + HOVAL, data = COL.OLD, listw) # summarize model fit with tidiers tidy(crime_sem) tidy(crime_sem, conf.int = TRUE) glance(crime_sem) augment(crime_sem) # fit another model crime_sac <- sacsarlm(CRIME ~ INC + HOVAL, data = COL.OLD, listw) # summarize model fit with tidiers tidy(crime_sac) tidy(crime_sac, conf.int = TRUE) glance(crime_sac) augment(crime_sac)
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'spec' tidy(x, ...)
## S3 method for class 'spec' tidy(x, ...)
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with columns:
freq |
Vector of frequencies at which the spectral density is estimated. |
spec |
Vector (for univariate series) or matrix (for multivariate series) of estimates of the spectral density at frequencies corresponding to freq. |
Other time series tidiers:
tidy.acf()
,
tidy.ts()
,
tidy.zoo()
spc <- spectrum(lh) tidy(spc) library(ggplot2) ggplot(tidy(spc), aes(freq, spec)) + geom_line()
spc <- spectrum(lh) tidy(spc) library(ggplot2) ggplot(tidy(spc), aes(freq, spec)) + geom_line()
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'speedglm' tidy(x, conf.int = FALSE, conf.level = 0.95, exponentiate = FALSE, ...)
## S3 method for class 'speedglm' tidy(x, conf.int = FALSE, conf.level = 0.95, exponentiate = FALSE, ...)
x |
A |
conf.int |
Logical indicating whether or not to include a confidence
interval in the tidied output. Defaults to |
conf.level |
The confidence level to use for the confidence interval
if |
exponentiate |
Logical indicating whether or not to exponentiate the
the coefficient estimates. This is typical for logistic and multinomial
regressions, but a bad idea if there is no log or logit link. Defaults
to |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with columns:
conf.high |
Upper bound on the confidence interval for the estimate. |
conf.low |
Lower bound on the confidence interval for the estimate. |
estimate |
The estimated value of the regression term. |
p.value |
The two-sided p-value associated with the observed statistic. |
statistic |
The value of a T-statistic to use in a hypothesis that the regression term is non-zero. |
std.error |
The standard error of the regression term. |
term |
The name of the regression term. |
Other speedlm tidiers:
augment.speedlm()
,
glance.speedglm()
,
glance.speedlm()
,
tidy.speedlm()
# load libraries for models and data library(speedglm) # generate data clotting <- data.frame( u = c(5, 10, 15, 20, 30, 40, 60, 80, 100), lot1 = c(118, 58, 42, 35, 27, 25, 21, 19, 18) ) # fit model fit <- speedglm(lot1 ~ log(u), data = clotting, family = Gamma(log)) # summarize model fit with tidiers tidy(fit) glance(fit)
# load libraries for models and data library(speedglm) # generate data clotting <- data.frame( u = c(5, 10, 15, 20, 30, 40, 60, 80, 100), lot1 = c(118, 58, 42, 35, 27, 25, 21, 19, 18) ) # fit model fit <- speedglm(lot1 ~ log(u), data = clotting, family = Gamma(log)) # summarize model fit with tidiers tidy(fit) glance(fit)
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'speedlm' tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
## S3 method for class 'speedlm' tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
x |
A |
conf.int |
Logical indicating whether or not to include a confidence
interval in the tidied output. Defaults to |
conf.level |
The confidence level to use for the confidence interval
if |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with columns:
conf.high |
Upper bound on the confidence interval for the estimate. |
conf.low |
Lower bound on the confidence interval for the estimate. |
estimate |
The estimated value of the regression term. |
p.value |
The two-sided p-value associated with the observed statistic. |
statistic |
The value of a T-statistic to use in a hypothesis that the regression term is non-zero. |
std.error |
The standard error of the regression term. |
term |
The name of the regression term. |
speedglm::speedlm()
, tidy.lm()
Other speedlm tidiers:
augment.speedlm()
,
glance.speedglm()
,
glance.speedlm()
,
tidy.speedglm()
# load modeling library library(speedglm) # fit model mod <- speedlm(mpg ~ wt + qsec, data = mtcars, fitted = TRUE) # summarize model fit with tidiers tidy(mod) glance(mod) augment(mod)
# load modeling library library(speedglm) # fit model mod <- speedlm(mpg ~ wt + qsec, data = mtcars, fitted = TRUE) # summarize model fit with tidiers tidy(mod) glance(mod) augment(mod)
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'summary_emm' tidy(x, null.value = NULL, ...)
## S3 method for class 'summary_emm' tidy(x, null.value = NULL, ...)
x |
A |
null.value |
Value to which estimate is compared. |
... |
Additional arguments passed to |
Returns a data frame with one observation for each estimated marginal mean, and one column for each combination of factors. When the input is a contrast, each row will contain one estimated contrast.
There are a large number of arguments that can be
passed on to emmeans::summary.emmGrid()
or lsmeans::summary.ref.grid()
.
A tibble::tibble()
with columns:
conf.high |
Upper bound on the confidence interval for the estimate. |
conf.low |
Lower bound on the confidence interval for the estimate. |
contrast |
Levels being compared. |
den.df |
Degrees of freedom of the denominator. |
df |
Degrees of freedom used by this term in the model. |
null.value |
Value to which the estimate is compared. |
num.df |
Degrees of freedom. |
p.value |
The two-sided p-value associated with the observed statistic. |
std.error |
The standard error of the regression term. |
level1 |
One level of the factor being contrasted |
level2 |
The other level of the factor being contrasted |
term |
Model term in joint tests |
estimate |
Expected marginal mean |
statistic |
T-ratio statistic or F-ratio statistic |
tidy()
, emmeans::ref_grid()
, emmeans::emmeans()
,
emmeans::contrast()
Other emmeans tidiers:
tidy.emmGrid()
,
tidy.lsmobj()
,
tidy.ref.grid()
# load libraries for models and data library(emmeans) # linear model for sales of oranges per day oranges_lm1 <- lm(sales1 ~ price1 + price2 + day + store, data = oranges) # reference grid; see vignette("basics", package = "emmeans") oranges_rg1 <- ref_grid(oranges_lm1) td <- tidy(oranges_rg1) td # marginal averages marginal <- emmeans(oranges_rg1, "day") tidy(marginal) # contrasts tidy(contrast(marginal)) tidy(contrast(marginal, method = "pairwise")) # plot confidence intervals library(ggplot2) ggplot(tidy(marginal, conf.int = TRUE), aes(day, estimate)) + geom_point() + geom_errorbar(aes(ymin = conf.low, ymax = conf.high)) # by multiple prices by_price <- emmeans(oranges_lm1, "day", by = "price2", at = list( price1 = 50, price2 = c(40, 60, 80), day = c("2", "3", "4") ) ) by_price tidy(by_price) ggplot(tidy(by_price, conf.int = TRUE), aes(price2, estimate, color = day)) + geom_line() + geom_errorbar(aes(ymin = conf.low, ymax = conf.high)) # joint_tests tidy(joint_tests(oranges_lm1))
# load libraries for models and data library(emmeans) # linear model for sales of oranges per day oranges_lm1 <- lm(sales1 ~ price1 + price2 + day + store, data = oranges) # reference grid; see vignette("basics", package = "emmeans") oranges_rg1 <- ref_grid(oranges_lm1) td <- tidy(oranges_rg1) td # marginal averages marginal <- emmeans(oranges_rg1, "day") tidy(marginal) # contrasts tidy(contrast(marginal)) tidy(contrast(marginal, method = "pairwise")) # plot confidence intervals library(ggplot2) ggplot(tidy(marginal, conf.int = TRUE), aes(day, estimate)) + geom_point() + geom_errorbar(aes(ymin = conf.low, ymax = conf.high)) # by multiple prices by_price <- emmeans(oranges_lm1, "day", by = "price2", at = list( price1 = 50, price2 = c(40, 60, 80), day = c("2", "3", "4") ) ) by_price tidy(by_price) ggplot(tidy(by_price, conf.int = TRUE), aes(price2, estimate, color = day)) + geom_line() + geom_errorbar(aes(ymin = conf.low, ymax = conf.high)) # joint_tests tidy(joint_tests(oranges_lm1))
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'summary.glht' tidy(x, ...)
## S3 method for class 'summary.glht' tidy(x, ...)
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with columns:
contrast |
Levels being compared. |
estimate |
The estimated value of the regression term. |
null.value |
Value to which the estimate is compared. |
p.value |
The two-sided p-value associated with the observed statistic. |
statistic |
The value of a T-statistic to use in a hypothesis that the regression term is non-zero. |
std.error |
The standard error of the regression term. |
tidy()
, multcomp::summary.glht()
, multcomp::glht()
Other multcomp tidiers:
tidy.cld()
,
tidy.confint.glht()
,
tidy.glht()
# load libraries for models and data library(multcomp) library(ggplot2) amod <- aov(breaks ~ wool + tension, data = warpbreaks) wht <- glht(amod, linfct = mcp(tension = "Tukey")) tidy(wht) ggplot(wht, aes(lhs, estimate)) + geom_point() CI <- confint(wht) tidy(CI) ggplot(CI, aes(lhs, estimate, ymin = lwr, ymax = upr)) + geom_pointrange() tidy(summary(wht)) ggplot(mapping = aes(lhs, estimate)) + geom_linerange(aes(ymin = lwr, ymax = upr), data = CI) + geom_point(aes(size = p), data = summary(wht)) + scale_size(trans = "reverse") cld <- cld(wht) tidy(cld)
# load libraries for models and data library(multcomp) library(ggplot2) amod <- aov(breaks ~ wool + tension, data = warpbreaks) wht <- glht(amod, linfct = mcp(tension = "Tukey")) tidy(wht) ggplot(wht, aes(lhs, estimate)) + geom_point() CI <- confint(wht) tidy(CI) ggplot(CI, aes(lhs, estimate, ymin = lwr, ymax = upr)) + geom_pointrange() tidy(summary(wht)) ggplot(mapping = aes(lhs, estimate)) + geom_linerange(aes(ymin = lwr, ymax = upr), data = CI) + geom_point(aes(size = p), data = summary(wht)) + scale_size(trans = "reverse") cld <- cld(wht) tidy(cld)
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'summary.lm' tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
## S3 method for class 'summary.lm' tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
x |
A |
conf.int |
Logical indicating whether or not to include a confidence
interval in the tidied output. Defaults to |
conf.level |
The confidence level to use for the confidence interval
if |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
The tidy.summary.lm()
method is a potentially useful alternative
to tidy.lm()
. For instance, if users have already converted large lm
objects into their leaner summary.lm
equivalents to conserve memory.
A tibble::tibble()
with columns:
conf.high |
Upper bound on the confidence interval for the estimate. |
conf.low |
Lower bound on the confidence interval for the estimate. |
estimate |
The estimated value of the regression term. |
p.value |
The two-sided p-value associated with the observed statistic. |
statistic |
The value of a T-statistic to use in a hypothesis that the regression term is non-zero. |
std.error |
The standard error of the regression term. |
term |
The name of the regression term. |
Other lm tidiers:
augment.glm()
,
augment.lm()
,
glance.glm()
,
glance.lm()
,
glance.summary.lm()
,
glance.svyglm()
,
tidy.glm()
,
tidy.lm()
,
tidy.lm.beta()
,
tidy.mlm()
# fit model mod <- lm(mpg ~ wt + qsec, data = mtcars) modsumm <- summary(mod) # summarize model fit with tidiers tidy(mod, conf.int = TRUE) # equivalent to the above tidy(modsumm, conf.int = TRUE) glance(mod) # mostly the same, except for a few missing columns glance(modsumm)
# fit model mod <- lm(mpg ~ wt + qsec, data = mtcars) modsumm <- summary(mod) # summarize model fit with tidiers tidy(mod, conf.int = TRUE) # equivalent to the above tidy(modsumm, conf.int = TRUE) glance(mod) # mostly the same, except for a few missing columns glance(modsumm)
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'survdiff' tidy(x, ...)
## S3 method for class 'survdiff' tidy(x, ...)
x |
An |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with columns:
exp |
Weighted expected number of events in each group. |
N |
Number of subjects in each group. |
obs |
weighted observed number of events in each group. |
Other survdiff tidiers:
glance.survdiff()
Other survival tidiers:
augment.coxph()
,
augment.survreg()
,
glance.aareg()
,
glance.cch()
,
glance.coxph()
,
glance.pyears()
,
glance.survdiff()
,
glance.survexp()
,
glance.survfit()
,
glance.survreg()
,
tidy.aareg()
,
tidy.cch()
,
tidy.coxph()
,
tidy.pyears()
,
tidy.survexp()
,
tidy.survfit()
,
tidy.survreg()
# load libraries for models and data library(survival) # fit model s <- survdiff( Surv(time, status) ~ pat.karno + strata(inst), data = lung ) # summarize model fit with tidiers tidy(s) glance(s)
# load libraries for models and data library(survival) # fit model s <- survdiff( Surv(time, status) ~ pat.karno + strata(inst), data = lung ) # summarize model fit with tidiers tidy(s) glance(s)
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'survexp' tidy(x, ...)
## S3 method for class 'survexp' tidy(x, ...)
x |
An |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with columns:
n.risk |
Number of individuals at risk at time zero. |
time |
Point in time. |
estimate |
Estimate survival |
Other survexp tidiers:
glance.survexp()
Other survival tidiers:
augment.coxph()
,
augment.survreg()
,
glance.aareg()
,
glance.cch()
,
glance.coxph()
,
glance.pyears()
,
glance.survdiff()
,
glance.survexp()
,
glance.survfit()
,
glance.survreg()
,
tidy.aareg()
,
tidy.cch()
,
tidy.coxph()
,
tidy.pyears()
,
tidy.survdiff()
,
tidy.survfit()
,
tidy.survreg()
# load libraries for models and data library(survival) # fit model sexpfit <- survexp( futime ~ 1, rmap = list( sex = "male", year = accept.dt, age = (accept.dt - birth.dt) ), method = "conditional", data = jasa ) # summarize model fit with tidiers tidy(sexpfit) glance(sexpfit)
# load libraries for models and data library(survival) # fit model sexpfit <- survexp( futime ~ 1, rmap = list( sex = "male", year = accept.dt, age = (accept.dt - birth.dt) ), method = "conditional", data = jasa ) # summarize model fit with tidiers tidy(sexpfit) glance(sexpfit)
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'survfit' tidy(x, ...)
## S3 method for class 'survfit' tidy(x, ...)
x |
An |
... |
For |
A tibble::tibble()
with columns:
conf.high |
Upper bound on the confidence interval for the estimate. |
conf.low |
Lower bound on the confidence interval for the estimate. |
n.censor |
Number of censored events. |
n.event |
Number of events at time t. |
n.risk |
Number of individuals at risk at time zero. |
std.error |
The standard error of the regression term. |
time |
Point in time. |
estimate |
estimate of survival or cumulative incidence rate when multistate |
state |
state if multistate survfit object input |
strata |
strata if stratified survfit object input |
Other survival tidiers:
augment.coxph()
,
augment.survreg()
,
glance.aareg()
,
glance.cch()
,
glance.coxph()
,
glance.pyears()
,
glance.survdiff()
,
glance.survexp()
,
glance.survfit()
,
glance.survreg()
,
tidy.aareg()
,
tidy.cch()
,
tidy.coxph()
,
tidy.pyears()
,
tidy.survdiff()
,
tidy.survexp()
,
tidy.survreg()
# load libraries for models and data library(survival) # fit model cfit <- coxph(Surv(time, status) ~ age + sex, lung) sfit <- survfit(cfit) # summarize model fit with tidiers + visualization tidy(sfit) glance(sfit) library(ggplot2) ggplot(tidy(sfit), aes(time, estimate)) + geom_line() + geom_ribbon(aes(ymin = conf.low, ymax = conf.high), alpha = .25) # multi-state fitCI <- survfit(Surv(stop, status * as.numeric(event), type = "mstate") ~ 1, data = mgus1, subset = (start == 0) ) td_multi <- tidy(fitCI) td_multi ggplot(td_multi, aes(time, estimate, group = state)) + geom_line(aes(color = state)) + geom_ribbon(aes(ymin = conf.low, ymax = conf.high), alpha = .25)
# load libraries for models and data library(survival) # fit model cfit <- coxph(Surv(time, status) ~ age + sex, lung) sfit <- survfit(cfit) # summarize model fit with tidiers + visualization tidy(sfit) glance(sfit) library(ggplot2) ggplot(tidy(sfit), aes(time, estimate)) + geom_line() + geom_ribbon(aes(ymin = conf.low, ymax = conf.high), alpha = .25) # multi-state fitCI <- survfit(Surv(stop, status * as.numeric(event), type = "mstate") ~ 1, data = mgus1, subset = (start == 0) ) td_multi <- tidy(fitCI) td_multi ggplot(td_multi, aes(time, estimate, group = state)) + geom_line(aes(color = state)) + geom_ribbon(aes(ymin = conf.low, ymax = conf.high), alpha = .25)
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'survreg' tidy(x, conf.level = 0.95, conf.int = FALSE, ...)
## S3 method for class 'survreg' tidy(x, conf.level = 0.95, conf.int = FALSE, ...)
x |
An |
conf.level |
The confidence level to use for the confidence interval
if |
conf.int |
Logical indicating whether or not to include a confidence
interval in the tidied output. Defaults to |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with columns:
conf.high |
Upper bound on the confidence interval for the estimate. |
conf.low |
Lower bound on the confidence interval for the estimate. |
estimate |
The estimated value of the regression term. |
p.value |
The two-sided p-value associated with the observed statistic. |
statistic |
The value of a T-statistic to use in a hypothesis that the regression term is non-zero. |
std.error |
The standard error of the regression term. |
term |
The name of the regression term. |
Other survreg tidiers:
augment.survreg()
,
glance.survreg()
Other survival tidiers:
augment.coxph()
,
augment.survreg()
,
glance.aareg()
,
glance.cch()
,
glance.coxph()
,
glance.pyears()
,
glance.survdiff()
,
glance.survexp()
,
glance.survfit()
,
glance.survreg()
,
tidy.aareg()
,
tidy.cch()
,
tidy.coxph()
,
tidy.pyears()
,
tidy.survdiff()
,
tidy.survexp()
,
tidy.survfit()
# load libraries for models and data library(survival) # fit model sr <- survreg( Surv(futime, fustat) ~ ecog.ps + rx, ovarian, dist = "exponential" ) # summarize model fit with tidiers + visualization tidy(sr) augment(sr, ovarian) glance(sr) # coefficient plot td <- tidy(sr, conf.int = TRUE) library(ggplot2) ggplot(td, aes(estimate, term)) + geom_point() + geom_errorbarh(aes(xmin = conf.low, xmax = conf.high), height = 0) + geom_vline(xintercept = 0)
# load libraries for models and data library(survival) # fit model sr <- survreg( Surv(futime, fustat) ~ ecog.ps + rx, ovarian, dist = "exponential" ) # summarize model fit with tidiers + visualization tidy(sr) augment(sr, ovarian) glance(sr) # coefficient plot td <- tidy(sr, conf.int = TRUE) library(ggplot2) ggplot(td, aes(estimate, term)) + geom_point() + geom_errorbarh(aes(xmin = conf.low, xmax = conf.high), height = 0) + geom_vline(xintercept = 0)
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'svyglm' tidy(x, conf.int = FALSE, conf.level = 0.95, exponentiate = FALSE, ...)
## S3 method for class 'svyglm' tidy(x, conf.int = FALSE, conf.level = 0.95, exponentiate = FALSE, ...)
x |
A |
conf.int |
Logical indicating whether or not to include a confidence
interval in the tidied output. Defaults to |
conf.level |
The confidence level to use for the confidence interval
if |
exponentiate |
Logical indicating whether or not to exponentiate the
the coefficient estimates. This is typical for logistic and multinomial
regressions, but a bad idea if there is no log or logit link. Defaults
to |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
survey::svyglm()
, stats::glm()
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'svyolr' tidy(x, conf.int = FALSE, conf.level = 0.95, exponentiate = FALSE, ...)
## S3 method for class 'svyolr' tidy(x, conf.int = FALSE, conf.level = 0.95, exponentiate = FALSE, ...)
x |
A |
conf.int |
Logical indicating whether or not to include a confidence
interval in the tidied output. Defaults to |
conf.level |
The confidence level to use for the confidence interval
if |
exponentiate |
Logical indicating whether or not to exponentiate the
the coefficient estimates. This is typical for logistic and multinomial
regressions, but a bad idea if there is no log or logit link. Defaults
to |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
The tidy.svyolr()
tidier is a light wrapper around
tidy.polr()
. However, the implementation for p-value calculation
in tidy.polr()
is both computationally intensive and specific to that
model, so the p.values
argument to tidy.svyolr()
is currently ignored,
and will raise a warning when passed.
A tibble::tibble()
with columns:
conf.high |
Upper bound on the confidence interval for the estimate. |
conf.low |
Lower bound on the confidence interval for the estimate. |
estimate |
The estimated value of the regression term. |
p.value |
The two-sided p-value associated with the observed statistic. |
statistic |
The value of a T-statistic to use in a hypothesis that the regression term is non-zero. |
std.error |
The standard error of the regression term. |
term |
The name of the regression term. |
Other ordinal tidiers:
augment.clm()
,
augment.polr()
,
glance.clm()
,
glance.clmm()
,
glance.polr()
,
glance.svyolr()
,
tidy.clm()
,
tidy.clmm()
,
tidy.polr()
library(broom) library(survey) data(api) dclus1 <- svydesign(id = ~dnum, weights = ~pw, data = apiclus1, fpc = ~fpc) dclus1 <- update(dclus1, mealcat = cut(meals, c(0, 25, 50, 75, 100))) m <- svyolr(mealcat ~ avg.ed + mobility + stype, design = dclus1) m tidy(m, conf.int = TRUE)
library(broom) library(survey) data(api) dclus1 <- svydesign(id = ~dnum, weights = ~pw, data = apiclus1, fpc = ~fpc) dclus1 <- update(dclus1, mealcat = cut(meals, c(0, 25, 50, 75, 100))) m <- svyolr(mealcat ~ avg.ed + mobility + stype, design = dclus1) m tidy(m, conf.int = TRUE)
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'systemfit' tidy(x, conf.int = TRUE, conf.level = 0.95, ...)
## S3 method for class 'systemfit' tidy(x, conf.int = TRUE, conf.level = 0.95, ...)
x |
A |
conf.int |
Logical indicating whether or not to include a confidence
interval in the tidied output. Defaults to |
conf.level |
The confidence level to use for the confidence interval
if |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
This tidy method works with any model objects of class systemfit
.
Default returns a tibble of six columns.
A tibble::tibble()
with columns:
conf.high |
Upper bound on the confidence interval for the estimate. |
conf.low |
Lower bound on the confidence interval for the estimate. |
estimate |
The estimated value of the regression term. |
p.value |
The two-sided p-value associated with the observed statistic. |
std.error |
The standard error of the regression term. |
term |
The name of the regression term. |
tidy()
, systemfit::systemfit()
set.seed(27) # load libraries for models and data library(systemfit) # generate data df <- data.frame( X = rnorm(100), Y = rnorm(100), Z = rnorm(100), W = rnorm(100) ) # fit model fit <- systemfit(formula = list(Y ~ Z, W ~ X), data = df, method = "SUR") # summarize model fit with tidiers tidy(fit) tidy(fit, conf.int = TRUE)
set.seed(27) # load libraries for models and data library(systemfit) # generate data df <- data.frame( X = rnorm(100), Y = rnorm(100), Z = rnorm(100), W = rnorm(100) ) # fit model fit <- systemfit(formula = list(Y ~ Z, W ~ X), data = df, method = "SUR") # summarize model fit with tidiers tidy(fit) tidy(fit, conf.int = TRUE)
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
Deprecated. Please use tibble::as_tibble()
instead.
## S3 method for class 'table' tidy(x, ...)
## S3 method for class 'table' tidy(x, ...)
x |
A base::table object. |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Directly calls tibble::as_tibble()
on a base::table object.
A tibble::tibble in long-form containing frequency information
for the table in a Freq
column. The result is much like what you get
from tidyr::pivot_longer()
.
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'ts' tidy(x, ...)
## S3 method for class 'ts' tidy(x, ...)
x |
A univariate or multivariate |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
series
column is only present for multivariate ts
objects.
A tibble::tibble()
with columns:
index |
Index (i.e. date or time) for a 'ts' or 'zoo' object. |
series |
Name of the series (present only for multivariate time series). |
value |
The value/estimate of the component. Results from data reshaping. |
Other time series tidiers:
tidy.acf()
,
tidy.spec()
,
tidy.zoo()
set.seed(678) tidy(ts(1:10, frequency = 4, start = c(1959, 2))) z <- ts(matrix(rnorm(300), 100, 3), start = c(1961, 1), frequency = 12) colnames(z) <- c("Aa", "Bb", "Cc") tidy(z)
set.seed(678) tidy(ts(1:10, frequency = 4, start = c(1959, 2))) z <- ts(matrix(rnorm(300), 100, 3), start = c(1961, 1), frequency = 12) colnames(z) <- c("Aa", "Bb", "Cc") tidy(z)
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'TukeyHSD' tidy(x, ...)
## S3 method for class 'TukeyHSD' tidy(x, ...)
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with columns:
adj.p.value |
P-value adjusted for multiple comparisons. |
conf.high |
Upper bound on the confidence interval for the estimate. |
conf.low |
Lower bound on the confidence interval for the estimate. |
contrast |
Levels being compared. |
estimate |
The estimated value of the regression term. |
null.value |
Value to which the estimate is compared. |
term |
The name of the regression term. |
Other anova tidiers:
glance.anova()
,
glance.aov()
,
tidy.anova()
,
tidy.aov()
,
tidy.aovlist()
,
tidy.manova()
fm1 <- aov(breaks ~ wool + tension, data = warpbreaks) thsd <- TukeyHSD(fm1, "tension", ordered = TRUE) tidy(thsd) # may include comparisons on multiple terms fm2 <- aov(mpg ~ as.factor(gear) * as.factor(cyl), data = mtcars) tidy(TukeyHSD(fm2))
fm1 <- aov(breaks ~ wool + tension, data = warpbreaks) thsd <- TukeyHSD(fm1, "tension", ordered = TRUE) tidy(thsd) # may include comparisons on multiple terms fm2 <- aov(mpg ~ as.factor(gear) * as.factor(cyl), data = mtcars) tidy(TukeyHSD(fm2))
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'varest' tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
## S3 method for class 'varest' tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
x |
A |
conf.int |
Logical indicating whether or not to include a confidence
interval in the tidied output. Defaults to |
conf.level |
The confidence level to use for the confidence interval
if |
... |
For |
The tibble has one row for each term in the regression. The
component
column indicates whether a particular
term was used to model either the "mean"
or "precision"
. Here the
precision is the inverse of the variance, often referred to as phi
.
At least one term will have been used to model the precision phi
.
The vars
package does not include a confint
method and does not report
confidence intervals for varest
objects. Setting the tidy
argument
conf.int = TRUE
will return a warning.
A tibble::tibble()
with columns:
conf.high |
Upper bound on the confidence interval for the estimate. |
conf.low |
Lower bound on the confidence interval for the estimate. |
estimate |
The estimated value of the regression term. |
p.value |
The two-sided p-value associated with the observed statistic. |
statistic |
The value of a T-statistic to use in a hypothesis that the regression term is non-zero. |
std.error |
The standard error of the regression term. |
term |
The name of the regression term. |
component |
Whether a particular term was used to model the mean or the precision in the regression. See details. |
# load libraries for models and data library(vars) # load data data("Canada", package = "vars") # fit models mod <- VAR(Canada, p = 1, type = "both") # summarize model fit with tidiers tidy(mod) glance(mod)
# load libraries for models and data library(vars) # load data data("Canada", package = "vars") # fit models mod <- VAR(Canada, p = 1, type = "both") # summarize model fit with tidiers tidy(mod) glance(mod)
Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies across models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.
## S3 method for class 'zoo' tidy(x, ...)
## S3 method for class 'zoo' tidy(x, ...)
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
A tibble::tibble()
with columns:
index |
Index (i.e. date or time) for a 'ts' or 'zoo' object. |
series |
Name of the series (present only for multivariate time series). |
value |
The value/estimate of the component. Results from data reshaping. |
Other time series tidiers:
tidy.acf()
,
tidy.spec()
,
tidy.ts()
# load libraries for models and data library(zoo) library(ggplot2) set.seed(1071) # generate data Z.index <- as.Date(sample(12450:12500, 10)) Z.data <- matrix(rnorm(30), ncol = 3) colnames(Z.data) <- c("Aa", "Bb", "Cc") Z <- zoo(Z.data, Z.index) # summarize model fit with tidiers + visualization tidy(Z) ggplot(tidy(Z), aes(index, value, color = series)) + geom_line() ggplot(tidy(Z), aes(index, value)) + geom_line() + facet_wrap(~series, ncol = 1) Zrolled <- rollmean(Z, 5) ggplot(tidy(Zrolled), aes(index, value, color = series)) + geom_line()
# load libraries for models and data library(zoo) library(ggplot2) set.seed(1071) # generate data Z.index <- as.Date(sample(12450:12500, 10)) Z.data <- matrix(rnorm(30), ncol = 3) colnames(Z.data) <- c("Aa", "Bb", "Cc") Z <- zoo(Z.data, Z.index) # summarize model fit with tidiers + visualization tidy(Z) ggplot(tidy(Z), aes(index, value, color = series)) + geom_line() ggplot(tidy(Z), aes(index, value)) + geom_line() + facet_wrap(~series, ncol = 1) Zrolled <- rollmean(Z, 5) ggplot(tidy(Zrolled), aes(index, value, color = series)) + geom_line()