Skip to content

Commit

Permalink
fix, lintr
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke committed Nov 20, 2023
1 parent f66fc39 commit 3734370
Show file tree
Hide file tree
Showing 17 changed files with 79 additions and 82 deletions.
20 changes: 10 additions & 10 deletions R/1_model_parameters.R
Original file line number Diff line number Diff line change
Expand Up @@ -576,14 +576,14 @@ model_parameters.default <- function(model,
ci_method <- "quantile"
}

args <- list(
fun_args <- list(
model,
iterations = iterations,
ci = ci,
ci_method = ci_method
)
args <- c(args, dots)
params <- do.call("bootstrap_parameters", args)
fun_args <- c(fun_args, dots)
params <- do.call("bootstrap_parameters", fun_args)

# Processing, non-bootstrapped parameters
} else {
Expand All @@ -592,7 +592,7 @@ model_parameters.default <- function(model,
ci_method <- "wald"
}

args <- list(
fun_args <- list(
model,
ci = ci,
component = component,
Expand All @@ -607,8 +607,8 @@ model_parameters.default <- function(model,
vcov = vcov,
vcov_args = vcov_args
)
args <- c(args, dots)
params <- do.call(".extract_parameters_generic", args)
fun_args <- c(fun_args, dots)
params <- do.call(".extract_parameters_generic", fun_args)
}


Expand Down Expand Up @@ -686,12 +686,12 @@ model_parameters.glm <- function(model,
# tell user that profiled CIs don't respect vcov-args
if (identical(ci_method, "profile") && (!is.null(vcov) || !is.null(vcov_args)) && isTRUE(verbose)) {
insight::format_alert(
"When `ci_method=\"profile\"`, `vcov` only modifies standard errors, test-statistic and p-values, but not confidence intervals.",
"When `ci_method=\"profile\"`, `vcov` only modifies standard errors, test-statistic and p-values, but not confidence intervals.", # nolint
"Use `ci_method=\"wald\"` to return confidence intervals based on robust standard errors."
)
}

args <- list(
fun_args <- list(
model = model,
ci = ci,
ci_method = ci_method,
Expand All @@ -708,8 +708,8 @@ model_parameters.glm <- function(model,
vcov_args = vcov_args,
verbose = verbose
)
args <- c(args, dots)
out <- do.call(".model_parameters_generic", args)
fun_args <- c(fun_args, dots)
out <- do.call(".model_parameters_generic", fun_args)

attr(out, "object_name") <- insight::safe_deparse_symbol(substitute(model))
out
Expand Down
6 changes: 3 additions & 3 deletions R/3_p_value.R
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,13 @@ p_value.default <- function(model,
if (inherits(vcov, "data.frame") || "SE" %in% colnames(vcov)) {
se <- vcov
} else {
args <- list(model,
fun_args <- list(model,
vcov_args = vcov_args,
vcov = vcov,
verbose = verbose
)
args <- c(args, dots)
se <- do.call("standard_error", args)
fun_args <- c(fun_args, dots)
se <- do.call("standard_error", fun_args)
}

dof <- degrees_of_freedom(model, method = "wald", verbose = FALSE)
Expand Down
4 changes: 2 additions & 2 deletions R/4_standard_error.R
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ standard_error.default <- function(model,

# vcov: function which returns a matrix
if (is.function(vcov)) {
args <- c(list(model), vcov_args, dots)
se <- .safe(sqrt(diag(do.call("vcov", args))))
fun_args <- c(list(model), vcov_args, dots)
se <- .safe(sqrt(diag(do.call("vcov", fun_args))))
}

# vcov: character (with backward compatibility for `robust = TRUE`)
Expand Down
16 changes: 8 additions & 8 deletions R/ci_profile_boot.R
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,14 @@
dot_args <- .check_profile_uniroot_args(...)

if (is.null(profiled)) {
args <- list(x, method = "profile", level = ci, dot_args)
out <- as.data.frame(do.call(stats::confint, args))
fun_args <- list(x, method = "profile", level = ci, dot_args)
out <- as.data.frame(do.call(stats::confint, fun_args))
} else {
args <- list(profiled, level = ci, dot_args)
out <- .safe(as.data.frame(do.call(stats::confint, args)))
fun_args <- list(profiled, level = ci, dot_args)
out <- .safe(as.data.frame(do.call(stats::confint, fun_args)))
if (is.null(out)) {
args <- list(x, method = "profile", level = ci, dot_args)
out <- as.data.frame(do.call(stats::confint, args))
fun_args <- list(x, method = "profile", level = ci, dot_args)
out <- as.data.frame(do.call(stats::confint, fun_args))
}
}
.process_glmmTMB_CI(x, out, ci, component)
Expand All @@ -103,8 +103,8 @@
.ci_uniroot_glmmTMB <- function(x, ci, component, ...) {
# make sure "..." doesn't pass invalid arguments to package TMB
dot_args <- .check_profile_uniroot_args(...)
args <- list(x, level = ci, method = "uniroot", dot_args)
out <- as.data.frame(do.call(stats::confint, args))
fun_args <- list(x, level = ci, method = "uniroot", dot_args)
out <- as.data.frame(do.call(stats::confint, fun_args))
.process_glmmTMB_CI(x, out, ci, component)
}

Expand Down
7 changes: 3 additions & 4 deletions R/dominance_analysis.R
Original file line number Diff line number Diff line change
Expand Up @@ -347,11 +347,10 @@ dominance_analysis <- function(model, sets = NULL, all = NULL,

# quote arguments for domin
for (arg in quote_args) {
if (!(arg %in% names(args))) {
insight::format_error(arg, " in `quote_args` not among arguments in model.")
if (arg %in% names(args)) {
args[[arg]] <- str2lang(paste0("quote(", deparse(args[[arg]]), ")", collapse = ""))
} else {
args[[arg]] <-
str2lang(paste0("quote(", deparse(args[[arg]]), ")", collapse = ""))
insight::format_error(arg, " in `quote_args` not among arguments in model.")
}
}

Expand Down
6 changes: 3 additions & 3 deletions R/methods_betareg.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ model_parameters.betareg <- function(model,

## TODO check merge by

args <- list(
fun_args <- list(
model,
ci = ci,
component = component,
Expand All @@ -48,9 +48,9 @@ model_parameters.betareg <- function(model,
vcov = NULL,
vcov_args = NULL
)
args <- c(args, dot_args)
fun_args <- c(fun_args, dot_args)

out <- do.call(".model_parameters_generic", args)
out <- do.call(".model_parameters_generic", fun_args)
attr(out, "object_name") <- insight::safe_deparse_symbol(substitute(model))
out
}
Expand Down
6 changes: 3 additions & 3 deletions R/methods_brglm2.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ model_parameters.bracl <- function(model,
merge_by <- "Parameter"
}

args <- list(
fun_args <- list(
model,
ci = ci,
bootstrap = bootstrap,
Expand All @@ -60,9 +60,9 @@ model_parameters.bracl <- function(model,
vcov = NULL,
vcov_args = NULL
)
args <- c(args, dot_args)
fun_args <- c(fun_args, dot_args)

out <- do.call(".model_parameters_generic", args)
out <- do.call(".model_parameters_generic", fun_args)
attr(out, "object_name") <- insight::safe_deparse_symbol(substitute(model))
out
}
Expand Down
6 changes: 3 additions & 3 deletions R/methods_car.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ model_parameters.deltaMethod <- function(model, p_adjust = NULL, verbose = TRUE,
params <- .p_adjust(params, p_adjust, model, verbose)
}

args <- list(
fun_args <- list(
params,
model,
ci = ci,
Expand All @@ -49,9 +49,9 @@ model_parameters.deltaMethod <- function(model, p_adjust = NULL, verbose = TRUE,
summary = FALSE,
verbose = verbose
)
args <- c(args, dots)
fun_args <- c(fun_args, dots)

params <- do.call(".add_model_parameters_attributes", args)
params <- do.call(".add_model_parameters_attributes", fun_args)

class(params) <- c("parameters_model", "see_parameters_model", class(params))
attr(params, "object_name") <- insight::safe_deparse_symbol(substitute(model))
Expand Down
6 changes: 3 additions & 3 deletions R/methods_cgam.R
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ model_parameters.cgam <- function(model,
...
)
} else {
args <- list(
fun_args <- list(
model,
ci = ci,
ci_method = ci_method,
Expand All @@ -74,8 +74,8 @@ model_parameters.cgam <- function(model,
vcov = NULL,
vcov_args = NULL
)
args <- c(args, dot_args)
params <- do.call(".extract_parameters_generic", args)
fun_args <- c(fun_args, dot_args)
params <- do.call(".extract_parameters_generic", fun_args)
}

# fix statistic column
Expand Down
10 changes: 5 additions & 5 deletions R/methods_glmmTMB.R
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ model_parameters.glmmTMB <- function(model,
}
}
} else {
args <- list(
fun_args <- list(
model,
ci = ci,
component = component,
Expand All @@ -100,8 +100,8 @@ model_parameters.glmmTMB <- function(model,
wb_component = wb_component,
summary = summary
)
args <- c(args, dot_args)
params <- do.call(".extract_parameters_generic", args)
fun_args <- c(fun_args, dot_args)
params <- do.call(".extract_parameters_generic", fun_args)
}

# add dispersion parameter
Expand Down Expand Up @@ -131,7 +131,7 @@ model_parameters.glmmTMB <- function(model,
if (verbose) {
insight::format_alert(
"Cannot compute standard errors and confidence intervals for sigma parameter.",
"Your model may suffer from singularity (see '?lme4::isSingular' and '?performance::check_singularity')."
"Your model may suffer from singularity (see '?lme4::isSingular' and '?performance::check_singularity')." # nolint
)
}
c(NA, NA)
Expand All @@ -157,7 +157,7 @@ model_parameters.glmmTMB <- function(model,
params_random <- .extract_random_parameters(model, ci = ci, effects = effects, component = component)
if (length(random_effects) > 1) {
insight::format_alert(
"Cannot extract confidence intervals for random variance parameters from models with more than one grouping factor."
"Cannot extract confidence intervals for random variance parameters from models with more than one grouping factor." # nolint
)
}
} else {
Expand Down
6 changes: 3 additions & 3 deletions R/methods_hglm.R
Original file line number Diff line number Diff line change
Expand Up @@ -223,13 +223,13 @@ p_value.hglm <- function(model,
...) {
dots <- list(...)
dots$component <- NULL
args <- list(
fun_args <- list(
model,
dof = dof,
component = "conditional",
method = method,
verbose = verbose
)
args <- c(args, dots)
do.call("p_value.default", args)
fun_args <- c(fun_args, dots)
do.call("p_value.default", fun_args)
}
12 changes: 6 additions & 6 deletions R/methods_lme4.R
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ model_parameters.merMod <- function(model,
}
}
} else {
args <- list(
fun_args <- list(
model,
ci = ci,
ci_method = ci_method,
Expand All @@ -212,8 +212,8 @@ model_parameters.merMod <- function(model,
vcov = vcov,
vcov_args = vcov_args
)
args <- c(args, dots)
params <- do.call(".extract_parameters_mixed", args)
fun_args <- c(fun_args, dots)
params <- do.call(".extract_parameters_mixed", fun_args)
}

params$Effects <- "fixed"
Expand Down Expand Up @@ -348,12 +348,12 @@ standard_error.merMod <- function(model,
}

if (!is.null(vcov) || isTRUE(dots[["robust"]])) {
args <- list(model,
fun_args <- list(model,
vcov = vcov,
vcov_args = vcov_args
)
args <- c(args, dots)
out <- do.call("standard_error.default", args)
fun_args <- c(fun_args, dots)
out <- do.call("standard_error.default", fun_args)
return(out)
}

Expand Down
6 changes: 3 additions & 3 deletions R/methods_mice.R
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ model_parameters.mipo <- function(model,
merge_by <- "Parameter"
}

args <- list(
fun_args <- list(
model,
ci = ci,
merge_by = merge_by,
Expand All @@ -119,9 +119,9 @@ model_parameters.mipo <- function(model,
vcov = NULL,
vcov_args = NULL
)
args <- c(args, dot_args)
fun_args <- c(fun_args, dot_args)

out <- do.call(".model_parameters_generic", args)
out <- do.call(".model_parameters_generic", fun_args)
attr(out, "object_name") <- insight::safe_deparse_symbol(substitute(model))
out
}
Expand Down
30 changes: 14 additions & 16 deletions R/methods_nestedLogit.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ model_parameters.nestedLogit <- function(model,
# tell user that profiled CIs don't respect vcov-args
if (identical(ci_method, "profile") && (!is.null(vcov) || !is.null(vcov_args)) && isTRUE(verbose)) {
insight::format_alert(
"When `ci_method=\"profile\"`, `vcov` only modifies standard errors, test-statistic and p-values, but not confidence intervals.",
"When `ci_method=\"profile\"`, `vcov` only modifies standard errors, test-statistic and p-values, but not confidence intervals.", # nolint
"Use `ci_method=\"wald\"` to return confidence intervals based on robust standard errors."
)
}

args <- list(
fun_args <- list(
model = model,
ci = ci,
ci_method = ci_method,
Expand All @@ -67,8 +67,8 @@ model_parameters.nestedLogit <- function(model,
vcov = vcov,
vcov_args = vcov_args
)
args <- c(args, dots)
out <- do.call(".model_parameters_generic", args)
fun_args <- c(fun_args, dots)
out <- do.call(".model_parameters_generic", fun_args)

attr(out, "object_name") <- insight::safe_deparse_symbol(substitute(model))
out
Expand All @@ -89,19 +89,17 @@ degrees_of_freedom.nestedLogit <- function(model,
dof <- rep(vapply(model$models, stats::df.residual, numeric(1)), each = nrow(cf))
if (!is.null(component) && !identical(component, "all")) {
comp <- intersect(names(dof), component)
if (!length(comp)) {
if (length(comp)) {
dof <- dof[comp]
} else {
if (verbose) {
insight::format_alert(
paste0(
"No matching model found. Possible values for `component` are ",
toString(paste0("'", names(model$models), "'")),
"."
)
)
insight::format_alert(paste0(
"No matching model found. Possible values for `component` are ",
toString(paste0("'", names(model$models), "'")),
"."
))
}
dof <- Inf
} else {
dof <- dof[comp]
}
}
} else {
Expand All @@ -128,8 +126,8 @@ standard_error.nestedLogit <- function(model,

# vcov: function which returns a matrix
if (is.function(vcov)) {
args <- c(list(model), vcov_args, dots)
se <- .safe(sqrt(diag(do.call("vcov", args))))
fun_args <- c(list(model), vcov_args, dots)
se <- .safe(sqrt(diag(do.call("vcov", fun_args))))
}

# vcov: character (with backward compatibility for `robust = TRUE`)
Expand Down
Loading

0 comments on commit 3734370

Please sign in to comment.