1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150
|
## TODO add ci_method later?
#' @export
model_parameters.betareg <- function(model,
ci = 0.95,
bootstrap = FALSE,
iterations = 1000,
component = "conditional",
standardize = NULL,
exponentiate = FALSE,
p_adjust = NULL,
include_info = getOption("parameters_info", FALSE),
keep = NULL,
drop = NULL,
verbose = TRUE,
...) {
# validation check, warn if unsupported argument is used.
dot_args <- .check_dots(
dots = list(...),
not_allowed = c("vcov", "vcov_args"),
class(model)[1],
verbose = verbose
)
component <- insight::validate_argument(component, c("conditional", "precision", "all"))
if (component == "all") {
merge_by <- c("Parameter", "Component")
} else {
merge_by <- "Parameter"
}
## TODO check merge by
fun_args <- list(
model,
ci = ci,
component = component,
bootstrap = bootstrap,
iterations = iterations,
merge_by = c("Parameter", "Component"),
standardize = standardize,
exponentiate = exponentiate,
p_adjust = p_adjust,
keep_parameters = keep,
drop_parameters = drop,
include_info = include_info,
vcov = NULL,
vcov_args = NULL
)
fun_args <- c(fun_args, dot_args)
out <- do.call(".model_parameters_generic", fun_args)
attr(out, "object_name") <- insight::safe_deparse_symbol(substitute(model))
out
}
#' @export
ci.betareg <- function(x, ci = 0.95, component = "all", verbose = TRUE, ...) {
# validation check, warn if unsupported argument is used.
dot_args <- .check_dots(
dots = list(...),
not_allowed = c("vcov", "vcov_args"),
class(x)[1],
function_name = "ci",
verbose = verbose
)
component <- match.arg(component, choices = c("all", "conditional", "precision"))
.ci_generic(model = x, ci = ci, dof = Inf, component = component, verbose = verbose)
}
#' @export
standard_error.betareg <- function(model, component = "all", verbose = TRUE, ...) {
# validation check, warn if unsupported argument is used.
dot_args <- .check_dots(
dots = list(...),
not_allowed = c("vcov", "vcov_args"),
class(model)[1],
function_name = "standard_error",
verbose = verbose
)
component <- match.arg(component, choices = c("all", "conditional", "precision"))
params <- insight::get_parameters(model)
cs <- do.call(rbind, stats::coef(summary(model)))
se <- cs[, 2]
out <- .data_frame(
Parameter = .remove_backticks_from_string(names(se)),
Component = params$Component,
SE = as.vector(se)
)
if (component != "all") {
out <- out[out$Component == component, ]
}
out
}
#' @export
p_value.betareg <- function(model, component = "all", verbose = TRUE, ...) {
# validation check, warn if unsupported argument is used.
dot_args <- .check_dots(
dots = list(...),
not_allowed = c("vcov", "vcov_args"),
class(model)[1],
function_name = "p_value",
verbose = verbose
)
component <- insight::validate_argument(
component,
c("all", "conditional", "precision")
)
params <- insight::get_parameters(model)
cs <- do.call(rbind, stats::coef(summary(model)))
p <- cs[, 4]
out <- .data_frame(
Parameter = params$Parameter,
Component = params$Component,
p = as.vector(p)
)
if (component != "all") {
out <- out[out$Component == component, ]
}
out
}
#' @export
simulate_model.betareg <- function(model, iterations = 1000, component = "all", ...) {
component <- insight::validate_argument(
component,
c("all", "conditional", "precision")
)
out <- .simulate_model(model, iterations, component = component, ...)
class(out) <- c("parameters_simulate_model", class(out))
attr(out, "object_name") <- insight::safe_deparse_symbol(substitute(model))
out
}
|