Debian Codegraph @

R/robustbase-glmrob.R

raw
1 #' @templateVar class glmrob
2 #' @template title_desc_tidy
3 #'
4 #' @param x A `glmrob` object returned from [robustbase::glmrob()].
5 #' @template param_confint
6 #' @template param_unused_dots
7 #'
8 #' @evalRd return_tidy(regression = TRUE)
9 #'
10 #' @details For tidiers for robust models from the \pkg{MASS} package see
11 #' [tidy.rlm()].
12 #'
13 #' @inherit tidy.lmrob examples
14 #'
15 #' @export
16 #' @family robustbase tidiers
17 #' @rdname tidy.robustbase.glmrob
18 #' @seealso [robustbase::glmrob()]
19 tidy.glmrob <- function(x, conf.int = FALSE, conf.level = 0.95, ...) {
20 ret <- coef(summary(x)) |>
21 as_tibble(rownames = "term")
22 names(ret) <- c("term", "estimate", "std.error", "statistic", "p.value")
23
24 if (conf.int) {
25 ci <- stats::confint.default(x, level = conf.level) |>
26 as_tibble()
27
28 names(ci) <- c("conf.low", "conf.high")
29 ret <- ret |>
30 cbind(ci)
31 }
32
33 ret
34 }
35
36
37 #' @templateVar class glmrob
38 #' @template title_desc_augment
39 #'
40 #' @inherit tidy.glmrob params
41 #' @template param_data
42 #' @template param_newdata
43 #' @template param_se_fit
44 #' @template param_type_predict
45 #' @template param_type_residuals
46 #' @template param_unused_dots
47 #'
48 #' @evalRd return_augment()
49 #' @details For tidiers for robust models from the \pkg{MASS} package see
50 #' [tidy.rlm()].
51 #'
52 #' @inherit tidy.lmrob examples
53 #'
54 #' @export
55 #' @family robustbase tidiers
56 #' @rdname augment.robustbase.glmrob
57 #' @seealso [robustbase::glmrob()]
58 augment.glmrob <- function(
59 x,
60 data = model.frame(x),
61 newdata = NULL,
62 type.predict = c("link", "response"),
63 type.residuals = c("deviance", "pearson"),
64 se_fit = FALSE,
65 ...
66 ) {
67 augment_newdata(
68 x,
69 data,
70 newdata,
71 type.predict = type.predict,
72 type.residuals = type.residuals,
73 .se_fit = se_fit
74 )
75 }