Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace degrees_of_freedom() with get_df() #997

Merged
merged 18 commits into from
Jul 23, 2024
Prev Previous commit
Next Next commit
try...
  • Loading branch information
strengejacke committed Jul 23, 2024
commit 1b40884ba31a7d21d9b5772edb97b5ccbf455725
2 changes: 1 addition & 1 deletion R/extract_parameters.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


#' @keywords internal
.extract_parameters_generic <- function(model,

Check warning on line 5 in R/extract_parameters.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/extract_parameters.R,line=5,col=1,[cyclocomp_linter] Reduce the cyclomatic complexity of this function from 68 to at most 40.
ci,
component,
merge_by = c("Parameter", "Component"),
Expand Down Expand Up @@ -451,7 +451,7 @@

# Degrees of freedom
if (.dof_method_ok(model, ci_method)) {
dof <- degrees_of_freedom(model, method = ci_method, verbose = FALSE)
dof <- insight::get_df(x = model, type = ci_method, verbose = FALSE)
} else {
dof <- Inf
}
Expand Down
2 changes: 1 addition & 1 deletion R/methods_flexsurvreg.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ p_value.flexsurvreg <- function(model, ...) {
params <- insight::get_parameters(model)
est <- params$Estimate
se <- standard_error(model)$SE
p <- 2 * stats::pt(abs(est / se), df = degrees_of_freedom(model, method = "any"), lower.tail = FALSE)
p <- 2 * stats::pt(abs(est / se), df = insight::get_df(x = model, type = "wald"), lower.tail = FALSE)
.data_frame(
Parameter = params$Parameter,
p = as.vector(p)
Expand Down
4 changes: 2 additions & 2 deletions R/methods_gee.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ p_value.gee <- function(model, method = NULL, ...) {
if (isTRUE(list(...)$robust) || "vcov" %in% names(list(...))) {
p <- 2 * stats::pt(
abs(cs[, "Estimate"] / cs[, "Robust S.E."]),
df = degrees_of_freedom(model, method = method),
df = insight::get_df(x = model, type = method),
lower.tail = FALSE
)
} else {
p <- 2 * stats::pt(
abs(cs[, "Estimate"] / cs[, "Naive S.E."]),
df = degrees_of_freedom(model, method = method),
df = insight::get_df(x = model, type = method),
lower.tail = FALSE
)
}
Expand Down
2 changes: 1 addition & 1 deletion R/methods_glmgee.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ p_value.glmgee <- function(model,

p <- 2 * stats::pt(
abs(est$Estimate / se$SE),
df = degrees_of_freedom(model, method = method),
df = insight::get_df(x = model, type = method),
lower.tail = FALSE
)

Expand Down
2 changes: 1 addition & 1 deletion R/methods_lm.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ p_value.summary.lm <- function(model, ...) {

#' @export
ci.summary.lm <- function(x, ci = 0.95, method = "residual", ...) {
.ci_generic(model = x, ci = ci, method = method, dof = degrees_of_freedom(x), ...)
.ci_generic(model = x, ci = ci, method = method, dof = insight::get_df(x), ...)
}


Expand Down
Loading