Debian Codegraph @

man/augment.htest.Rd

raw
1 % Generated by roxygen2: do not edit by hand
2 % Please edit documentation in R/stats-htest.R
3 \name{augment.htest}
4 \alias{augment.htest}
5 \title{Augment data with information from a(n) htest object}
6 \usage{
7 \method{augment}{htest}(x, ...)
8 }
9 \arguments{
10 \item{x}{An \code{htest} objected, such as those created by \code{\link[stats:cor.test]{stats::cor.test()}},
11 \code{\link[stats:t.test]{stats::t.test()}}, \code{\link[stats:wilcox.test]{stats::wilcox.test()}}, \code{\link[stats:chisq.test]{stats::chisq.test()}}, etc.}
12
13 \item{...}{Additional arguments. Not used. Needed to match generic
14 signature only. \strong{Cautionary note:} Misspelled arguments will be
15 absorbed in \code{...}, where they will be ignored. If the misspelled
16 argument has a default value, the default value will be used.
17 For example, if you pass \code{conf.lvel = 0.9}, all computation will
18 proceed using \code{conf.level = 0.95}. Two exceptions here are:
19 \itemize{
20 \item \code{tidy()} methods will warn when supplied an \code{exponentiate} argument if
21 it will be ignored.
22 \item \code{augment()} methods will warn when supplied a \code{newdata} argument if it
23 will be ignored.
24 }}
25 }
26 \description{
27 Augment accepts a model object and a dataset and adds
28 information about each observation in the dataset. Most commonly, this
29 includes predicted values in the \code{.fitted} column, residuals in the
30 \code{.resid} column, and standard errors for the fitted values in a \code{.se.fit}
31 column. New columns always begin with a \code{.} prefix to avoid overwriting
32 columns in the original dataset.
33
34 Users may pass data to augment via either the \code{data} argument or the
35 \code{newdata} argument. If the user passes data to the \code{data} argument,
36 it \strong{must} be exactly the data that was used to fit the model
37 object. Pass datasets to \code{newdata} to augment data that was not used
38 during model fitting. This still requires that at least all predictor
39 variable columns used to fit the model are present. If the original outcome
40 variable used to fit the model is not included in \code{newdata}, then no
41 \code{.resid} column will be included in the output.
42
43 Augment will often behave differently depending on whether \code{data} or
44 \code{newdata} is given. This is because there is often information
45 associated with training observations (such as influences or related)
46 measures that is not meaningfully defined for new observations.
47
48 For convenience, many augment methods provide default \code{data} arguments,
49 so that \code{augment(fit)} will return the augmented training data. In these
50 cases, augment tries to reconstruct the original data based on the model
51 object with varying degrees of success.
52
53 The augmented dataset is always returned as a \link[tibble:tibble]{tibble::tibble} with the
54 \strong{same number of rows} as the passed dataset. This means that the passed
55 data must be coercible to a tibble. If a predictor enters the model as part
56 of a matrix of covariates, such as when the model formula uses
57 \code{\link[splines:ns]{splines::ns()}}, \code{\link[stats:poly]{stats::poly()}}, or \code{\link[survival:Surv]{survival::Surv()}}, it is represented
58 as a matrix column.
59
60 We are in the process of defining behaviors for models fit with various
61 \code{na.action} arguments, but make no guarantees about behavior when data is
62 missing at this time.
63 }
64 \details{
65 See \code{\link[stats:chisq.test]{stats::chisq.test()}} for more details on
66 how residuals are computed.
67 }
68 \examples{
69
70 tt <- t.test(rnorm(10))
71
72 tidy(tt)
73
74 # the glance output will be the same for each of the below tests
75 glance(tt)
76
77 tt <- t.test(mpg ~ am, data = mtcars)
78
79 tidy(tt)
80
81 wt <- wilcox.test(mpg ~ am, data = mtcars, conf.int = TRUE, exact = FALSE)
82
83 tidy(wt)
84
85 ct <- cor.test(mtcars$wt, mtcars$mpg)
86
87 tidy(ct)
88
89 chit <- chisq.test(xtabs(Freq ~ Sex + Class, data = as.data.frame(Titanic)))
90
91 tidy(chit)
92 augment(chit)
93
94 }
95 \seealso{
96 \code{\link[=augment]{augment()}}, \code{\link[stats:chisq.test]{stats::chisq.test()}}
97
98 Other htest tidiers:
99 \code{\link{tidy.htest}()},
100 \code{\link{tidy.pairwise.htest}()},
101 \code{\link{tidy.power.htest}()}
102 }
103 \concept{htest tidiers}
104 \value{
105 A \code{\link[tibble:tibble]{tibble::tibble()}} with exactly one row and columns:
106 \item{.observed}{Observed count.}
107 \item{.prop}{Proportion of the total.}
108 \item{.row.prop}{Row proportion (2 dimensions table only).}
109 \item{.col.prop}{Column proportion (2 dimensions table only).}
110 \item{.expected}{Expected count under the null hypothesis.}
111 \item{.resid}{Pearson residuals.}
112 \item{.std.resid}{Standardized residual.}
113
114 }