Type: | Package |
Title: | Convert Statistical Objects into Tidy Tibbles |
Version: | 1.0.7 |
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. |
License: | MIT + file LICENSE |
URL: | https://broom.tidymodels.org/, https://github.com/tidymodels/broom |
BugReports: | https://github.com/tidymodels/broom/issues |
Depends: | R (≥ 3.5) |
Imports: | backports, dplyr (≥ 1.0.0), generics (≥ 0.0.2), glue, lifecycle, purrr, rlang, stringr, tibble (≥ 3.0.0), tidyr (≥ 1.0.0) |
Suggests: | AER, AUC, bbmle, betareg (≥ 3.2-1), biglm, binGroup, boot, btergm (≥ 1.10.6), car (≥ 3.1-2), carData, caret, cluster, cmprsk, coda, covr, drc, e1071, emmeans, epiR, ergm (≥ 3.10.4), fixest (≥ 0.9.0), gam (≥ 1.15), gee, geepack, ggplot2, glmnet, glmnetUtils, gmm, Hmisc, irlba, interp, joineRML, Kendall, knitr, ks, Lahman, lavaan (≥ 0.6.18), leaps, lfe, lm.beta, lme4, lmodel2, lmtest (≥ 0.9.38), lsmeans, maps, margins, MASS, mclust, mediation, metafor, mfx, mgcv, mlogit, modeldata, modeltests (≥ 0.1.6), muhaz, multcomp, network, nnet, orcutt (≥ 2.2), ordinal, plm, poLCA, psych, quantreg, rmarkdown, robust, robustbase, rsample, sandwich, spdep (≥ 1.1), spatialreg, speedglm, spelling, survey, survival (≥ 3.6-4), systemfit, testthat (≥ 2.1.0), tseries, vars, zoo |
VignetteBuilder: | knitr |
Config/Needs/website: | tidyverse/tidytemplate |
Encoding: | UTF-8 |
RoxygenNote: | 7.3.2 |
Language: | en-US |
Collate: | 'aaa-documentation-helper.R' 'null-and-default-tidiers.R' 'aer-tidiers.R' 'auc-tidiers.R' 'base-tidiers.R' 'bbmle-tidiers.R' 'betareg-tidiers.R' 'biglm-tidiers.R' 'bingroup-tidiers.R' 'boot-tidiers.R' 'broom-package.R' 'broom.R' 'btergm-tidiers.R' 'car-tidiers.R' 'caret-tidiers.R' 'cluster-tidiers.R' 'cmprsk-tidiers.R' 'data-frame-tidiers.R' 'deprecated-0-7-0.R' 'drc-tidiers.R' 'emmeans-tidiers.R' 'epiR-tidiers.R' 'ergm-tidiers.R' 'fixest-tidiers.R' 'gam-tidiers.R' 'geepack-tidiers.R' 'glmnet-cv-glmnet-tidiers.R' 'glmnet-glmnet-tidiers.R' 'gmm-tidiers.R' 'hmisc-tidiers.R' 'joinerml-tidiers.R' 'kendall-tidiers.R' 'ks-tidiers.R' 'lavaan-tidiers.R' 'leaps-tidiers.R' 'lfe-tidiers.R' 'list-irlba.R' 'list-optim-tidiers.R' 'list-svd-tidiers.R' 'list-tidiers.R' 'list-xyz-tidiers.R' 'lm-beta-tidiers.R' 'lmodel2-tidiers.R' 'lmtest-tidiers.R' 'maps-tidiers.R' 'margins-tidiers.R' 'mass-fitdistr-tidiers.R' 'mass-negbin-tidiers.R' 'mass-polr-tidiers.R' 'mass-ridgelm-tidiers.R' 'stats-lm-tidiers.R' 'mass-rlm-tidiers.R' 'mclust-tidiers.R' 'mediation-tidiers.R' 'metafor-tidiers.R' 'mfx-tidiers.R' 'mgcv-tidiers.R' 'mlogit-tidiers.R' 'muhaz-tidiers.R' 'multcomp-tidiers.R' 'nnet-tidiers.R' 'nobs.R' 'orcutt-tidiers.R' 'ordinal-clm-tidiers.R' 'ordinal-clmm-tidiers.R' 'plm-tidiers.R' 'polca-tidiers.R' 'psych-tidiers.R' 'stats-nls-tidiers.R' 'quantreg-nlrq-tidiers.R' 'quantreg-rq-tidiers.R' 'quantreg-rqs-tidiers.R' 'robust-glmrob-tidiers.R' 'robust-lmrob-tidiers.R' 'robustbase-glmrob-tidiers.R' 'robustbase-lmrob-tidiers.R' 'sp-tidiers.R' 'spdep-tidiers.R' 'speedglm-speedglm-tidiers.R' 'speedglm-speedlm-tidiers.R' 'stats-anova-tidiers.R' 'stats-arima-tidiers.R' 'stats-decompose-tidiers.R' 'stats-factanal-tidiers.R' 'stats-glm-tidiers.R' 'stats-htest-tidiers.R' 'stats-kmeans-tidiers.R' 'stats-loess-tidiers.R' 'stats-mlm-tidiers.R' 'stats-prcomp-tidiers.R' 'stats-smooth.spline-tidiers.R' 'stats-summary-lm-tidiers.R' 'stats-time-series-tidiers.R' 'survey-tidiers.R' 'survival-aareg-tidiers.R' 'survival-cch-tidiers.R' 'survival-coxph-tidiers.R' 'survival-pyears-tidiers.R' 'survival-survdiff-tidiers.R' 'survival-survexp-tidiers.R' 'survival-survfit-tidiers.R' 'survival-survreg-tidiers.R' 'systemfit-tidiers.R' 'tseries-tidiers.R' 'utilities.R' 'vars-tidiers.R' 'zoo-tidiers.R' 'zzz.R' |
NeedsCompilation: | no |
Packaged: | 2024-09-26 19:48:33 UTC; simoncouch |
Author: | David Robinson [aut],
Alex Hayes |
Maintainer: | Simon Couch <simon.couch@posit.co> |
Repository: | CRAN |
Date/Publication: | 2024-09-26 21:00:13 UTC |
broom: Convert Statistical Objects into Tidy Tibbles
Description
Convert statistical analysis objects from R into tidy tibbles, so that they can more easily be combined, reshaped and otherwise processed with tools like dplyr, tidyr and ggplot2. The package provides three S3 generics: tidy, which summarizes a model's statistical findings such as coefficients of a regression; augment, which adds columns to the original data such as predictions, residuals and cluster assignments; and glance, which provides a one-row summary of model-level statistics.
Author(s)
Maintainer: Simon Couch simon.couch@posit.co (ORCID)
Authors:
David Robinson admiral.david@gmail.com
Alex Hayes alexpghayes@gmail.com (ORCID)
Other contributors:
Posit Software, PBC [copyright holder, funder]
Indrajeet Patil patilindrajeet.science@gmail.com (ORCID) [contributor]
Derek Chiu dchiu@bccrc.ca [contributor]
Matthieu Gomez mattg@princeton.edu [contributor]
Boris Demeshev boris.demeshev@gmail.com [contributor]
Dieter Menne dieter.menne@menne-biomed.de [contributor]
Benjamin Nutter nutter@battelle.org [contributor]
Luke Johnston luke.johnston@mail.utoronto.ca [contributor]
Ben Bolker bolker@mcmaster.ca [contributor]
Francois Briatte f.briatte@gmail.com [contributor]
Jeffrey Arnold jeffrey.arnold@gmail.com [contributor]
Jonah Gabry jsg2201@columbia.edu [contributor]
Luciano Selzer luciano.selzer@gmail.com [contributor]
Gavin Simpson ucfagls@gmail.com [contributor]
Jens Preussner jens.preussner@mpi-bn.mpg.de [contributor]
Jay Hesselberth jay.hesselberth@gmail.com [contributor]
Hadley Wickham hadley@posit.co [contributor]
Matthew Lincoln matthew.d.lincoln@gmail.com [contributor]
Alessandro Gasparini ag475@leicester.ac.uk [contributor]
Lukasz Komsta lukasz.komsta@umlub.pl [contributor]
Frederick Novometsky [contributor]
Wilson Freitas [contributor]
Michelle Evans [contributor]
Jason Cory Brunson cornelioid@gmail.com [contributor]
Simon Jackson drsimonjackson@gmail.com [contributor]
Ben Whalley ben.whalley@plymouth.ac.uk [contributor]
Karissa Whiting karissa.whiting@gmail.com [contributor]
Yves Rosseel yrosseel@gmail.com [contributor]
Michael Kuehn mkuehn10@gmail.com [contributor]
Jorge Cimentada cimentadaj@gmail.com [contributor]
Erle Holgersen erle.holgersen@gmail.com [contributor]
Karl Dunkle Werner (ORCID) [contributor]
Ethan Christensen christensen.ej@gmail.com [contributor]
Steven Pav shabbychef@gmail.com [contributor]
Paul PJ pjpaul.stephens@gmail.com [contributor]
Ben Schneider benjamin.julius.schneider@gmail.com [contributor]
Patrick Kennedy pkqstr@protonmail.com [contributor]
Lily Medina lilymiru@gmail.com [contributor]
Brian Fannin captain@pirategrunt.com [contributor]
Jason Muhlenkamp jason.muhlenkamp@gmail.com [contributor]
Matt Lehman [contributor]
Bill Denney wdenney@humanpredictions.com (ORCID) [contributor]
Nic Crane [contributor]
Andrew Bates [contributor]
Vincent Arel-Bundock vincent.arel-bundock@umontreal.ca (ORCID) [contributor]
Hideaki Hayashi [contributor]
Luis Tobalina [contributor]
Annie Wang anniewang.uc@gmail.com [contributor]
Wei Yang Tham weiyang.tham@gmail.com [contributor]
Clara Wang clara.wang.94@gmail.com [contributor]
Abby Smith als1@u.northwestern.edu (ORCID) [contributor]
Jasper Cooper jaspercooper@gmail.com (ORCID) [contributor]
E Auden Krauska krauskae@gmail.com (ORCID) [contributor]
Alex Wang x249wang@uwaterloo.ca [contributor]
Malcolm Barrett malcolmbarrett@gmail.com (ORCID) [contributor]
Charles Gray charlestigray@gmail.com (ORCID) [contributor]
Jared Wilber [contributor]
Vilmantas Gegzna GegznaV@gmail.com (ORCID) [contributor]
Eduard Szoecs eduardszoecs@gmail.com [contributor]
Frederik Aust frederik.aust@uni-koeln.de (ORCID) [contributor]
Angus Moore angusmoore9@gmail.com [contributor]
Nick Williams ntwilliams.personal@gmail.com [contributor]
Marius Barth marius.barth.uni.koeln@gmail.com (ORCID) [contributor]
Bruna Wundervald brunadaviesw@gmail.com (ORCID) [contributor]
Joyce Cahoon joyceyu48@gmail.com (ORCID) [contributor]
Grant McDermott grantmcd@uoregon.edu (ORCID) [contributor]
Kevin Zarca kevin.zarca@gmail.com [contributor]
Shiro Kuriwaki shirokuriwaki@gmail.com (ORCID) [contributor]
Lukas Wallrich lukas.wallrich@gmail.com (ORCID) [contributor]
James Martherus james@martherus.com (ORCID) [contributor]
Chuliang Xiao cxiao@umich.edu (ORCID) [contributor]
Joseph Larmarange joseph@larmarange.net [contributor]
Max Kuhn max@posit.co [contributor]
Michal Bojanowski michal2992@gmail.com [contributor]
Hakon Malmedal hmalmedal@gmail.com [contributor]
Clara Wang [contributor]
Sergio Oller sergioller@gmail.com [contributor]
Luke Sonnet luke.sonnet@gmail.com [contributor]
Jim Hester jim.hester@posit.co [contributor]
Ben Schneider benjamin.julius.schneider@gmail.com [contributor]
Bernie Gray bfgray3@gmail.com (ORCID) [contributor]
Mara Averick mara@posit.co [contributor]
Aaron Jacobs atheriel@gmail.com [contributor]
Andreas Bender bender.at.R@gmail.com [contributor]
Sven Templer sven.templer@gmail.com [contributor]
Paul-Christian Buerkner paul.buerkner@gmail.com [contributor]
Matthew Kay mjskay@umich.edu [contributor]
Erwan Le Pennec lepennec@gmail.com [contributor]
Johan Junkka johan.junkka@umu.se [contributor]
Hao Zhu haozhu233@gmail.com [contributor]
Benjamin Soltoff soltoffbc@uchicago.edu [contributor]
Zoe Wilkinson Saldana zoewsaldana@gmail.com [contributor]
Tyler Littlefield tylurp1@gmail.com [contributor]
Charles T. Gray charlestigray@gmail.com [contributor]
Shabbh E. Banks [contributor]
Serina Robinson robi0916@umn.edu [contributor]
Roger Bivand Roger.Bivand@nhh.no [contributor]
Riinu Ots riinuots@gmail.com [contributor]
Nicholas Williams ntwilliams.personal@gmail.com [contributor]
Nina Jakobsen [contributor]
Michael Weylandt michael.weylandt@gmail.com [contributor]
Lisa Lendway llendway@macalester.edu [contributor]
Karl Hailperin khailper@gmail.com [contributor]
Josue Rodriguez jerrodriguez@ucdavis.edu [contributor]
Jenny Bryan jenny@posit.co [contributor]
Chris Jarvis Christopher1.jarvis@gmail.com [contributor]
Greg Macfarlane gregmacfarlane@gmail.com [contributor]
Brian Mannakee bmannakee@gmail.com [contributor]
Drew Tyre atyre2@unl.edu [contributor]
Shreyas Singh shreyas.singh.298@gmail.com [contributor]
Laurens Geffert laurensgeffert@gmail.com [contributor]
Hong Ooi hongooi@microsoft.com [contributor]
Henrik Bengtsson henrikb@braju.com [contributor]
Eduard Szocs eduardszoecs@gmail.com [contributor]
David Hugh-Jones davidhughjones@gmail.com [contributor]
Matthieu Stigler Matthieu.Stigler@gmail.com [contributor]
Hugo Tavares hm533@cam.ac.uk (ORCID) [contributor]
R. Willem Vervoort Willemvervoort@gmail.com [contributor]
Brenton M. Wiernik brenton@wiernik.org [contributor]
Josh Yamamoto joshuayamamoto5@gmail.com [contributor]
Jasme Lee [contributor]
Taren Sanders taren.sanders@acu.edu.au (ORCID) [contributor]
Ilaria Prosdocimi prosdocimi.ilaria@gmail.com (ORCID) [contributor]
Daniel D. Sjoberg danield.sjoberg@gmail.com (ORCID) [contributor]
Alex Reinhart areinhar@stat.cmu.edu (ORCID) [contributor]
See Also
Useful links:
Report bugs at https://github.com/tidymodels/broom/issues
Add fitted values, residuals, and other common outputs to an augment call
Description
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()
.
Usage
augment_columns(
x,
data,
newdata = NULL,
type,
type.predict = type,
type.residuals = type,
se.fit = TRUE,
...
)
Arguments
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) |
Details
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 data with information from a(n) betamfx object
Description
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.
Usage
## 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"),
...
)
Arguments
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
|
Details
This augment method wraps augment.betareg()
for
mfx::betamfx()
objects.
Value
A tibble::tibble()
with columns:
.cooksd |
Cooks distance. |
.fitted |
Fitted or predicted value. |
.resid |
The difference between observed and fitted values. |
See Also
augment.betareg()
, mfx::betamfx()
Other mfx tidiers:
augment.mfx()
,
glance.betamfx()
,
glance.mfx()
,
tidy.betamfx()
,
tidy.mfx()
Examples
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 data with information from a(n) betareg object
Description
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.
Usage
## S3 method for class 'betareg'
augment(
x,
data = model.frame(x),
newdata = NULL,
type.predict,
type.residuals,
...
)
Arguments
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
|
Details
For additional details on Cook's distance, see
stats::cooks.distance()
.
Value
A tibble::tibble()
with columns:
.cooksd |
Cooks distance. |
.fitted |
Fitted or predicted value. |
.resid |
The difference between observed and fitted values. |
See Also
Examples
# 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 data with information from a(n) clm object
Description
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.
Usage
## S3 method for class 'clm'
augment(
x,
data = model.frame(x),
newdata = NULL,
type.predict = c("prob", "class"),
...
)
Arguments
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
|
See Also
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()
Examples
# 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 data with information from a(n) coxph object
Description
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.
Usage
## S3 method for class 'coxph'
augment(
x,
data = model.frame(x),
newdata = NULL,
type.predict = "lp",
type.residuals = "martingale",
...
)
Arguments
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
|
Details
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.
Value
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. |
See Also
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()
Examples
# 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 data with information from a(n) decomposed.ts object
Description
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.
Usage
## S3 method for class 'decomposed.ts'
augment(x, ...)
Arguments
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
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. |
See Also
Other decompose tidiers:
augment.stl()
Examples
# 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 data with information from a(n) drc object
Description
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.
Usage
## S3 method for class 'drc'
augment(
x,
data = NULL,
newdata = NULL,
se_fit = FALSE,
conf.int = FALSE,
conf.level = 0.95,
...
)
Arguments
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
|
Value
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. |
See Also
Other drc tidiers:
glance.drc()
,
tidy.drc()
Examples
# 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 data with information from a(n) factanal object
Description
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.
Usage
## S3 method for class 'factanal'
augment(x, data, ...)
Arguments
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
|
Value
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
).
See Also
Other factanal tidiers:
glance.factanal()
,
tidy.factanal()
Augment data with information from a(n) felm object
Description
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.
Usage
## S3 method for class 'felm'
augment(x, data = model.frame(x), ...)
Arguments
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
|
Value
A tibble::tibble()
with columns:
.fitted |
Fitted or predicted value. |
.resid |
The difference between observed and fitted values. |
See Also
Other felm tidiers:
tidy.felm()
Examples
# 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 data with information from a(n) fixest object
Description
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.
Usage
## S3 method for class 'fixest'
augment(
x,
data = NULL,
newdata = NULL,
type.predict = c("link", "response"),
type.residuals = c("response", "deviance", "pearson", "working"),
...
)
Arguments
x |
A |
data |
A base::data.frame or |
newdata |
A |
type.predict |
Passed to |
type.residuals |
Passed to |
... |
Additional arguments passed to |
Value
A tibble::tibble()
with columns:
.fitted |
Fitted or predicted value. |
.resid |
The difference between observed and fitted values. |
Note
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()
.
See Also
augment()
, fixest::feglm()
, fixest::femlm()
, fixest::feols()
Other fixest tidiers:
tidy.fixest()
Examples
# 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 data with information from a(n) gam object
Description
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.
Usage
## S3 method for class 'gam'
augment(
x,
data = model.frame(x),
newdata = NULL,
type.predict,
type.residuals,
...
)
Arguments
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
|
Details
For additional details on Cook's distance, see
stats::cooks.distance()
.
Value
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. |
See Also
Examples
# 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 data with information from a(n) glm object
Description
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.
Usage
## 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,
...
)
Arguments
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
|
Details
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.
Value
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. |
See Also
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 data with information from a(n) glmrob object
Description
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.
Usage
## 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,
...
)
Arguments
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
|
Details
For tidiers for robust models from the MASS package see
tidy.rlm()
.
Value
A tibble::tibble()
with columns:
.fitted |
Fitted or predicted value. |
.resid |
The difference between observed and fitted values. |
See Also
Other robustbase tidiers:
augment.lmrob()
,
glance.lmrob()
,
tidy.glmrob()
,
tidy.lmrob()
Examples
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 data with information from a(n) glmRob object
Description
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.
Usage
## S3 method for class 'glmRob'
augment(x, ...)
Arguments
x |
Unused. |
... |
Unused. |
Augment data with information from a(n) htest object
Description
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.
Usage
## S3 method for class 'htest'
augment(x, ...)
Arguments
x |
An |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Details
See stats::chisq.test()
for more details on
how residuals are computed.
Value
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. |
See Also
augment()
, stats::chisq.test()
Other htest tidiers:
tidy.htest()
,
tidy.pairwise.htest()
,
tidy.power.htest()
Examples
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 data with information from a(n) ivreg object
Description
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.
Usage
## S3 method for class 'ivreg'
augment(x, data = model.frame(x), newdata = NULL, ...)
Arguments
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
|
Details
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.
Value
A tibble::tibble()
with columns:
.fitted |
Fitted or predicted value. |
.resid |
The difference between observed and fitted values. |
See Also
Other ivreg tidiers:
glance.ivreg()
,
tidy.ivreg()
Examples
# 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 data with information from a(n) kmeans object
Description
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.
Usage
## S3 method for class 'kmeans'
augment(x, data, ...)
Arguments
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
|
Value
A tibble::tibble()
with columns:
.cluster |
Cluster assignment. |
See Also
Other kmeans tidiers:
glance.kmeans()
,
tidy.kmeans()
Examples
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 data with information from a(n) lm object
Description
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.
Usage
## 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,
...
)
Arguments
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
|
Details
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.
Value
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. |
See Also
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()
Examples
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 data with information from a(n) lmrob object
Description
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.
Usage
## S3 method for class 'lmrob'
augment(x, data = model.frame(x), newdata = NULL, se_fit = FALSE, ...)
Arguments
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
|
Details
For tidiers for robust models from the MASS package see
tidy.rlm()
.
Value
A tibble::tibble()
with columns:
.fitted |
Fitted or predicted value. |
.resid |
The difference between observed and fitted values. |
See Also
Other robustbase tidiers:
augment.glmrob()
,
glance.lmrob()
,
tidy.glmrob()
,
tidy.lmrob()
Examples
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 data with information from a(n) lmRob object
Description
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.
Usage
## S3 method for class 'lmRob'
augment(x, data = model.frame(x), newdata = NULL, ...)
Arguments
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
|
Details
For tidiers for robust models from the MASS package see
tidy.rlm()
.
See Also
Other robust tidiers:
glance.glmRob()
,
glance.lmRob()
,
tidy.glmRob()
,
tidy.lmRob()
Examples
# 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 a(n) loess object
Description
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.
Usage
## S3 method for class 'loess'
augment(x, data = model.frame(x), newdata = NULL, se_fit = FALSE, ...)
Arguments
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
|
Details
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.
Value
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. |
See Also
augment()
, stats::loess()
, stats::predict.loess()
Examples
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 data with information from a(n) Mclust object
Description
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.
Usage
## S3 method for class 'Mclust'
augment(x, data = NULL, ...)
Arguments
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
|
Value
A tibble::tibble()
with columns:
.class |
Predicted class. |
.uncertainty |
The uncertainty associated with the classification. Equal to one minus the model class probability. |
See Also
Other mclust tidiers:
tidy.Mclust()
Examples
# 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 data with information from a(n) mfx object
Description
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.
Usage
## 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,
...
)
Arguments
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
|
Details
This generic augment method wraps augment.glm()
for applicable
objects from the mfx
package.
Value
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. |
See Also
augment.glm()
, mfx::logitmfx()
, mfx::negbinmfx()
,
mfx::poissonmfx()
, mfx::probitmfx()
Other mfx tidiers:
augment.betamfx()
,
glance.betamfx()
,
glance.mfx()
,
tidy.betamfx()
,
tidy.mfx()
Examples
# 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 data with information from a(n) mjoint object
Description
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.
Usage
## S3 method for class 'mjoint'
augment(x, data = x$data, ...)
Arguments
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
|
Details
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.
Value
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 |
Examples
# 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 data with information from a(n) mlogit object
Description
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.
Usage
## S3 method for class 'mlogit'
augment(x, data = x$model, ...)
Arguments
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
|
Details
At the moment this only works on the estimation dataset. Need to set it up to predict on another dataset.
Value
A tibble::tibble()
with columns:
.fitted |
Fitted or predicted value. |
.probability |
Class probability of modal class. |
.resid |
The difference between observed and fitted values. |
See Also
Other mlogit tidiers:
glance.mlogit()
,
tidy.mlogit()
Examples
# 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 a(n) nlrq object
Description
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.
Usage
## S3 method for class 'nlrq'
augment(x, data = NULL, newdata = NULL, ...)
Arguments
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
|
See Also
Other quantreg tidiers:
augment.rq()
,
augment.rqs()
,
glance.nlrq()
,
glance.rq()
,
tidy.nlrq()
,
tidy.rq()
,
tidy.rqs()
Examples
# 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 data with information from a(n) nls object
Description
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.
Usage
## S3 method for class 'nls'
augment(x, data = NULL, newdata = NULL, ...)
Arguments
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
|
Details
augment.nls does not currently support confidence intervals due to a lack of support in stats::predict.nls().
Value
A tibble::tibble()
with columns:
.fitted |
Fitted or predicted value. |
.resid |
The difference between observed and fitted values. |
See Also
tidy, stats::nls()
, stats::predict.nls()
Other nls tidiers:
glance.nls()
,
tidy.nls()
Examples
# 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 data with information from a(n) pam object
Description
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.
Usage
## S3 method for class 'pam'
augment(x, data = NULL, ...)
Arguments
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
|
Value
A tibble::tibble()
with columns:
.cluster |
Cluster assignment. |
.fitted |
Fitted or predicted value. |
.resid |
The difference between observed and fitted values. |
See Also
Other pam tidiers:
glance.pam()
,
tidy.pam()
Examples
# 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 data with information from a(n) plm object
Description
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.
Usage
## S3 method for class 'plm'
augment(x, data = model.frame(x), ...)
Arguments
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
|
Value
A tibble::tibble()
with columns:
.fitted |
Fitted or predicted value. |
.resid |
The difference between observed and fitted values. |
See Also
Other plm tidiers:
glance.plm()
,
tidy.plm()
Examples
# 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 data with information from a(n) poLCA object
Description
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.
Usage
## S3 method for class 'poLCA'
augment(x, data = NULL, ...)
Arguments
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
|
Details
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.
Value
A tibble::tibble()
with columns:
.class |
Predicted class. |
.probability |
Class probability of modal class. |
See Also
Other poLCA tidiers:
glance.poLCA()
,
tidy.poLCA()
Examples
# 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 data with information from a(n) polr object
Description
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.
Usage
## S3 method for class 'polr'
augment(
x,
data = model.frame(x),
newdata = NULL,
type.predict = c("class"),
...
)
Arguments
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
|
See Also
Other ordinal tidiers:
augment.clm()
,
glance.clm()
,
glance.clmm()
,
glance.polr()
,
glance.svyolr()
,
tidy.clm()
,
tidy.clmm()
,
tidy.polr()
,
tidy.svyolr()
Examples
# 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 data with information from a(n) prcomp object
Description
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.
Usage
## S3 method for class 'prcomp'
augment(x, data = NULL, newdata, ...)
Arguments
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
|
Value
A tibble::tibble containing the original data along with additional columns containing each observation's projection into PCA space.
See Also
Other svd tidiers:
tidy.prcomp()
,
tidy_irlba()
,
tidy_svd()
Augment data with information from a(n) rlm object
Description
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.
Usage
## S3 method for class 'rlm'
augment(x, data = model.frame(x), newdata = NULL, se_fit = FALSE, ...)
Arguments
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
|
Value
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. |
See Also
Other rlm tidiers:
glance.rlm()
,
tidy.rlm()
Examples
# 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 data with information from a(n) rma object
Description
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.
Usage
## S3 method for class 'rma'
augment(x, interval = c("prediction", "confidence"), ...)
Arguments
x |
An |
interval |
For |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
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 |
Examples
# 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 data with information from a(n) rq object
Description
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.
Usage
## S3 method for class 'rq'
augment(x, data = model.frame(x), newdata = NULL, ...)
Arguments
x |
An |
data |
A base::data.frame or |
newdata |
A |
... |
Arguments passed on to
|
Details
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.
Value
A tibble::tibble()
with columns:
.fitted |
Fitted or predicted value. |
.resid |
The difference between observed and fitted values. |
.tau |
Quantile. |
See Also
augment, quantreg::rq()
, quantreg::predict.rq()
Other quantreg tidiers:
augment.nlrq()
,
augment.rqs()
,
glance.nlrq()
,
glance.rq()
,
tidy.nlrq()
,
tidy.rq()
,
tidy.rqs()
Examples
# 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 data with information from a(n) rqs object
Description
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.
Usage
## S3 method for class 'rqs'
augment(x, data = model.frame(x), newdata, ...)
Arguments
x |
An |
data |
A base::data.frame or |
newdata |
A |
... |
Arguments passed on to
|
Details
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.
See Also
augment, quantreg::rq()
, quantreg::predict.rqs()
Other quantreg tidiers:
augment.nlrq()
,
augment.rq()
,
glance.nlrq()
,
glance.rq()
,
tidy.nlrq()
,
tidy.rq()
,
tidy.rqs()
Examples
# 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 data with information from a(n) spatialreg object
Description
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.
Usage
## S3 method for class 'sarlm'
augment(x, data = x$X, ...)
Arguments
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
|
Details
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.
Value
A tibble::tibble()
with columns:
.fitted |
Fitted or predicted value. |
.resid |
The difference between observed and fitted values. |
See Also
Other spatialreg tidiers:
glance.sarlm()
,
tidy.sarlm()
Examples
# 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 a(n) smooth.spline object
Description
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.
Usage
## S3 method for class 'smooth.spline'
augment(x, data = x$data, ...)
Arguments
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
|
Value
A tibble::tibble()
with columns:
.fitted |
Fitted or predicted value. |
.resid |
The difference between observed and fitted values. |
See Also
augment()
, stats::smooth.spline()
,
stats::predict.smooth.spline()
Other smoothing spline tidiers:
glance.smooth.spline()
Examples
# 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 data with information from a(n) speedlm object
Description
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.
Usage
## S3 method for class 'speedlm'
augment(x, data = model.frame(x), newdata = NULL, ...)
Arguments
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
|
Value
A tibble::tibble()
with columns:
.fitted |
Fitted or predicted value. |
.resid |
The difference between observed and fitted values. |
See Also
Other speedlm tidiers:
glance.speedglm()
,
glance.speedlm()
,
tidy.speedglm()
,
tidy.speedlm()
Examples
# 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 data with information from a(n) stl object
Description
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.
Usage
## S3 method for class 'stl'
augment(x, data = NULL, weights = TRUE, ...)
Arguments
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
|
Value
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. |
See Also
Other decompose tidiers:
augment.decomposed.ts()
Augment data with information from a(n) survreg object
Description
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.
Usage
## S3 method for class 'survreg'
augment(
x,
data = model.frame(x),
newdata = NULL,
type.predict = "response",
type.residuals = "response",
...
)
Arguments
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
|
Value
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. |
See Also
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()
Examples
# 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)
Set up bootstrap replicates of a dplyr operation
Description
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.
Usage
bootstrap(df, m, by_group = FALSE)
Arguments
df |
a data frame |
m |
number of bootstrap replicates to perform |
by_group |
If |
Details
This code originates from Hadley Wickham (with a few small corrections) here: https://github.com/tidyverse/dplyr/issues/269
See Also
Other deprecated:
confint_tidy()
,
data.frame_tidiers
,
finish_glance()
,
fix_data_frame()
,
summary_tidiers
,
tidy.density()
,
tidy.dist()
,
tidy.ftable()
,
tidy.numeric()
(Deprecated) Calculate confidence interval as a tidy data frame
Description
This function is now deprecated and will be removed from a future release of broom.
Usage
confint_tidy(x, conf.level = 0.95, func = stats::confint, ...)
Arguments
x |
a model object for which |
conf.level |
confidence level |
func |
A function to compute a confidence interval for |
... |
extra arguments passed on to |
Details
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
Value
A tibble with two columns: conf.low
and conf.high
.
See Also
Other deprecated:
bootstrap()
,
data.frame_tidiers
,
finish_glance()
,
fix_data_frame()
,
summary_tidiers
,
tidy.density()
,
tidy.dist()
,
tidy.ftable()
,
tidy.numeric()
Tidiers for data.frame objects
Description
Data frame tidiers are deprecated and will be removed from an upcoming release of broom.
Usage
## 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, ...)
Arguments
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 |
Details
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.
Value
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 |
Author(s)
David Robinson, Benjamin Nutter
Source
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
See Also
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()
Examples
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()
Tidy/glance a(n) durbinWatsonTest object
Description
For models that have only a single component, the tidy()
and
glance()
methods are identical. Please see the documentation for both
of those methods.
Usage
## S3 method for class 'durbinWatsonTest'
tidy(x, ...)
## S3 method for class 'durbinWatsonTest'
glance(x, ...)
Arguments
x |
An object of class |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
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'. |
See Also
tidy()
, glance()
, car::durbinWatsonTest()
Other car tidiers:
leveneTest_tidiers
Examples
# 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)
(Deprecated) Add logLik, AIC, BIC, and other common measurements to a glance of a prediction
Description
This function is now deprecated in favor of using custom logic and
the appropriate nobs()
method.
Usage
finish_glance(ret, x)
Arguments
ret |
a one-row data frame (a partially complete glance) |
x |
the prediction model |
Value
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 |
See Also
Other deprecated:
bootstrap()
,
confint_tidy()
,
data.frame_tidiers
,
fix_data_frame()
,
summary_tidiers
,
tidy.density()
,
tidy.dist()
,
tidy.ftable()
,
tidy.numeric()
Ensure an object is a data frame, with rownames moved into a column
Description
This function is deprecated as of broom 0.7.0 and will be removed from
a future release. Please see tibble::as_tibble
.
Usage
fix_data_frame(x, newnames = NULL, newcol = "term")
Arguments
x |
a data.frame or matrix |
newnames |
new column names, not including the rownames |
newcol |
the name of the new rownames column |
Value
a data.frame, with rownames moved into a column and new column names assigned
See Also
Other deprecated:
bootstrap()
,
confint_tidy()
,
data.frame_tidiers
,
finish_glance()
,
summary_tidiers
,
tidy.density()
,
tidy.dist()
,
tidy.ftable()
,
tidy.numeric()
Tidy a(n) optim object masquerading as list
Description
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.
Usage
glance_optim(x, ...)
Arguments
x |
A list returned from |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
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. |
See Also
Other list tidiers:
list_tidiers
,
tidy_irlba()
,
tidy_optim()
,
tidy_svd()
,
tidy_xyz()
Examples
f <- function(x) (x[1] - 2)^2 + (x[2] - 3)^2 + (x[3] - 8)^2
o <- optim(c(1, 1, 1), f)
Glance at a(n) aareg object
Description
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.
Usage
## S3 method for class 'aareg'
glance(x, ...)
Arguments
x |
An |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
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. |
See Also
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()
Examples
# 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 at a(n) anova object
Description
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.
Usage
## S3 method for class 'anova'
glance(x, ...)
Arguments
x |
An |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
A tibble::tibble()
with exactly one row and columns:
deviance |
Deviance of the model. |
df.residual |
Residual degrees of freedom. |
Note
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.
See Also
Other anova tidiers:
glance.aov()
,
tidy.TukeyHSD()
,
tidy.anova()
,
tidy.aov()
,
tidy.aovlist()
,
tidy.manova()
Examples
# 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 at a(n) lm object
Description
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.
Usage
## S3 method for class 'aov'
glance(x, ...)
Arguments
x |
An |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
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
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.
See Also
Other anova tidiers:
glance.anova()
,
tidy.TukeyHSD()
,
tidy.anova()
,
tidy.aov()
,
tidy.aovlist()
,
tidy.manova()
Examples
a <- aov(mpg ~ wt + qsec + disp, mtcars)
tidy(a)
Glance at a(n) Arima object
Description
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.
Usage
## S3 method for class 'Arima'
glance(x, ...)
Arguments
x |
An object of class |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
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. |
See Also
Other Arima tidiers:
tidy.Arima()
Examples
# fit model
fit <- arima(lh, order = c(1, 0, 0))
# summarize model fit with tidiers
tidy(fit)
glance(fit)
Glance at a(n) betamfx object
Description
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.
Usage
## S3 method for class 'betamfx'
glance(x, ...)
Arguments
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Details
This glance method wraps glance.betareg()
for mfx::betamfx()
objects.
Value
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. |
See Also
glance.betareg()
, mfx::betamfx()
Other mfx tidiers:
augment.betamfx()
,
augment.mfx()
,
glance.mfx()
,
tidy.betamfx()
,
tidy.mfx()
Examples
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 at a(n) betareg object
Description
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.
Usage
## S3 method for class 'betareg'
glance(x, ...)
Arguments
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
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. |
See Also
Examples
# 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 at a(n) biglm object
Description
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.
Usage
## S3 method for class 'biglm'
glance(x, ...)
Arguments
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
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. |
See Also
glance()
, biglm::biglm()
, biglm::bigglm()
Other biglm tidiers:
tidy.biglm()
Examples
# 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 at a(n) binDesign object
Description
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.
Usage
## S3 method for class 'binDesign'
glance(x, ...)
Arguments
x |
A binGroup::binDesign object. |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
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. |
See Also
glance()
, binGroup::binDesign()
Other bingroup tidiers:
tidy.binDesign()
,
tidy.binWidth()
Examples
# 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 at a(n) cch object
Description
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.
Usage
## S3 method for class 'cch'
glance(x, ...)
Arguments
x |
An |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
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 |
See Also
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()
Examples
# 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 at a(n) clm object
Description
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.
Usage
## S3 method for class 'clm'
glance(x, ...)
Arguments
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
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. |
See Also
Other ordinal tidiers:
augment.clm()
,
augment.polr()
,
glance.clmm()
,
glance.polr()
,
glance.svyolr()
,
tidy.clm()
,
tidy.clmm()
,
tidy.polr()
,
tidy.svyolr()
Examples
# 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 at a(n) clmm object
Description
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.
Usage
## S3 method for class 'clmm'
glance(x, ...)
Arguments
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
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. |
See Also
Other ordinal tidiers:
augment.clm()
,
augment.polr()
,
glance.clm()
,
glance.polr()
,
glance.svyolr()
,
tidy.clm()
,
tidy.clmm()
,
tidy.polr()
,
tidy.svyolr()
Examples
# 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 at a(n) coeftest object
Description
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.
Usage
## S3 method for class 'coeftest'
glance(x, ...)
Arguments
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
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. |
Note
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).
References
Wooldridge, Jeffrey M. (2016) Introductory econometrics: A modern approach. (6th edition). Nelson Education.
See Also
Examples
# 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 at a(n) coxph object
Description
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.
Usage
## S3 method for class 'coxph'
glance(x, ...)
Arguments
x |
A |
... |
For |
Value
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.
See Also
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()
Examples
# 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 at a(n) crr object
Description
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.
Usage
## S3 method for class 'crr'
glance(x, ...)
Arguments
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
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. |
See Also
Other cmprsk tidiers:
tidy.crr()
Examples
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 at a(n) cv.glmnet object
Description
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.
Usage
## S3 method for class 'cv.glmnet'
glance(x, ...)
Arguments
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
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. |
See Also
Other glmnet tidiers:
glance.glmnet()
,
tidy.cv.glmnet()
,
tidy.glmnet()
Examples
# 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 at a(n) drc object
Description
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.
Usage
## S3 method for class 'drc'
glance(x, ...)
Arguments
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
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 |
See Also
Other drc tidiers:
augment.drc()
,
tidy.drc()
Examples
# 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 at a(n) ergm object
Description
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.
Usage
## S3 method for class 'ergm'
glance(x, deviance = FALSE, mcmc = FALSE, ...)
Arguments
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 |
Value
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 |
See Also
glance()
, ergm::ergm()
, ergm::summary.ergm()
Other ergm tidiers:
tidy.ergm()
Glance at a(n) factanal object
Description
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.
Usage
## S3 method for class 'factanal'
glance(x, ...)
Arguments
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
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. |
See Also
Other factanal tidiers:
augment.factanal()
,
tidy.factanal()
Examples
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 at a(n) felm object
Description
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.
Usage
## S3 method for class 'felm'
glance(x, ...)
Arguments
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
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. |
Examples
# 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 at a(n) fitdistr object
Description
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.
Usage
## S3 method for class 'fitdistr'
glance(x, ...)
Arguments
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
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. |
See Also
Other fitdistr tidiers:
tidy.fitdistr()
Examples
# 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 at a(n) fixest object
Description
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.
Usage
## S3 method for class 'fixest'
glance(x, ...)
Arguments
x |
A |
... |
Additional arguments passed to |
Value
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. |
Note
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
.
Examples
# 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 at a(n) gam object
Description
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.
Usage
## S3 method for class 'gam'
glance(x, ...)
Arguments
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
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. |
See Also
Other mgcv tidiers:
tidy.gam()
Examples
# 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 at a(n) Gam object
Description
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.
Usage
## S3 method for class 'Gam'
glance(x, ...)
Arguments
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Details
Glance at gam
objects created by calls to mgcv::gam()
with
glance.gam()
.
Value
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. |
See Also
Other gam tidiers:
tidy.Gam()
Tidy a(n) garch object
Description
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.
Usage
## S3 method for class 'garch'
glance(x, test = c("box-ljung-test", "jarque-bera-test"), ...)
Arguments
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
|
Value
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. |
See Also
glance()
, tseries::garch()
, []
Other garch tidiers:
tidy.garch()
Glance at a(n) geeglm object
Description
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.
Usage
## S3 method for class 'geeglm'
glance(x, ...)
Arguments
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
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. |
See Also
Examples
# 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 at a(n) glm object
Description
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.
Usage
## S3 method for class 'glm'
glance(x, ...)
Arguments
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
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. |
See Also
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()
Examples
g <- glm(am ~ mpg, mtcars, family = "binomial")
glance(g)
Glance at a(n) glmnet object
Description
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.
Usage
## S3 method for class 'glmnet'
glance(x, ...)
Arguments
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
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. |
See Also
Other glmnet tidiers:
glance.cv.glmnet()
,
tidy.cv.glmnet()
,
tidy.glmnet()
Examples
# 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 at a(n) glmRob object
Description
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.
Usage
## S3 method for class 'glmRob'
glance(x, ...)
Arguments
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
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. |
See Also
Other robust tidiers:
augment.lmRob()
,
glance.lmRob()
,
tidy.glmRob()
,
tidy.lmRob()
Examples
# 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 at a(n) gmm object
Description
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.
Usage
## S3 method for class 'gmm'
glance(x, ...)
Arguments
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
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. |
See Also
Other gmm tidiers:
tidy.gmm()
Examples
# 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 at a(n) ivreg object
Description
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.
Usage
## S3 method for class 'ivreg'
glance(x, diagnostics = FALSE, ...)
Arguments
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
|
Details
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.
Value
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. |
Note
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.
See Also
Other ivreg tidiers:
augment.ivreg()
,
tidy.ivreg()
Examples
# 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 at a(n) kmeans object
Description
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.
Usage
## S3 method for class 'kmeans'
glance(x, ...)
Arguments
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
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. |
See Also
Other kmeans tidiers:
augment.kmeans()
,
tidy.kmeans()
Examples
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 at a(n) lavaan object
Description
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.
Usage
## S3 method for class 'lavaan'
glance(x, ...)
Arguments
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
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
See Also
glance()
, lavaan::cfa()
, lavaan::sem()
,
lavaan::fitmeasures()
Other lavaan tidiers:
tidy.lavaan()
Examples
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 at a(n) lm object
Description
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.
Usage
## S3 method for class 'lm'
glance(x, ...)
Arguments
x |
An |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
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. |
See Also
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()
Examples
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 at a(n) lmodel2 object
Description
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.
Usage
## S3 method for class 'lmodel2'
glance(x, ...)
Arguments
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
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 |
See Also
Other lmodel2 tidiers:
tidy.lmodel2()
Examples
# 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 at a(n) lmrob object
Description
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.
Usage
## S3 method for class 'lmrob'
glance(x, ...)
Arguments
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Details
For tidiers for robust models from the MASS package see
tidy.rlm()
.
Value
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. |
See Also
Other robustbase tidiers:
augment.glmrob()
,
augment.lmrob()
,
tidy.glmrob()
,
tidy.lmrob()
Examples
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 at a(n) lmRob object
Description
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.
Usage
## S3 method for class 'lmRob'
glance(x, ...)
Arguments
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
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. |
See Also
Other robust tidiers:
augment.lmRob()
,
glance.glmRob()
,
tidy.glmRob()
,
tidy.lmRob()
Examples
# 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 at a(n) margins object
Description
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.
Usage
## S3 method for class 'margins'
glance(x, ...)
Arguments
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
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. |
Examples
# 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 at a(n) Mclust object
Description
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.
Usage
## S3 method for class 'Mclust'
glance(x, ...)
Arguments
x |
An |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
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'. |
Examples
# 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 at a(n) mfx object
Description
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.
Usage
## 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, ...)
Arguments
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Details
This generic glance method wraps glance.glm()
for applicable
objects from the mfx
package.
Value
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. |
See Also
glance.glm()
, mfx::logitmfx()
, mfx::negbinmfx()
,
mfx::poissonmfx()
, mfx::probitmfx()
Other mfx tidiers:
augment.betamfx()
,
augment.mfx()
,
glance.betamfx()
,
tidy.betamfx()
,
tidy.mfx()
Examples
# 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 at a(n) mjoint object
Description
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.
Usage
## S3 method for class 'mjoint'
glance(x, ...)
Arguments
x |
An |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
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 |
See Also
Other mjoint tidiers:
tidy.mjoint()
Examples
# 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 at a(n) mlogit object
Description
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.
Usage
## S3 method for class 'mlogit'
glance(x, ...)
Arguments
x |
an object returned from |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
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. |
See Also
Other mlogit tidiers:
augment.mlogit()
,
tidy.mlogit()
Examples
# 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 at a(n) muhaz object
Description
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.
Usage
## S3 method for class 'muhaz'
glance(x, ...)
Arguments
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
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. |
See Also
Other muhaz tidiers:
tidy.muhaz()
Examples
# 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 at a(n) multinom object
Description
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.
Usage
## S3 method for class 'multinom'
glance(x, ...)
Arguments
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
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. |
See Also
Other multinom tidiers:
tidy.multinom()
Examples
# 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 at a(n) negbin object
Description
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.
Usage
## S3 method for class 'negbin'
glance(x, ...)
Arguments
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
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. |
See Also
Other glm.nb tidiers:
tidy.negbin()
Examples
# 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 at a(n) nlrq object
Description
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.
Usage
## S3 method for class 'nlrq'
glance(x, ...)
Arguments
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
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. |
See Also
Other quantreg tidiers:
augment.nlrq()
,
augment.rq()
,
augment.rqs()
,
glance.rq()
,
tidy.nlrq()
,
tidy.rq()
,
tidy.rqs()
Examples
# 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 at a(n) nls object
Description
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.
Usage
## S3 method for class 'nls'
glance(x, ...)
Arguments
x |
An |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
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. |
See Also
Other nls tidiers:
augment.nls()
,
tidy.nls()
Examples
# 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 at a(n) orcutt object
Description
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.
Usage
## S3 method for class 'orcutt'
glance(x, ...)
Arguments
x |
An |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
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 |
See Also
glance()
, orcutt::cochrane.orcutt()
Other orcutt tidiers:
tidy.orcutt()
Examples
# 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 at a(n) pam object
Description
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.
Usage
## S3 method for class 'pam'
glance(x, ...)
Arguments
x |
An |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
A tibble::tibble()
with exactly one row and columns:
avg.silhouette.width |
The average silhouette width for the dataset. |
See Also
Other pam tidiers:
augment.pam()
,
tidy.pam()
Examples
# 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 at a(n) plm object
Description
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.
Usage
## S3 method for class 'plm'
glance(x, ...)
Arguments
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
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 |
See Also
Other plm tidiers:
augment.plm()
,
tidy.plm()
Examples
# 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 at a(n) poLCA object
Description
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.
Usage
## S3 method for class 'poLCA'
glance(x, ...)
Arguments
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
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 |
See Also
Other poLCA tidiers:
augment.poLCA()
,
tidy.poLCA()
Examples
# 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 at a(n) polr object
Description
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.
Usage
## S3 method for class 'polr'
glance(x, ...)
Arguments
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
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. |
See Also
Other ordinal tidiers:
augment.clm()
,
augment.polr()
,
glance.clm()
,
glance.clmm()
,
glance.svyolr()
,
tidy.clm()
,
tidy.clmm()
,
tidy.polr()
,
tidy.svyolr()
Examples
# 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 at a(n) pyears object
Description
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.
Usage
## S3 method for class 'pyears'
glance(x, ...)
Arguments
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
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 |
See Also
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()
Examples
# 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 at a(n) ridgelm object
Description
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.
Usage
## S3 method for class 'ridgelm'
glance(x, ...)
Arguments
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Details
This is similar to the output of select.ridgelm
, but it is
returned rather than printed.
Value
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 |
See Also
glance()
, MASS::select.ridgelm()
, MASS::lm.ridge()
Other ridgelm tidiers:
tidy.ridgelm()
Examples
# 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 at a(n) rlm object
Description
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.
Usage
## S3 method for class 'rlm'
glance(x, ...)
Arguments
x |
An |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
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. |
See Also
Other rlm tidiers:
augment.rlm()
,
tidy.rlm()
Examples
# 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 at a(n) rma object
Description
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.
Usage
## S3 method for class 'rma'
glance(x, ...)
Arguments
x |
An |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
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. |
Examples
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 at a(n) rq object
Description
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.
Usage
## S3 method for class 'rq'
glance(x, ...)
Arguments
x |
An |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Details
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)
Value
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. |
See Also
Other quantreg tidiers:
augment.nlrq()
,
augment.rq()
,
augment.rqs()
,
glance.nlrq()
,
tidy.nlrq()
,
tidy.rq()
,
tidy.rqs()
Examples
# 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 at a(n) spatialreg object
Description
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.
Usage
## S3 method for class 'sarlm'
glance(x, ...)
Arguments
x |
An object returned from |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
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. |
See Also
glance()
, spatialreg::lagsarlm()
, spatialreg::errorsarlm()
,
spatialreg::sacsarlm()
Other spatialreg tidiers:
augment.sarlm()
,
tidy.sarlm()
Examples
# 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 a(n) smooth.spine object
Description
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.
Usage
## S3 method for class 'smooth.spline'
glance(x, ...)
Arguments
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
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. |
See Also
augment()
, stats::smooth.spline()
Other smoothing spline tidiers:
augment.smooth.spline()
Examples
# 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 at a(n) speedglm object
Description
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.
Usage
## S3 method for class 'speedglm'
glance(x, ...)
Arguments
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
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. |
See Also
Other speedlm tidiers:
augment.speedlm()
,
glance.speedlm()
,
tidy.speedglm()
,
tidy.speedlm()
Examples
# 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 at a(n) speedlm object
Description
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.
Usage
## S3 method for class 'speedlm'
glance(x, ...)
Arguments
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
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. |
See Also
Other speedlm tidiers:
augment.speedlm()
,
glance.speedglm()
,
tidy.speedglm()
,
tidy.speedlm()
Examples
# 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 at a(n) summary.lm object
Description
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.
Usage
## S3 method for class 'summary.lm'
glance(x, ...)
Arguments
x |
An |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Details
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.)
Value
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. |
See Also
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()
Examples
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 at a(n) survdiff object
Description
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.
Usage
## S3 method for class 'survdiff'
glance(x, ...)
Arguments
x |
An |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
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. |
See Also
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()
Examples
# 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 at a(n) survexp object
Description
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.
Usage
## S3 method for class 'survexp'
glance(x, ...)
Arguments
x |
An |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
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. |
See Also
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()
Examples
# 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 at a(n) survfit object
Description
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.
Usage
## S3 method for class 'survfit'
glance(x, ...)
Arguments
x |
An |
... |
Additional arguments passed to |
Value
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 |
See Also
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()
Examples
# 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 at a(n) survreg object
Description
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.
Usage
## S3 method for class 'survreg'
glance(x, ...)
Arguments
x |
An |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
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. |
See Also
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()
Examples
# 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 at a(n) svyglm object
Description
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.
Usage
## S3 method for class 'svyglm'
glance(x, maximal = x, ...)
Arguments
x |
A |
maximal |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
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. |
References
Lumley T, Scott A (2015). AIC and BIC for modelling with complex survey data. Journal of Survey Statistics and Methodology, 3(1).
See Also
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()
Examples
# 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 at a(n) svyolr object
Description
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.
Usage
## S3 method for class 'svyolr'
glance(x, ...)
Arguments
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
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. |
See Also
Other ordinal tidiers:
augment.clm()
,
augment.polr()
,
glance.clm()
,
glance.clmm()
,
glance.polr()
,
tidy.clm()
,
tidy.clmm()
,
tidy.polr()
,
tidy.svyolr()
Examples
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 at a(n) varest object
Description
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.
Usage
## S3 method for class 'varest'
glance(x, ...)
Arguments
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
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. |
See Also
Examples
# 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/glance a(n) leveneTest object
Description
For models that have only a single component, the tidy()
and
glance()
methods are identical. Please see the documentation for both
of those methods.
Usage
## S3 method for class 'leveneTest'
tidy(x, ...)
Arguments
x |
An object of class |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
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. |
See Also
tidy()
, glance()
, car::leveneTest()
Other car tidiers:
durbinWatsonTest_tidiers
Examples
# load libraries for models and data
library(car)
data(Moore)
lt <- with(Moore, leveneTest(conformity, fcategory))
tidy(lt)
glance(lt)
Tidying methods for lists / returned values that are not S3 objects
Description
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.
Usage
## S3 method for class 'list'
tidy(x, ...)
## S3 method for class 'list'
glance(x, ...)
Arguments
x |
A list, potentially representing an object that can be tidied. |
... |
Additionally, arguments passed to the tidying function. |
Details
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.
See Also
Other list tidiers:
glance_optim()
,
tidy_irlba()
,
tidy_optim()
,
tidy_svd()
,
tidy_xyz()
Tidiers for NULL inputs
Description
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.
Usage
## S3 method for class ''NULL''
tidy(x, ...)
## S3 method for class ''NULL''
glance(x, ...)
## S3 method for class ''NULL''
augment(x, ...)
Arguments
x |
The value |
... |
Additional arguments (not used). |
Value
An empty tibble::tibble.
See Also
Objects exported from other packages
Description
These objects are imported from other packages. Follow the links below to see their documentation.
See Also
Tidy a(n) SpatialPolygonsDataFrame object
Description
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.
Usage
## 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, ...)
Arguments
x |
A |
region |
name of variable used to split up regions |
... |
not used by this method |
(Deprecated) Tidy summaryDefault objects
Description
Tidiers for summaryDefault objects have been deprecated as of
broom 0.7.0 in favor of skimr::skim()
.
Usage
## S3 method for class 'summaryDefault'
tidy(x, ...)
## S3 method for class 'summaryDefault'
glance(x, ...)
Arguments
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
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 |
See Also
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()
Examples
v <- rnorm(1000)
s <- summary(v)
s
tidy(s)
glance(s)
v2 <- c(v,NA)
tidy(summary(v2))
Tidy a(n) irlba object masquerading as list
Description
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.
Usage
tidy_irlba(x, ...)
Arguments
x |
A list returned from |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Details
A very thin wrapper around tidy_svd()
.
Value
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). |
See Also
Other list tidiers:
glance_optim()
,
list_tidiers
,
tidy_optim()
,
tidy_svd()
,
tidy_xyz()
Other svd tidiers:
augment.prcomp()
,
tidy.prcomp()
,
tidy_svd()
Examples
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")
Tidy a(n) optim object masquerading as list
Description
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.
Usage
tidy_optim(x, ...)
Arguments
x |
A list returned from |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
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.
Note
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)
See Also
Other list tidiers:
glance_optim()
,
list_tidiers
,
tidy_irlba()
,
tidy_svd()
,
tidy_xyz()
Examples
f <- function(x) (x[1] - 2)^2 + (x[2] - 3)^2 + (x[3] - 8)^2
o <- optim(c(1, 1, 1), f)
Tidy a(n) svd object masquerading as list
Description
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.
Usage
tidy_svd(x, matrix = "u", ...)
Arguments
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
|
Details
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.
Value
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). |
See Also
Other svd tidiers:
augment.prcomp()
,
tidy.prcomp()
,
tidy_irlba()
Other list tidiers:
glance_optim()
,
list_tidiers
,
tidy_irlba()
,
tidy_optim()
,
tidy_xyz()
Examples
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")
Tidy a(n) xyz object masquerading as list
Description
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()
.
Usage
tidy_xyz(x, ...)
Arguments
x |
A list with component |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
A tibble::tibble with vector columns x
, y
and z
.
See Also
tidy()
, graphics::persp()
, graphics::image()
,
interp::interp()
Other list tidiers:
glance_optim()
,
list_tidiers
,
tidy_irlba()
,
tidy_optim()
,
tidy_svd()
Examples
A <- list(x = 1:5, y = 1:3, z = matrix(runif(5 * 3), nrow = 5))
image(A)
tidy(A)
Tidy a(n) aareg object
Description
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.
Usage
## S3 method for class 'aareg'
tidy(x, ...)
Arguments
x |
An |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Details
robust.se
is only present when x
was created with
dfbeta = TRUE
.
Value
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. |
See Also
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()
Examples
# 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 a(n) acf object
Description
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.
Usage
## S3 method for class 'acf'
tidy(x, ...)
Arguments
x |
An |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
A tibble::tibble()
with columns:
acf |
Autocorrelation. |
lag |
Lag values. |
See Also
tidy()
, stats::acf()
, stats::pacf()
, stats::ccf()
Other time series tidiers:
tidy.spec()
,
tidy.ts()
,
tidy.zoo()
Examples
tidy(acf(lh, plot = FALSE))
tidy(ccf(mdeaths, fdeaths, plot = FALSE))
tidy(pacf(lh, plot = FALSE))
Tidy a(n) anova object
Description
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.
Usage
## S3 method for class 'anova'
tidy(x, ...)
Arguments
x |
An |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Details
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()
Value
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. |
See Also
tidy()
, stats::anova()
, car::Anova()
, car::leveneTest()
Other anova tidiers:
glance.anova()
,
glance.aov()
,
tidy.TukeyHSD()
,
tidy.aov()
,
tidy.aovlist()
,
tidy.manova()
Examples
# 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 a(n) aov object
Description
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.
Usage
## S3 method for class 'aov'
tidy(x, intercept = FALSE, ...)
Arguments
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
|
Details
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()
See Also
Other anova tidiers:
glance.anova()
,
glance.aov()
,
tidy.TukeyHSD()
,
tidy.anova()
,
tidy.aovlist()
,
tidy.manova()
Examples
a <- aov(mpg ~ wt + qsec + disp, mtcars)
tidy(a)
Tidy a(n) aovlist object
Description
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.
Usage
## S3 method for class 'aovlist'
tidy(x, ...)
Arguments
x |
An |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Details
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()
Value
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. |
See Also
Other anova tidiers:
glance.anova()
,
glance.aov()
,
tidy.TukeyHSD()
,
tidy.anova()
,
tidy.aov()
,
tidy.manova()
Examples
a <- aov(mpg ~ wt + qsec + Error(disp / am), mtcars)
tidy(a)
Tidy a(n) Arima object
Description
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.
Usage
## S3 method for class 'Arima'
tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
Arguments
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
|
Value
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. |
See Also
Other Arima tidiers:
glance.Arima()
Examples
# fit model
fit <- arima(lh, order = c(1, 0, 0))
# summarize model fit with tidiers
tidy(fit)
glance(fit)
Tidy a(n) betamfx object
Description
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.
Usage
## S3 method for class 'betamfx'
tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
Arguments
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
|
Details
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.
Value
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. |
See Also
tidy.betareg()
, mfx::betamfx()
Other mfx tidiers:
augment.betamfx()
,
augment.mfx()
,
glance.betamfx()
,
glance.mfx()
,
tidy.mfx()
Examples
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 a(n) betareg object
Description
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.
Usage
## S3 method for class 'betareg'
tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
Arguments
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
|
Details
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
.
Value
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. |
See Also
Examples
# 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 a(n) biglm object
Description
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.
Usage
## S3 method for class 'biglm'
tidy(x, conf.int = FALSE, conf.level = 0.95, exponentiate = FALSE, ...)
Arguments
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
|
Value
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. |
See Also
tidy()
, biglm::biglm()
, biglm::bigglm()
Other biglm tidiers:
glance.biglm()
Examples
# 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 a(n) binDesign object
Description
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.
Usage
## S3 method for class 'binDesign'
tidy(x, ...)
Arguments
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
A tibble::tibble()
with columns:
n |
Number of trials in given iteration. |
power |
Power achieved for given value of n. |
See Also
Other bingroup tidiers:
glance.binDesign()
,
tidy.binWidth()
Examples
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 a(n) binWidth object
Description
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.
Usage
## S3 method for class 'binWidth'
tidy(x, ...)
Arguments
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
A tibble::tibble()
with columns:
alternative |
Alternative hypothesis (character). |
ci.width |
Expected width of confidence interval. |
p |
True proportion. |
n |
Total sample size |
See Also
Other bingroup tidiers:
glance.binDesign()
,
tidy.binDesign()
Examples
# load libraries
library(binGroup)
# fit model
bw <- binWidth(100, .1)
bw
# summarize model fit with tidiers
tidy(bw)
Tidy a(n) boot object
Description
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.
Usage
## S3 method for class 'boot'
tidy(
x,
conf.int = FALSE,
conf.level = 0.95,
conf.method = c("perc", "bca", "basic", "norm"),
exponentiate = FALSE,
...
)
Arguments
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
|
Details
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.
Value
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. |
See Also
tidy()
, boot::boot()
, boot::tsboot()
, boot::boot.ci()
,
rsample::bootstraps()
Examples
# 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 a(n) btergm object
Description
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.
Usage
## S3 method for class 'btergm'
tidy(x, conf.level = 0.95, exponentiate = FALSE, ...)
Arguments
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
|
Value
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. |
See Also
Examples
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 a(n) cch object
Description
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.
Usage
## S3 method for class 'cch'
tidy(x, conf.level = 0.95, ...)
Arguments
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
|
Value
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. |
See Also
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()
Examples
# 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 a(n) cld object
Description
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.
Usage
## S3 method for class 'cld'
tidy(x, ...)
Arguments
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
A tibble::tibble()
with columns:
contrast |
Levels being compared. |
letters |
Compact letter display denoting all pair-wise comparisons. |
See Also
tidy()
, multcomp::cld()
, multcomp::summary.glht()
,
multcomp::confint.glht()
, multcomp::glht()
Other multcomp tidiers:
tidy.confint.glht()
,
tidy.glht()
,
tidy.summary.glht()
Examples
# 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 a(n) clm object
Description
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.
Usage
## S3 method for class 'clm'
tidy(
x,
conf.int = FALSE,
conf.level = 0.95,
conf.type = c("profile", "Wald"),
exponentiate = FALSE,
...
)
Arguments
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
|
Details
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.
Value
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. |
See Also
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()
Examples
# 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 a(n) clmm object
Description
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.
Usage
## S3 method for class 'clmm'
tidy(x, conf.int = FALSE, conf.level = 0.95, exponentiate = FALSE, ...)
Arguments
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
|
Value
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. |
Note
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.
See Also
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()
Examples
# 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 a(n) coeftest object
Description
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.
Usage
## S3 method for class 'coeftest'
tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
Arguments
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
|
Value
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. |
See Also
Examples
# 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 a(n) confint.glht object
Description
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.
Usage
## S3 method for class 'confint.glht'
tidy(x, ...)
Arguments
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
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. |
See Also
tidy()
, multcomp::confint.glht()
, multcomp::glht()
Other multcomp tidiers:
tidy.cld()
,
tidy.glht()
,
tidy.summary.glht()
Examples
# 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 a(n) confusionMatrix object
Description
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.
Usage
## S3 method for class 'confusionMatrix'
tidy(x, by_class = TRUE, ...)
Arguments
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
|
Value
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. |
See Also
tidy()
, caret::confusionMatrix()
Examples
# 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 a(n) coxph object
Description
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.
Usage
## S3 method for class 'coxph'
tidy(x, exponentiate = FALSE, conf.int = FALSE, conf.level = 0.95, ...)
Arguments
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 |
Value
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. |
See Also
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()
Examples
# 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 a(n) cmprsk object
Description
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.
Usage
## S3 method for class 'crr'
tidy(x, exponentiate = FALSE, conf.int = FALSE, conf.level = 0.95, ...)
Arguments
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
|
Value
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. |
See Also
Other cmprsk tidiers:
glance.crr()
Examples
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 a(n) cv.glmnet object
Description
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.
Usage
## S3 method for class 'cv.glmnet'
tidy(x, ...)
Arguments
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
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 |
See Also
Other glmnet tidiers:
glance.cv.glmnet()
,
glance.glmnet()
,
tidy.glmnet()
Examples
# 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
Description
(Deprecated) Tidy density objects
Usage
## S3 method for class 'density'
tidy(x, ...)
Arguments
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
A tibble::tibble with two columns: points x
where the density
is estimated, and estimated density y
.
See Also
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
Description
(Deprecated) Tidy dist objects
Usage
## S3 method for class 'dist'
tidy(x, diagonal = attr(x, "Diag"), upper = attr(x, "Upper"), ...)
Arguments
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
|
Details
If the distance matrix does not include an upper triangle and/or diagonal, the tidied version will not either.
Value
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 |
See Also
Other deprecated:
bootstrap()
,
confint_tidy()
,
data.frame_tidiers
,
finish_glance()
,
fix_data_frame()
,
summary_tidiers
,
tidy.density()
,
tidy.ftable()
,
tidy.numeric()
Examples
cars_dist <- dist(t(mtcars[, 1:4]))
cars_dist
tidy(cars_dist)
tidy(cars_dist, upper = TRUE)
tidy(cars_dist, diagonal = TRUE)
Tidy a(n) drc object
Description
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.
Usage
## S3 method for class 'drc'
tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
Arguments
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
|
Details
The tibble has one row for each curve and term in the regression.
The curveid
column indicates the curve.
Value
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. |
See Also
Other drc tidiers:
augment.drc()
,
glance.drc()
Examples
# 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 a(n) emmGrid object
Description
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.
Usage
## S3 method for class 'emmGrid'
tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
Arguments
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 |
Details
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()
.
Value
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 |
See Also
tidy()
, emmeans::ref_grid()
, emmeans::emmeans()
,
emmeans::contrast()
Other emmeans tidiers:
tidy.lsmobj()
,
tidy.ref.grid()
,
tidy.summary_emm()
Examples
# 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 a(n) epi.2by2 object
Description
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.
Usage
## S3 method for class 'epi.2by2'
tidy(x, parameters = c("moa", "stat"), ...)
Arguments
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
|
Details
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.
Value
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 |
See Also
Examples
# 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 a(n) ergm object
Description
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.
Usage
## S3 method for class 'ergm'
tidy(x, conf.int = FALSE, conf.level = 0.95, exponentiate = FALSE, ...)
Arguments
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 |
Value
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 |
References
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/.
See Also
tidy()
, ergm::ergm()
, ergm::control.ergm()
,
ergm::summary()
Other ergm tidiers:
glance.ergm()
Examples
# 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 a(n) factanal object
Description
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.
Usage
## S3 method for class 'factanal'
tidy(x, ...)
Arguments
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
A tibble::tibble()
with columns:
variable |
Variable under consideration. |
uniqueness |
Proportion of residual, or unexplained variance |
flX |
Factor loading for level X. |
See Also
Other factanal tidiers:
augment.factanal()
,
glance.factanal()
Examples
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 a(n) felm object
Description
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.
Usage
## S3 method for class 'felm'
tidy(
x,
conf.int = FALSE,
conf.level = 0.95,
fe = FALSE,
se.type = c("default", "iid", "robust", "cluster"),
...
)
Arguments
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
|
Value
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. |
See Also
Other felm tidiers:
augment.felm()
Examples
# 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 a(n) fitdistr object
Description
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.
Usage
## S3 method for class 'fitdistr'
tidy(x, ...)
Arguments
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
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. |
See Also
Other fitdistr tidiers:
glance.fitdistr()
Examples
# 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 a(n) fixest object
Description
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.
Usage
## S3 method for class 'fixest'
tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
Arguments
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 |
Details
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)
Value
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. |
See Also
tidy()
, fixest::feglm()
, fixest::fenegbin()
,
fixest::feNmlm()
, fixest::femlm()
, fixest::feols()
, fixest::fepois()
Other fixest tidiers:
augment.fixest()
Examples
# 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.
(Deprecated) Tidy ftable objects
Description
This function is deprecated. Please use tibble::as_tibble()
instead.
Usage
## S3 method for class 'ftable'
tidy(x, ...)
Arguments
x |
An |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
An ftable contains a "flat" contingency table. This melts it into a
tibble::tibble with one column for each variable, then a Freq
column.
See Also
Other deprecated:
bootstrap()
,
confint_tidy()
,
data.frame_tidiers
,
finish_glance()
,
fix_data_frame()
,
summary_tidiers
,
tidy.density()
,
tidy.dist()
,
tidy.numeric()
Tidy a(n) gam object
Description
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.
Usage
## S3 method for class 'gam'
tidy(
x,
parametric = FALSE,
conf.int = FALSE,
conf.level = 0.95,
exponentiate = FALSE,
...
)
Arguments
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
|
Details
When parametric = FALSE
return columns edf
and ref.df
rather
than estimate
and std.error
.
Value
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' |
See Also
Other mgcv tidiers:
glance.gam()
Examples
# 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 a(n) Gam object
Description
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.
Usage
## S3 method for class 'Gam'
tidy(x, ...)
Arguments
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Details
Tidy gam
objects created by calls to mgcv::gam()
with
tidy.gam()
.
Value
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. |
See Also
tidy()
, gam::gam()
, tidy.anova()
, tidy.gam()
Other gam tidiers:
glance.Gam()
Examples
# 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 a(n) garch object
Description
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.
Usage
## S3 method for class 'garch'
tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
Arguments
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
|
Value
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. |
See Also
Other garch tidiers:
glance.garch()
Examples
# 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 a(n) geeglm object
Description
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.
Usage
## S3 method for class 'geeglm'
tidy(x, conf.int = FALSE, conf.level = 0.95, exponentiate = FALSE, ...)
Arguments
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
|
Details
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.
Value
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. |
See Also
Examples
# 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 a(n) glht object
Description
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.
Usage
## S3 method for class 'glht'
tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
Arguments
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 |
Value
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. |
See Also
Other multcomp tidiers:
tidy.cld()
,
tidy.confint.glht()
,
tidy.summary.glht()
Examples
# 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 a(n) glm object
Description
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.
Usage
## S3 method for class 'glm'
tidy(x, conf.int = FALSE, conf.level = 0.95, exponentiate = FALSE, ...)
Arguments
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
|
See Also
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 a(n) glmnet object
Description
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.
Usage
## S3 method for class 'glmnet'
tidy(x, return_zeros = FALSE, ...)
Arguments
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
|
Details
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.
Value
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. |
See Also
Other glmnet tidiers:
glance.cv.glmnet()
,
glance.glmnet()
,
tidy.cv.glmnet()
Examples
# 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 a(n) glmrob object
Description
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.
Usage
## S3 method for class 'glmrob'
tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
Arguments
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
|
Details
For tidiers for robust models from the MASS package see
tidy.rlm()
.
Value
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. |
See Also
Other robustbase tidiers:
augment.glmrob()
,
augment.lmrob()
,
glance.lmrob()
,
tidy.lmrob()
Examples
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 a(n) glmRob object
Description
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.
Usage
## S3 method for class 'glmRob'
tidy(x, ...)
Arguments
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Details
For tidiers for robust models from the MASS package see
tidy.rlm()
.
See Also
Other robust tidiers:
augment.lmRob()
,
glance.glmRob()
,
glance.lmRob()
,
tidy.lmRob()
Examples
# 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 a(n) gmm object
Description
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.
Usage
## S3 method for class 'gmm'
tidy(x, conf.int = FALSE, conf.level = 0.95, exponentiate = FALSE, ...)
Arguments
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
|
Value
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. |
See Also
Other gmm tidiers:
glance.gmm()
Examples
# 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)
Tidy/glance a(n) htest object
Description
For models that have only a single component, the tidy()
and
glance()
methods are identical. Please see the documentation for both
of those methods.
Usage
## S3 method for class 'htest'
tidy(x, ...)
## S3 method for class 'htest'
glance(x, ...)
Arguments
x |
An |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
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. |
See Also
tidy()
, stats::cor.test()
, stats::t.test()
,
stats::wilcox.test()
, stats::chisq.test()
Other htest tidiers:
augment.htest()
,
tidy.pairwise.htest()
,
tidy.power.htest()
Examples
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 a(n) ivreg object
Description
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.
Usage
## S3 method for class 'ivreg'
tidy(x, conf.int = FALSE, conf.level = 0.95, instruments = FALSE, ...)
Arguments
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
|
Details
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.
Value
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. |
See Also
Other ivreg tidiers:
augment.ivreg()
,
glance.ivreg()
Examples
# 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 a(n) kappa object
Description
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.
Usage
## S3 method for class 'kappa'
tidy(x, ...)
Arguments
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Details
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.
Value
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'. |
See Also
Examples
# 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 a(n) kde object
Description
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.
Usage
## S3 method for class 'kde'
tidy(x, ...)
Arguments
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Details
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.
Value
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. |
See Also
Examples
# 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 a(n) Kendall object
Description
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.
Usage
## S3 method for class 'Kendall'
tidy(x, ...)
Arguments
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
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. |
See Also
tidy()
, Kendall::Kendall()
, Kendall::MannKendall()
,
Kendall::SeasonalMannKendall()
Examples
# 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 a(n) kmeans object
Description
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.
Usage
## S3 method for class 'kmeans'
tidy(x, col.names = colnames(x$centers), ...)
Arguments
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
|
Value
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. |
See Also
Other kmeans tidiers:
augment.kmeans()
,
glance.kmeans()
Examples
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 a(n) lavaan object
Description
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.
Usage
## S3 method for class 'lavaan'
tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
Arguments
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 |
Value
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. |
See Also
tidy()
, lavaan::cfa()
, lavaan::sem()
,
lavaan::parameterEstimates()
Other lavaan tidiers:
glance.lavaan()
Examples
# 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 a(n) lm object
Description
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.
Usage
## S3 method for class 'lm'
tidy(x, conf.int = FALSE, conf.level = 0.95, exponentiate = FALSE, ...)
Arguments
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
|
Details
If the linear model is an mlm
object (multiple linear model),
there is an additional column response
. See tidy.mlm()
.
Value
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. |
See Also
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()
Examples
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 a(n) lm.beta object
Description
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.
Usage
## S3 method for class 'lm.beta'
tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
Arguments
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
|
Details
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
.
Value
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. |
See Also
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()
Examples
# 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 a(n) lmodel2 object
Description
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.
Usage
## S3 method for class 'lmodel2'
tidy(x, ...)
Arguments
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Details
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")
.
Value
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 |
See Also
Other lmodel2 tidiers:
glance.lmodel2()
Examples
# 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 a(n) lmrob object
Description
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.
Usage
## S3 method for class 'lmrob'
tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
Arguments
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
|
Details
For tidiers for robust models from the MASS package see
tidy.rlm()
.
See Also
Other robustbase tidiers:
augment.glmrob()
,
augment.lmrob()
,
glance.lmrob()
,
tidy.glmrob()
Examples
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 a(n) lmRob object
Description
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.
Usage
## S3 method for class 'lmRob'
tidy(x, ...)
Arguments
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Details
For tidiers for robust models from the MASS package see
tidy.rlm()
.
See Also
Other robust tidiers:
augment.lmRob()
,
glance.glmRob()
,
glance.lmRob()
,
tidy.glmRob()
Examples
# 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 a(n) lsmobj object
Description
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.
Usage
## S3 method for class 'lsmobj'
tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
Arguments
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 |
Details
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()
.
Value
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 |
See Also
tidy()
, emmeans::ref_grid()
, emmeans::emmeans()
,
emmeans::contrast()
Other emmeans tidiers:
tidy.emmGrid()
,
tidy.ref.grid()
,
tidy.summary_emm()
Examples
# 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 a(n) manova object
Description
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.
Usage
## S3 method for class 'manova'
tidy(x, test = "Pillai", ...)
Arguments
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
|
Details
Depending on which test statistic is specified only one of pillai
,
wilks
, hl
or roy
is included.
Value
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. |
See Also
tidy()
, stats::summary.manova()
Other anova tidiers:
glance.anova()
,
glance.aov()
,
tidy.TukeyHSD()
,
tidy.anova()
,
tidy.aov()
,
tidy.aovlist()
Examples
npk2 <- within(npk, foo <- rnorm(24))
m <- manova(cbind(yield, foo) ~ block + N * P * K, npk2)
tidy(m)
Tidy a(n) map object
Description
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.
Usage
## S3 method for class 'map'
tidy(x, ...)
Arguments
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
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.
See Also
Examples
# 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 a(n) margins object
Description
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.
Usage
## S3 method for class 'margins'
tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
Arguments
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
|
Details
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.
Value
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. |
See Also
Examples
# 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 a(n) Mclust object
Description
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.
Usage
## S3 method for class 'Mclust'
tidy(x, ...)
Arguments
x |
An |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
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. |
See Also
Other mclust tidiers:
augment.Mclust()
Examples
# 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 a(n) mediate object
Description
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.
Usage
## S3 method for class 'mediate'
tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
Arguments
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
|
Details
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.
Value
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. |
See Also
Examples
# 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 a(n) mfx object
Description
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).
Usage
## 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, ...)
Arguments
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
|
Details
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.
Value
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. |
See Also
tidy()
, mfx::logitmfx()
, mfx::negbinmfx()
, mfx::poissonmfx()
, mfx::probitmfx()
Other mfx tidiers:
augment.betamfx()
,
augment.mfx()
,
glance.betamfx()
,
glance.mfx()
,
tidy.betamfx()
Examples
# 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 a(n) mjoint object
Description
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.
Usage
## S3 method for class 'mjoint'
tidy(
x,
component = "survival",
conf.int = FALSE,
conf.level = 0.95,
boot_se = NULL,
...
)
Arguments
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
|
Value
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. |
See Also
tidy()
, joineRML::mjoint()
, joineRML::bootSE()
Other mjoint tidiers:
glance.mjoint()
Examples
# 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 a(n) mle2 object
Description
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.
Usage
## S3 method for class 'mle2'
tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
Arguments
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
|
Value
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. |
See Also
tidy()
, bbmle::mle2()
, tidy_optim()
Examples
# 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 a(n) mlm object
Description
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.
Usage
## S3 method for class 'mlm'
tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
Arguments
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
|
Details
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
.
Value
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. |
See Also
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()
Examples
# fit model
mod <- lm(cbind(mpg, disp) ~ wt, mtcars)
# summarize model fit with tidiers
tidy(mod, conf.int = TRUE)
Tidying methods for logit models
Description
These methods tidy the coefficients of mnl and nl models generated
by the functions of the mlogit
package.
Usage
## S3 method for class 'mlogit'
tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
Arguments
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
|
Value
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. |
See Also
Other mlogit tidiers:
augment.mlogit()
,
glance.mlogit()
Examples
# 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 a(n) muhaz object
Description
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.
Usage
## S3 method for class 'muhaz'
tidy(x, ...)
Arguments
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
A tibble::tibble()
with columns:
time |
Point in time. |
estimate |
Estimated hazard rate. |
See Also
Other muhaz tidiers:
glance.muhaz()
Examples
# 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)
Tidying methods for multinomial logistic regression models
Description
These methods tidy the coefficients of multinomial logistic regression
models generated by multinom
of the nnet
package.
Usage
## S3 method for class 'multinom'
tidy(x, conf.int = FALSE, conf.level = 0.95, exponentiate = FALSE, ...)
Arguments
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
|
Value
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. |
See Also
Other multinom tidiers:
glance.multinom()
Examples
# 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 a(n) negbin object
Description
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.
Usage
## S3 method for class 'negbin'
tidy(x, conf.int = FALSE, conf.level = 0.95, exponentiate = FALSE, ...)
Arguments
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 |
See Also
Other glm.nb tidiers:
glance.negbin()
Examples
# 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 a(n) nlrq object
Description
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.
Usage
## S3 method for class 'nlrq'
tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
Arguments
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
|
Value
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. |
See Also
Other quantreg tidiers:
augment.nlrq()
,
augment.rq()
,
augment.rqs()
,
glance.nlrq()
,
glance.rq()
,
tidy.rq()
,
tidy.rqs()
Examples
# 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 a(n) nls object
Description
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.
Usage
## S3 method for class 'nls'
tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
Arguments
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
|
Value
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. |
See Also
tidy, stats::nls()
, stats::summary.nls()
Other nls tidiers:
augment.nls()
,
glance.nls()
Examples
# 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)
Tidy atomic vectors
Description
Vector tidiers are deprecated and will be removed from an upcoming release of broom.
Usage
## S3 method for class 'numeric'
tidy(x, ...)
## S3 method for class 'character'
tidy(x, ...)
## S3 method for class 'logical'
tidy(x, ...)
Arguments
x |
An object of class "numeric", "integer", "character", or "logical". Most likely a named vector |
... |
Extra arguments (not used) |
Details
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.
See Also
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()
Examples
## Not run:
x <- 1:5
names(x) <- letters[1:5]
tidy(x)
## End(Not run)
Tidy a(n) orcutt object
Description
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.
Usage
## S3 method for class 'orcutt'
tidy(x, ...)
Arguments
x |
An |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
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. |
See Also
Other orcutt tidiers:
glance.orcutt()
Examples
# 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 a(n) pairwise.htest object
Description
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.
Usage
## S3 method for class 'pairwise.htest'
tidy(x, ...)
Arguments
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Details
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.
Value
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. |
See Also
stats::pairwise.t.test()
, stats::pairwise.wilcox.test()
,
tidy()
Other htest tidiers:
augment.htest()
,
tidy.htest()
,
tidy.power.htest()
Examples
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 a(n) pam object
Description
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.
Usage
## S3 method for class 'pam'
tidy(x, col.names = paste0("x", 1:ncol(x$medoids)), ...)
Arguments
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
|
Details
For examples, see the pam vignette.
Value
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. |
See Also
Other pam tidiers:
augment.pam()
,
glance.pam()
Examples
# 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 a(n) plm object
Description
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.
Usage
## S3 method for class 'plm'
tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
Arguments
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
|
Value
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. |
See Also
Other plm tidiers:
augment.plm()
,
glance.plm()
Examples
# 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 a(n) poLCA object
Description
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.
Usage
## S3 method for class 'poLCA'
tidy(x, ...)
Arguments
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
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 |
See Also
Other poLCA tidiers:
augment.poLCA()
,
glance.poLCA()
Examples
# 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 a(n) polr object
Description
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.
Usage
## S3 method for class 'polr'
tidy(
x,
conf.int = FALSE,
conf.level = 0.95,
exponentiate = FALSE,
p.values = FALSE,
...
)
Arguments
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
|
Details
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.
Value
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. |
See Also
Other ordinal tidiers:
augment.clm()
,
augment.polr()
,
glance.clm()
,
glance.clmm()
,
glance.polr()
,
glance.svyolr()
,
tidy.clm()
,
tidy.clmm()
,
tidy.svyolr()
Examples
# 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 a(n) power.htest object
Description
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.
Usage
## S3 method for class 'power.htest'
tidy(x, ...)
Arguments
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
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). |
See Also
Other htest tidiers:
augment.htest()
,
tidy.htest()
,
tidy.pairwise.htest()
Examples
ptt <- power.t.test(n = 2:30, delta = 1)
tidy(ptt)
library(ggplot2)
ggplot(tidy(ptt), aes(n, power)) +
geom_line()
Tidy a(n) prcomp object
Description
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.
Usage
## S3 method for class 'prcomp'
tidy(x, matrix = "u", ...)
Arguments
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
|
Details
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.
Value
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). |
See Also
Other svd tidiers:
augment.prcomp()
,
tidy_irlba()
,
tidy_svd()
Examples
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 a(n) pyears object
Description
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.
Usage
## S3 method for class 'pyears'
tidy(x, ...)
Arguments
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Details
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
.
Value
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 |
See Also
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()
Examples
# 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 a(n) rcorr object
Description
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.
Usage
## S3 method for class 'rcorr'
tidy(x, diagonal = FALSE, ...)
Arguments
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
|
Details
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.
Value
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 |
See Also
Examples
# 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 a(n) ref.grid object
Description
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.
Usage
## S3 method for class 'ref.grid'
tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
Arguments
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 |
Details
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()
.
Value
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 |
See Also
tidy()
, emmeans::ref_grid()
, emmeans::emmeans()
,
emmeans::contrast()
Other emmeans tidiers:
tidy.emmGrid()
,
tidy.lsmobj()
,
tidy.summary_emm()
Examples
# 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 a(n) regsubsets object
Description
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.
Usage
## S3 method for class 'regsubsets'
tidy(x, ...)
Arguments
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
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. |
See Also
Examples
# load libraries for models and data
library(leaps)
# fit model
all_fits <- regsubsets(hp ~ ., mtcars)
# summarize model fit with tidiers
tidy(all_fits)
Tidy a(n) ridgelm object
Description
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.
Usage
## S3 method for class 'ridgelm'
tidy(x, ...)
Arguments
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
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 |
See Also
Other ridgelm tidiers:
glance.ridgelm()
Examples
# 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 a(n) rlm object
Description
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.
Usage
## S3 method for class 'rlm'
tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
Arguments
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
|
See Also
Other rlm tidiers:
augment.rlm()
,
glance.rlm()
Tidy a(n) rma object
Description
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.
Usage
## S3 method for class 'rma'
tidy(
x,
conf.int = FALSE,
conf.level = 0.95,
exponentiate = FALSE,
include_studies = FALSE,
measure = "GEN",
...
)
Arguments
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
|
Value
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) |
Examples
# 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 a(n) roc object
Description
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.
Usage
## S3 method for class 'roc'
tidy(x, ...)
Arguments
x |
An |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
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. |
See Also
Examples
# 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 a(n) rq object
Description
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.
Usage
## S3 method for class 'rq'
tidy(x, se.type = NULL, conf.int = FALSE, conf.level = 0.95, ...)
Arguments
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 |
Details
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.
Value
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. |
See Also
Other quantreg tidiers:
augment.nlrq()
,
augment.rq()
,
augment.rqs()
,
glance.nlrq()
,
glance.rq()
,
tidy.nlrq()
,
tidy.rqs()
Examples
# 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 a(n) rqs object
Description
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.
Usage
## S3 method for class 'rqs'
tidy(x, se.type = "rank", conf.int = FALSE, conf.level = 0.95, ...)
Arguments
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 |
Details
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.
Value
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. |
See Also
Other quantreg tidiers:
augment.nlrq()
,
augment.rq()
,
augment.rqs()
,
glance.nlrq()
,
glance.rq()
,
tidy.nlrq()
,
tidy.rq()
Examples
# 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
Tidying methods for spatially autoregressive models
Description
These methods tidy the coefficients of spatial autoregression
models generated by functions in the spatialreg
package.
Usage
## S3 method for class 'sarlm'
tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
Arguments
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
|
Value
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. |
See Also
tidy()
, spatialreg::lagsarlm()
, spatialreg::errorsarlm()
,
spatialreg::sacsarlm()
Other spatialreg tidiers:
augment.sarlm()
,
glance.sarlm()
Examples
# 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 a(n) spec object
Description
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.
Usage
## S3 method for class 'spec'
tidy(x, ...)
Arguments
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
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. |
See Also
Other time series tidiers:
tidy.acf()
,
tidy.ts()
,
tidy.zoo()
Examples
spc <- spectrum(lh)
tidy(spc)
library(ggplot2)
ggplot(tidy(spc), aes(freq, spec)) +
geom_line()
Tidy a(n) speedglm object
Description
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.
Usage
## S3 method for class 'speedglm'
tidy(x, conf.int = FALSE, conf.level = 0.95, exponentiate = FALSE, ...)
Arguments
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
|
Value
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. |
See Also
Other speedlm tidiers:
augment.speedlm()
,
glance.speedglm()
,
glance.speedlm()
,
tidy.speedlm()
Examples
# 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 a(n) speedlm object
Description
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.
Usage
## S3 method for class 'speedlm'
tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
Arguments
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
|
Value
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. |
See Also
speedglm::speedlm()
, tidy.lm()
Other speedlm tidiers:
augment.speedlm()
,
glance.speedglm()
,
glance.speedlm()
,
tidy.speedglm()
Examples
# 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 a(n) summary_emm object
Description
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.
Usage
## S3 method for class 'summary_emm'
tidy(x, null.value = NULL, ...)
Arguments
x |
A |
null.value |
Value to which estimate is compared. |
... |
Additional arguments passed to |
Details
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()
.
Value
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 |
See Also
tidy()
, emmeans::ref_grid()
, emmeans::emmeans()
,
emmeans::contrast()
Other emmeans tidiers:
tidy.emmGrid()
,
tidy.lsmobj()
,
tidy.ref.grid()
Examples
# 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 a(n) summary.glht object
Description
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.
Usage
## S3 method for class 'summary.glht'
tidy(x, ...)
Arguments
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
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. |
See Also
tidy()
, multcomp::summary.glht()
, multcomp::glht()
Other multcomp tidiers:
tidy.cld()
,
tidy.confint.glht()
,
tidy.glht()
Examples
# 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 a(n) summary.lm object
Description
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.
Usage
## S3 method for class 'summary.lm'
tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
Arguments
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
|
Details
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.
Value
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. |
See Also
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()
Examples
# 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 a(n) survdiff object
Description
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.
Usage
## S3 method for class 'survdiff'
tidy(x, ...)
Arguments
x |
An |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
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. |
See Also
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()
Examples
# 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 a(n) survexp object
Description
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.
Usage
## S3 method for class 'survexp'
tidy(x, ...)
Arguments
x |
An |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
A tibble::tibble()
with columns:
n.risk |
Number of individuals at risk at time zero. |
time |
Point in time. |
estimate |
Estimate survival |
See Also
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()
Examples
# 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 a(n) survfit object
Description
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.
Usage
## S3 method for class 'survfit'
tidy(x, ...)
Arguments
x |
An |
... |
For |
Value
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 |
See Also
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()
Examples
# 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 a(n) survreg object
Description
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.
Usage
## S3 method for class 'survreg'
tidy(x, conf.level = 0.95, conf.int = FALSE, ...)
Arguments
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
|
Value
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. |
See Also
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()
Examples
# 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 a(n) svyglm object
Description
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.
Usage
## S3 method for class 'svyglm'
tidy(x, conf.int = FALSE, conf.level = 0.95, exponentiate = FALSE, ...)
Arguments
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
|
See Also
survey::svyglm()
, stats::glm()
Tidy a(n) svyolr object
Description
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.
Usage
## S3 method for class 'svyolr'
tidy(x, conf.int = FALSE, conf.level = 0.95, exponentiate = FALSE, ...)
Arguments
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
|
Details
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.
Value
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. |
See Also
Other ordinal tidiers:
augment.clm()
,
augment.polr()
,
glance.clm()
,
glance.clmm()
,
glance.polr()
,
glance.svyolr()
,
tidy.clm()
,
tidy.clmm()
,
tidy.polr()
Examples
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 a(n) systemfit object
Description
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.
Usage
## S3 method for class 'systemfit'
tidy(x, conf.int = TRUE, conf.level = 0.95, ...)
Arguments
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
|
Details
This tidy method works with any model objects of class systemfit
.
Default returns a tibble of six columns.
Value
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. |
See Also
tidy()
, systemfit::systemfit()
Examples
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 a(n) table object
Description
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.
Usage
## S3 method for class 'table'
tidy(x, ...)
Arguments
x |
A base::table object. |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Details
Directly calls tibble::as_tibble()
on a base::table object.
Value
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()
.
See Also
Tidy a(n) ts object
Description
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.
Usage
## S3 method for class 'ts'
tidy(x, ...)
Arguments
x |
A univariate or multivariate |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Details
series
column is only present for multivariate ts
objects.
Value
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. |
See Also
Other time series tidiers:
tidy.acf()
,
tidy.spec()
,
tidy.zoo()
Examples
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 a(n) TukeyHSD object
Description
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.
Usage
## S3 method for class 'TukeyHSD'
tidy(x, ...)
Arguments
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
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. |
See Also
Other anova tidiers:
glance.anova()
,
glance.aov()
,
tidy.anova()
,
tidy.aov()
,
tidy.aovlist()
,
tidy.manova()
Examples
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 a(n) varest object
Description
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.
Usage
## S3 method for class 'varest'
tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
Arguments
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 |
Details
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.
Value
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. |
See Also
Examples
# 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 a(n) zoo object
Description
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.
Usage
## S3 method for class 'zoo'
tidy(x, ...)
Arguments
x |
A |
... |
Additional arguments. Not used. Needed to match generic
signature only. Cautionary note: Misspelled arguments will be
absorbed in
|
Value
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. |
See Also
Other time series tidiers:
tidy.acf()
,
tidy.spec()
,
tidy.ts()
Examples
# 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()