Debian Codegraph @

man/augment.clm.Rd

raw
1 % Generated by roxygen2: do not edit by hand
2 % Please edit documentation in R/ordinal-clm.R
3 \name{augment.clm}
4 \alias{augment.clm}
5 \title{Augment data with information from a(n) clm object}
6 \usage{
7 \method{augment}{clm}(
8 x,
9 data = model.frame(x),
10 newdata = NULL,
11 type.predict = c("prob", "class"),
12 ...
13 )
14 }
15 \arguments{
16 \item{x}{A \code{clm} object returned from \code{\link[ordinal:clm]{ordinal::clm()}}.}
17
18 \item{data}{A \link[base:data.frame]{base::data.frame} or \code{\link[tibble:tibble]{tibble::tibble()}} containing the original
19 data that was used to produce the object \code{x}. Defaults to
20 \code{stats::model.frame(x)} so that \code{augment(my_fit)} returns the augmented
21 original data. \strong{Do not} pass new data to the \code{data} argument.
22 Augment will report information such as influence and cooks distance for
23 data passed to the \code{data} argument. These measures are only defined for
24 the original training data.}
25
26 \item{newdata}{A \code{\link[base:data.frame]{base::data.frame()}} or \code{\link[tibble:tibble]{tibble::tibble()}} containing all
27 the original predictors used to create \code{x}. Defaults to \code{NULL}, indicating
28 that nothing has been passed to \code{newdata}. If \code{newdata} is specified,
29 the \code{data} argument will be ignored.}
30
31 \item{type.predict}{Which type of prediction to compute, either \code{"prob"}
32 or \code{"class"}, passed to \code{\link[ordinal:predict]{ordinal::predict.clm()}}. Defaults to \code{"prob"}.}
33
34 \item{...}{Additional arguments. Not used. Needed to match generic
35 signature only. \strong{Cautionary note:} Misspelled arguments will be
36 absorbed in \code{...}, where they will be ignored. If the misspelled
37 argument has a default value, the default value will be used.
38 For example, if you pass \code{conf.lvel = 0.9}, all computation will
39 proceed using \code{conf.level = 0.95}. Two exceptions here are:
40 \itemize{
41 \item \code{tidy()} methods will warn when supplied an \code{exponentiate} argument if
42 it will be ignored.
43 \item \code{augment()} methods will warn when supplied a \code{newdata} argument if it
44 will be ignored.
45 }}
46 }
47 \description{
48 Augment accepts a model object and a dataset and adds
49 information about each observation in the dataset. Most commonly, this
50 includes predicted values in the \code{.fitted} column, residuals in the
51 \code{.resid} column, and standard errors for the fitted values in a \code{.se.fit}
52 column. New columns always begin with a \code{.} prefix to avoid overwriting
53 columns in the original dataset.
54
55 Users may pass data to augment via either the \code{data} argument or the
56 \code{newdata} argument. If the user passes data to the \code{data} argument,
57 it \strong{must} be exactly the data that was used to fit the model
58 object. Pass datasets to \code{newdata} to augment data that was not used
59 during model fitting. This still requires that at least all predictor
60 variable columns used to fit the model are present. If the original outcome
61 variable used to fit the model is not included in \code{newdata}, then no
62 \code{.resid} column will be included in the output.
63
64 Augment will often behave differently depending on whether \code{data} or
65 \code{newdata} is given. This is because there is often information
66 associated with training observations (such as influences or related)
67 measures that is not meaningfully defined for new observations.
68
69 For convenience, many augment methods provide default \code{data} arguments,
70 so that \code{augment(fit)} will return the augmented training data. In these
71 cases, augment tries to reconstruct the original data based on the model
72 object with varying degrees of success.
73
74 The augmented dataset is always returned as a \link[tibble:tibble]{tibble::tibble} with the
75 \strong{same number of rows} as the passed dataset. This means that the passed
76 data must be coercible to a tibble. If a predictor enters the model as part
77 of a matrix of covariates, such as when the model formula uses
78 \code{\link[splines:ns]{splines::ns()}}, \code{\link[stats:poly]{stats::poly()}}, or \code{\link[survival:Surv]{survival::Surv()}}, it is represented
79 as a matrix column.
80
81 We are in the process of defining behaviors for models fit with various
82 \code{na.action} arguments, but make no guarantees about behavior when data is
83 missing at this time.
84 }
85 \examples{
86 \dontshow{if (rlang::is_installed("ordinal")) withAutoprint(\{ # examplesIf}
87
88 # load libraries for models and data
89 library(ordinal)
90
91 # fit model
92 fit <- clm(rating ~ temp * contact, data = wine)
93
94 # summarize model fit with tidiers
95 tidy(fit)
96 tidy(fit, conf.int = TRUE, conf.level = 0.9)
97 tidy(fit, conf.int = TRUE, conf.type = "Wald", exponentiate = TRUE)
98
99 glance(fit)
100 augment(fit, type.predict = "prob")
101 augment(fit, type.predict = "class")
102
103 # ...and again with another model specification
104 fit2 <- clm(rating ~ temp, nominal = ~contact, data = wine)
105
106 tidy(fit2)
107 glance(fit2)
108 \dontshow{\}) # examplesIf}
109 }
110 \seealso{
111 \link{tidy}, \code{\link[ordinal:clm]{ordinal::clm()}}, \code{\link[ordinal:predict]{ordinal::predict.clm()}}
112
113 Other ordinal tidiers:
114 \code{\link{augment.polr}()},
115 \code{\link{glance.clm}()},
116 \code{\link{glance.clmm}()},
117 \code{\link{glance.polr}()},
118 \code{\link{glance.svyolr}()},
119 \code{\link{tidy.clm}()},
120 \code{\link{tidy.clmm}()},
121 \code{\link{tidy.polr}()},
122 \code{\link{tidy.svyolr}()}
123 }
124 \concept{ordinal tidiers}