Debian Codegraph @

R/car.R

raw
1 #' @templateVar class durbinWatsonTest
2 #' @template title_desc_tidy_glance
3 #'
4 #' @param x An object of class `durbinWatsonTest` created by a call to
5 #' [car::durbinWatsonTest()].
6 #' @template param_unused_dots
7 #'
8 #' @evalRd return_tidy("p.value", "autocorrelation", "alternative",
9 #' statistic = "Test statistic for Durbin-Watson test.",
10 #' method = "Always `Durbin-Watson Test`."
11 #' )
12 #'
13 #' @examplesIf rlang::is_installed("car")
14 #'
15 #' # load modeling library
16 #' library(car)
17 #'
18 #' # fit model
19 #' dw <- durbinWatsonTest(lm(mpg ~ wt, data = mtcars))
20 #'
21 #' # summarize model fit with tidiers
22 #' tidy(dw)
23 #'
24 #' # same output for all durbinWatsonTests
25 #' glance(dw)
26 #'
27 #' @name durbinWatsonTest_tidiers
28 #' @family car tidiers
29 #' @export
30 #' @seealso [tidy()], [glance()], [car::durbinWatsonTest()]
31 tidy.durbinWatsonTest <- function(x, ...) {
32 tibble(
33 statistic = x$dw,
34 p.value = x$p,
35 autocorrelation = x$r,
36 method = "Durbin-Watson Test",
37 alternative = x$alternative
38 )
39 }
40
41 #' @rdname durbinWatsonTest_tidiers
42 #' @export
43 glance.durbinWatsonTest <- function(x, ...) tidy(x)
44
45
46 #' @templateVar class leveneTest
47 #' @template title_desc_tidy_glance
48 #'
49 #' @param x An object of class `anova` created by a call to
50 #' [car::leveneTest()].
51 #' @template param_unused_dots
52 #'
53 #' @evalRd return_tidy(
54 #' "statistic",
55 #' "p.value",
56 #' "df",
57 #' "df.residual" = "Residual degrees of freedom."
58 #' )
59 #'
60 #' @examplesIf rlang::is_installed("car")
61 #'
62 #' # load libraries for models and data
63 #' library(car)
64 #'
65 #' data(Moore)
66 #'
67 #' lt <- with(Moore, leveneTest(conformity, fcategory))
68 #'
69 #' tidy(lt)
70 #' glance(lt)
71 #'
72 #' @name leveneTest_tidiers
73 #' @family car tidiers
74 #' @export
75 #' @seealso [tidy()], [glance()], [car::leveneTest()]
76 tidy.leveneTest <- function(x, ...) {
77 ret <- tibble::tibble(
78 statistic = x[["F value"]][1],
79 p.value = x[["Pr(>F)"]][1],
80 df = x[["Df"]][1],
81 df.residual = x[["Df"]][2]
82 )
83 ret
84 }