Debian Codegraph @

man/glance.coeftest.Rd

raw
1 % Generated by roxygen2: do not edit by hand
2 % Please edit documentation in R/lmtest.R
3 \name{glance.coeftest}
4 \alias{glance.coeftest}
5 \title{Glance at a(n) coeftest object}
6 \usage{
7 \method{glance}{coeftest}(x, ...)
8 }
9 \arguments{
10 \item{x}{A \code{coeftest} object returned from \code{\link[lmtest:coeftest]{lmtest::coeftest()}}.}
11
12 \item{...}{Additional arguments. Not used. Needed to match generic
13 signature only. \strong{Cautionary note:} Misspelled arguments will be
14 absorbed in \code{...}, where they will be ignored. If the misspelled
15 argument has a default value, the default value will be used.
16 For example, if you pass \code{conf.lvel = 0.9}, all computation will
17 proceed using \code{conf.level = 0.95}. Two exceptions here are:
18 \itemize{
19 \item \code{tidy()} methods will warn when supplied an \code{exponentiate} argument if
20 it will be ignored.
21 \item \code{augment()} methods will warn when supplied a \code{newdata} argument if it
22 will be ignored.
23 }}
24 }
25 \description{
26 Glance accepts a model object and returns a \code{\link[tibble:tibble]{tibble::tibble()}}
27 with exactly one row of model summaries. The summaries are typically
28 goodness of fit measures, p-values for hypothesis tests on residuals,
29 or model convergence information.
30
31 Glance never returns information from the original call to the modeling
32 function. This includes the name of the modeling function or any
33 arguments passed to the modeling function.
34
35 Glance does not calculate summary measures. Rather, it farms out these
36 computations to appropriate methods and gathers the results together.
37 Sometimes a goodness of fit measure will be undefined. In these cases
38 the measure will be reported as \code{NA}.
39
40 Glance returns the same number of columns regardless of whether the
41 model matrix is rank-deficient or not. If so, entries in columns
42 that no longer have a well-defined value are filled in with an \code{NA}
43 of the appropriate type.
44 }
45 \note{
46 Because of the way that lmtest::coeftest() retains information about
47 the underlying model object, the returned columns for glance.coeftest() will
48 vary depending on the arguments. Specifically, four columns are returned
49 regardless: "Loglik", "AIC", "BIC", and "nobs". Users can obtain additional
50 columns (e.g. "r.squared", "df") by invoking the "save = TRUE" argument as
51 part of lmtest::coeftest(). See examples.
52
53 As an aside, goodness-of-fit measures such as R-squared are unaffected by the
54 presence of heteroskedasticity. For further discussion see, e.g. chapter 8.1
55 of Wooldridge (2016).
56 }
57 \examples{
58 \dontshow{if (rlang::is_installed("lmtest")) withAutoprint(\{ # examplesIf}
59
60 # load libraries for models and data
61 library(lmtest)
62
63 m <- lm(dist ~ speed, data = cars)
64
65 coeftest(m)
66 tidy(coeftest(m))
67 tidy(coeftest(m, conf.int = TRUE))
68
69 # a very common workflow is to combine lmtest::coeftest with alternate
70 # variance-covariance matrices via the sandwich package. The lmtest
71 # tidiers support this workflow too, enabling you to adjust the standard
72 # errors of your tidied models on the fly.
73 library(sandwich)
74
75 # "HC3" (default) robust SEs
76 tidy(coeftest(m, vcov = vcovHC))
77
78 # "HC2" robust SEs
79 tidy(coeftest(m, vcov = vcovHC, type = "HC2"))
80
81 # N-W HAC robust SEs
82 tidy(coeftest(m, vcov = NeweyWest))
83
84 # the columns of the returned tibble for glance.coeftest() will vary
85 # depending on whether the coeftest object retains the underlying model.
86 # Users can control this with the "save = TRUE" argument of coeftest().
87 glance(coeftest(m))
88 glance(coeftest(m, save = TRUE))
89 \dontshow{\}) # examplesIf}
90 }
91 \references{
92 Wooldridge, Jeffrey M. (2016) \cite{Introductory econometrics: A
93 modern approach.} (6th edition). Nelson Education.
94 }
95 \seealso{
96 \code{\link[=glance]{glance()}}, \code{\link[lmtest:coeftest]{lmtest::coeftest()}}
97 }
98 \concept{coeftest_tidiers}
99 \value{
100 A \code{\link[tibble:tibble]{tibble::tibble()}} with exactly one row and columns:
101 \item{adj.r.squared}{Adjusted R squared statistic, which is like the R squared statistic except taking degrees of freedom into account.}
102 \item{AIC}{Akaike's Information Criterion for the model.}
103 \item{BIC}{Bayesian Information Criterion for the model.}
104 \item{deviance}{Deviance of the model.}
105 \item{df}{Degrees of freedom used by the model.}
106 \item{df.residual}{Residual degrees of freedom.}
107 \item{logLik}{The log-likelihood of the model. [stats::logLik()] may be a useful reference.}
108 \item{nobs}{Number of observations used.}
109 \item{p.value}{P-value corresponding to the test statistic.}
110 \item{r.squared}{R squared statistic, or the percent of variation explained by the model. Also known as the coefficient of determination.}
111 \item{sigma}{Estimated standard error of the residuals.}
112 \item{statistic}{Test statistic.}
113
114 }