Skip to content

Harnonize arguments #778

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

Merged
merged 3 commits into from
Nov 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: performance
Title: Assessment of Regression Models Performance
Version: 0.12.4.6
Version: 0.12.4.7
Authors@R:
c(person(given = "Daniel",
family = "Lüdecke",
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -4,6 +4,11 @@

* Deprecated arguments and alias-function-names have been removed.

* Argument names in `check_model()` that refer to plot-aesthetics (like
`dot_size`) are now harmonized across *easystats* packages, meaning that
these have been renamed. They now follow the pattern `aesthetic_type`, e.g.
`size_dot` (instead of `dot_size`).

## Changes

* Increased accuracy for `check_convergence()` for *glmmTMB* models.
106 changes: 53 additions & 53 deletions R/check_model.R
Original file line number Diff line number Diff line change
@@ -10,8 +10,8 @@
#' get hints about possible problems.
#'
#' @param x A model object.
#' @param dot_size,line_size Size of line and dot-geoms.
#' @param base_size,title_size,axis_title_size Base font size for axis and plot titles.
#' @param size_dot,size_line Size of line and dot-geoms.
#' @param base_size,size_title,size_axis_title Base font size for axis and plot titles.
#' @param panel Logical, if `TRUE`, plots are arranged as panels; else,
#' single plots for each diagnostic are returned.
#' @param check Character vector, indicating which checks for should be performed
@@ -23,7 +23,7 @@
#' `"linearity"`, and checks for non-constant variance, i.e. for
#' heteroscedasticity, as well as the linear relationship. By default, all
#' possible checks are performed and plotted.
#' @param alpha,dot_alpha The alpha level of the confidence bands and dot-geoms.
#' @param alpha,alpha_dot The alpha level of the confidence bands and dot-geoms.
#' Scalar from 0 to 1.
#' @param colors Character vector with color codes (hex-format). Must be of
#' length 3. First color is usually used for reference lines, second color
@@ -62,7 +62,7 @@
#'
#' @details For Bayesian models from packages **rstanarm** or **brms**,
#' models will be "converted" to their frequentist counterpart, using
#' [`bayestestR::bayesian_as_frequentist`](https://easystats.github.io/bayestestR/reference/convert_bayesian_as_frequentist.html).

Check warning on line 65 in R/check_model.R

GitHub Actions / lint / lint

file=R/check_model.R,line=65,col=121,[line_length_linter] Lines should not be more than 120 characters. This line is 130 characters.

Check warning on line 65 in R/check_model.R

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

file=R/check_model.R,line=65,col=121,[line_length_linter] Lines should not be more than 120 characters. This line is 130 characters.
#' A more advanced model-check for Bayesian models will be implemented at a
#' later stage.
#'
@@ -90,7 +90,7 @@
#' plots are helpful to check model assumptions, they do not necessarily indicate
#' so-called "lack of fit", e.g. missed non-linear relationships or interactions.
#' Thus, it is always recommended to also look at
#' [effect plots, including partial residuals](https://strengejacke.github.io/ggeffects/articles/introduction_partial_residuals.html).

Check warning on line 93 in R/check_model.R

GitHub Actions / lint / lint

file=R/check_model.R,line=93,col=121,[line_length_linter] Lines should not be more than 120 characters. This line is 134 characters.

Check warning on line 93 in R/check_model.R

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

file=R/check_model.R,line=93,col=121,[line_length_linter] Lines should not be more than 120 characters. This line is 134 characters.
#'
#' @section Homogeneity of Variance:
#' This plot checks the assumption of equal variance (homoscedasticity). The
@@ -196,13 +196,13 @@
type = "density",
residual_type = NULL,
show_dots = NULL,
dot_size = 2,
line_size = 0.8,
title_size = 12,
axis_title_size = base_size,
size_dot = 2,
size_line = 0.8,
size_title = 12,
size_axis_title = base_size,
base_size = 10,
alpha = 0.2,
dot_alpha = 0.8,
alpha_dot = 0.8,
colors = c("#3aaf85", "#1b6ca8", "#cd201f"),
theme = "see::theme_lucid",
verbose = FALSE,
@@ -277,14 +277,14 @@
}

attr(assumptions_data, "panel") <- panel
attr(assumptions_data, "dot_size") <- dot_size
attr(assumptions_data, "line_size") <- line_size
attr(assumptions_data, "dot_size") <- size_dot
attr(assumptions_data, "line_size") <- size_line
attr(assumptions_data, "base_size") <- base_size
attr(assumptions_data, "axis_title_size") <- axis_title_size
attr(assumptions_data, "title_size") <- title_size
attr(assumptions_data, "axis_title_size") <- size_axis_title
attr(assumptions_data, "title_size") <- size_title
attr(assumptions_data, "check") <- check
attr(assumptions_data, "alpha") <- alpha
attr(assumptions_data, "dot_alpha") <- dot_alpha
attr(assumptions_data, "dot_alpha") <- alpha_dot
attr(assumptions_data, "show_dots") <- isTRUE(show_dots)
attr(assumptions_data, "detrend") <- detrend
attr(assumptions_data, "colors") <- colors
@@ -328,28 +328,28 @@
type = "density",
residual_type = NULL,
show_dots = NULL,
dot_size = 2,
line_size = 0.8,
title_size = 12,
axis_title_size = base_size,
size_dot = 2,
size_line = 0.8,
size_title = 12,
size_axis_title = base_size,
base_size = 10,
alpha = 0.2,
dot_alpha = 0.8,
alpha_dot = 0.8,
colors = c("#3aaf85", "#1b6ca8", "#cd201f"),
theme = "see::theme_lucid",
verbose = FALSE,
...) {
check_model(bayestestR::bayesian_as_frequentist(x),
dot_size = dot_size,
line_size = line_size,
size_dot = size_dot,
size_line = size_line,
panel = panel,
check = check,
alpha = alpha,
dot_alpha = dot_alpha,
alpha_dot = alpha_dot,
colors = colors,
theme = theme,
base_size = base_size,
axis_title_size = axis_title_size,
size_axis_title = size_axis_title,
detrend = detrend,
show_dots = show_dots,
bandwidth = bandwidth,
@@ -374,26 +374,26 @@
type = "density",
residual_type = NULL,
show_dots = NULL,
dot_size = 2,
line_size = 0.8,
title_size = 12,
axis_title_size = base_size,
size_dot = 2,
size_line = 0.8,
size_title = 12,
size_axis_title = base_size,
base_size = 10,
alpha = 0.2,
dot_alpha = 0.8,
alpha_dot = 0.8,
colors = c("#3aaf85", "#1b6ca8", "#cd201f"),
theme = "see::theme_lucid",
verbose = FALSE,
...) {
check_model(
x$fit,
dot_size = dot_size,
line_size = line_size,
size_dot = size_dot,
size_line = size_line,
panel = panel,
check = check,
alpha = alpha,
axis_title_size = axis_title_size,
dot_alpha = dot_alpha,
size_axis_title = size_axis_title,
alpha_dot = alpha_dot,
colors = colors,
theme = theme,
base_size = base_size,
@@ -417,26 +417,26 @@
type = "density",
residual_type = NULL,
show_dots = NULL,
dot_size = 2,
line_size = 0.8,
title_size = 12,
axis_title_size = base_size,
size_dot = 2,
size_line = 0.8,
size_title = 12,
size_axis_title = base_size,
base_size = 10,
alpha = 0.2,
dot_alpha = 0.8,
alpha_dot = 0.8,
colors = c("#3aaf85", "#1b6ca8", "#cd201f"),
theme = "see::theme_lucid",
verbose = FALSE,
...) {
check_model(
x$fittedModel,
dot_size = dot_size,
line_size = line_size,
size_dot = size_dot,
size_line = size_line,
panel = panel,
check = check,
alpha = alpha,
dot_alpha = dot_alpha,
axis_title_size = axis_title_size,
alpha_dot = alpha_dot,
size_axis_title = size_axis_title,
colors = colors,
theme = theme,
base_size = base_size,
@@ -462,35 +462,35 @@

# multicollinearity --------------
if (any(c("all", "vif") %in% check)) {
dat$VIF <- .diag_vif(model, verbose = verbose)
dat$VIF <- .model_diagnostic_vif(model, verbose = verbose)
}

# Q-Q plot (normality/uniformity of residuals) --------------
if (any(c("all", "qq") %in% check)) {
dat$QQ <- switch(residual_type,
simulated = .safe(simulate_residuals(model, ...)),
.diag_qq(model, model_info = model_info, verbose = verbose)
.model_diagnostic_qq(model, model_info = model_info, verbose = verbose)
)
}

# Random Effects Q-Q plot (normality of BLUPs) --------------
if (any(c("all", "reqq") %in% check)) {
dat$REQQ <- .diag_reqq(model, level = 0.95, model_info = model_info, verbose = verbose)
dat$REQQ <- .model_diagnostic_ranef_qq(model, level = 0.95, model_info = model_info, verbose = verbose)
}

# normal-curve plot (normality of residuals) --------------
if (any(c("all", "normality") %in% check)) {
dat$NORM <- .diag_norm(model, verbose = verbose)
dat$NORM <- .model_diagnostic_normality(model, verbose = verbose)
}

# non-constant variance (heteroskedasticity, liniearity) --------------
if (any(c("all", "ncv", "linearity") %in% check)) {
dat$NCV <- .diag_ncv(model, verbose = verbose)
dat$NCV <- .model_diagnostic_ncv(model, verbose = verbose)
}

# homogeneity of variance --------------
if (any(c("all", "homogeneity") %in% check)) {
dat$HOMOGENEITY <- .diag_homogeneity(model, verbose = verbose)
dat$HOMOGENEITY <- .model_diagnostic_homogeneity(model, verbose = verbose)
}

# outliers --------------
@@ -501,7 +501,7 @@
} else {
threshold <- attributes(dat$OUTLIERS)$threshold$cook
}
dat$INFLUENTIAL <- .influential_obs(model, threshold = threshold)
dat$INFLUENTIAL <- .safe(.model_diagnostic_outlier(model, threshold = threshold))
}

# posterior predictive checks --------------
@@ -523,25 +523,25 @@

# multicollinearity --------------
if (any(c("all", "vif") %in% check)) {
dat$VIF <- .diag_vif(model, verbose = verbose)
dat$VIF <- .model_diagnostic_vif(model, verbose = verbose)
}

# Q-Q plot (normality/uniformity of residuals) --------------
if (any(c("all", "qq") %in% check)) {
dat$QQ <- switch(residual_type,
simulated = .safe(simulate_residuals(model, ...)),
.diag_qq(model, model_info = model_info, verbose = verbose)
.model_diagnostic_qq(model, model_info = model_info, verbose = verbose)
)
}

# homogeneity of variance --------------
if (any(c("all", "homogeneity") %in% check)) {
dat$HOMOGENEITY <- .diag_homogeneity(model, verbose = verbose)
dat$HOMOGENEITY <- .model_diagnostic_homogeneity(model, verbose = verbose)
}

# Random Effects Q-Q plot (normality of BLUPs) --------------
if (any(c("all", "reqq") %in% check)) {
dat$REQQ <- .diag_reqq(model, level = 0.95, model_info = model_info, verbose = verbose)
dat$REQQ <- .model_diagnostic_ranef_qq(model, level = 0.95, model_info = model_info, verbose = verbose)
}

# outliers --------------
@@ -552,7 +552,7 @@
} else {
threshold <- attributes(dat$OUTLIERS)$threshold$cook
}
dat$INFLUENTIAL <- .influential_obs(model, threshold = threshold)
dat$INFLUENTIAL <- .safe(.model_diagnostic_outlier(model, threshold = threshold))
}

# posterior predictive checks --------------
@@ -567,7 +567,7 @@

# misspecified dispersion and zero-inflation --------------
if (isTRUE(model_info$is_count) && any(c("all", "overdispersion") %in% check)) {
dat$OVERDISPERSION <- .diag_overdispersion(model)
dat$OVERDISPERSION <- .model_diagnostic_overdispersion(model)
}

dat <- insight::compact_list(dat)
16 changes: 8 additions & 8 deletions R/check_model_diagnostics.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# prepare data for VIF plot ----------------------------------

.diag_vif <- function(model, verbose = TRUE) {
.model_diagnostic_vif <- function(model, verbose = TRUE) {
out <- check_collinearity(model, verbose = verbose)
dat <- insight::compact_list(out)
if (is.null(dat)) {
@@ -35,7 +35,7 @@

# prepare data for QQ plot ----------------------------------

.diag_qq <- function(model, model_info = NULL, verbose = TRUE) {
.model_diagnostic_qq <- function(model, model_info = NULL, verbose = TRUE) {
if (inherits(model, c("lme", "lmerMod", "merMod", "gam"))) {
res_ <- stats::residuals(model)
} else if (inherits(model, "geeglm")) {
@@ -98,7 +98,7 @@

# prepare data for random effects QQ plot ----------------------------------

.diag_reqq <- function(model, level = 0.95, model_info = NULL, verbose = TRUE) {
.model_diagnostic_ranef_qq <- function(model, level = 0.95, model_info = NULL, verbose = TRUE) {
# check if we have mixed model
if (is.null(model_info) || !model_info$is_mixed) {
return(NULL)
@@ -161,7 +161,7 @@

# prepare data for normality of residuals plot ----------------------------------

.diag_norm <- function(model, verbose = TRUE) {
.model_diagnostic_normality <- function(model, verbose = TRUE) {
r <- try(as.numeric(stats::residuals(model)), silent = TRUE)

if (inherits(r, "try-error")) {
@@ -181,7 +181,7 @@

# prepare data for influential obs plot ----------------------------------

.diag_influential_obs <- function(model, threshold = NULL) {
.model_diagnostic_outlier <- function(model, threshold = NULL) {
s <- summary(model)

if (inherits(model, "lm", which = TRUE) == 1) {
@@ -220,7 +220,7 @@

# prepare data for non-constant variance plot ----------------------------------

.diag_ncv <- function(model, verbose = TRUE) {
.model_diagnostic_ncv <- function(model, verbose = TRUE) {
ncv <- tryCatch(
data.frame(
x = as.numeric(stats::fitted(model)),
@@ -248,7 +248,7 @@

# prepare data for homogeneity of variance plot ----------------------------------

.diag_homogeneity <- function(model, verbose = TRUE) {
.model_diagnostic_homogeneity <- function(model, verbose = TRUE) {
faminfo <- insight::model_info(model)
r <- tryCatch(
if (inherits(model, "merMod")) {
@@ -367,7 +367,7 @@



.diag_overdispersion <- function(model, ...) {
.model_diagnostic_overdispersion <- function(model, ...) {
faminfo <- insight::model_info(model)

# data for poisson models
2 changes: 1 addition & 1 deletion R/check_normality.R
Original file line number Diff line number Diff line change
@@ -231,7 +231,7 @@ check_normality.merMod <- function(x, effects = c("fixed", "random"), ...) {
p.val <- c(p.val, .check_normality(re[[i]][[j]], x, "random effects"))
}
}
attr(p.val, "re_qq") <- .diag_reqq(x, level = 0.95, model_info = info)
attr(p.val, "re_qq") <- .model_diagnostic_ranef_qq(x, level = 0.95, model_info = info)
attr(p.val, "type") <- "random effects"
attr(p.val, "re_groups") <- re_groups
}
10 changes: 1 addition & 9 deletions R/check_outliers.R
Original file line number Diff line number Diff line change
@@ -588,7 +588,7 @@ check_outliers.default <- function(x,
attr(outlier, "threshold") <- thresholds
attr(outlier, "method") <- method
attr(outlier, "text_size") <- 3
attr(outlier, "influential_obs") <- .influential_obs(x, threshold = unlist(thresholds))
attr(outlier, "influential_obs") <- .safe(.model_diagnostic_outlier(x, threshold = unlist(thresholds))) # nolint
attr(outlier, "variables") <- "(Whole model)"
attr(outlier, "raw_data") <- my_data
attr(outlier, "outlier_var") <- outlier_var
@@ -2036,14 +2036,6 @@ check_outliers.DHARMa <- check_outliers.performance_simres



# influential observations data --------

.influential_obs <- function(x, threshold = NULL) {
.safe(.diag_influential_obs(x, threshold = threshold))
}



# Non-supported model classes ---------------------------------------

#' @export
2 changes: 1 addition & 1 deletion R/check_overdispersion.R
Original file line number Diff line number Diff line change
@@ -101,7 +101,7 @@ plot.check_overdisp <- function(x, ...) {
}
}
if (!is.null(model)) {
x <- .diag_overdispersion(model)
x <- .model_diagnostic_overdispersion(model)
class(x) <- c("see_check_overdisp", "data.frame")
attr(x, "colors") <- list(...)$colors
attr(x, "line_size") <- list(...)$size_line
16 changes: 8 additions & 8 deletions man/check_model.Rd
12 changes: 6 additions & 6 deletions vignettes/check_model_practical.Rmd
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
---
title: "How to arrive at the best model fit"
output:
output:
rmarkdown::html_vignette:
toc: true
tags: [r, performance]
vignette: >
\usepackage[utf8]{inputenc}
%\VignetteIndexEntry{How to arrive at the best model fit}
%\VignetteEngine{knitr::rmarkdown}
editor_options:
editor_options:
chunk_output_type: console
---

@@ -82,7 +82,7 @@ In *performance*, we can conduct a comprehensive visual inspection of our model
For now, we want to focus on the _posterior predictive checks_, _dispersion and zero-inflation_ as well as the Q-Q plot (_uniformity of residuals_).

```{r fig.height=12, fig.width=10}
check_model(model1, dot_size = 1.2)
check_model(model1, size_dot = 1.2)
```

Note that unlike `plot()`, which is a base R function to create diagnostic plots, `check_model()` relies on *simulated residuals* for the Q-Q plot, which is more accurate for non-Gaussian models. See [this vignette](https://easystats.github.io/performance/articles/simulate_residuals.html) and the documentation of `simulate_residuals()` for further details.
@@ -108,7 +108,7 @@ model2 <- glmmTMB::glmmTMB(
family = poisson,
data = glmmTMB::Salamanders
)
check_model(model2, dot_size = 1.2)
check_model(model2, size_dot = 1.2)
```

Looking at the above plots, the zero-inflation seems to be addressed properly (see especially _posterior predictive checks_ and _uniformity of residuals_, the Q-Q plot). However, the overdispersion still could be present. We can check for these problems using `check_overdispersion()` and `check_zeroinflation()` again.
@@ -132,7 +132,7 @@ model3 <- glmmTMB::glmmTMB(
family = glmmTMB::nbinom1,
data = glmmTMB::Salamanders
)
check_model(model3, dot_size = 1.2)
check_model(model3, size_dot = 1.2)
```

Now we see that the plot showing _misspecified dispersion and zero-inflation_ suggests that the overdispersion is better addressed than before. Let us check again:
@@ -195,7 +195,7 @@ model4 <- glmmTMB::glmmTMB(
family = glmmTMB::nbinom2,
data = glmmTMB::Salamanders
)
check_model(model4, dot_size = 1.2)
check_model(model4, size_dot = 1.2)
check_overdispersion(model4)
8 changes: 4 additions & 4 deletions vignettes/simulate_residuals.Rmd
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
---
title: "Checking simulated residuals"
output:
output:
rmarkdown::html_vignette:
toc: true
tags: [r, performance]
vignette: >
\usepackage[utf8]{inputenc}
%\VignetteIndexEntry{Checking simulated residuals}
%\VignetteEngine{knitr::rmarkdown}
editor_options:
editor_options:
chunk_output_type: console
---

@@ -93,10 +93,10 @@ check_outliers(simulated_residuals)

The above three functions internally call `simulate_residuals()` for more complex models automatically, so you don't need to call `simulate_residuals()` yourself. Simulated residuals are usually more reliable than the standard residuals, especially for complex models.

Finally, you can even perform a visual check for the entire model, either by passing the model object directly, or the object returned from `simulate_residuals()`.
Finally, you can even perform a visual check for the entire model, either by passing the model object directly, or the object returned from `simulate_residuals()`.

```{r fig.height=12, fig.width=10}
check_model(simulated_residuals, dot_size = 1.5)
check_model(simulated_residuals, size_dot = 1.5)
```

The `check_model()` function is the main reason we don't want to prematurely extract the residuals in `simulate_residuals()`, because if we do then the simulated residual won't contain the model fit (`fittedModel` in the output below), so we won't be able to do all of the checks we would want to do using the model (e.g., posterior predictive checks).

Unchanged files with check annotations Beta

.check_collinearity <- function(x, component, ci = 0.95, verbose = TRUE) {

Check warning on line 407 in R/check_collinearity.R

GitHub Actions / lint / lint

file=R/check_collinearity.R,line=407,col=1,[cyclocomp_linter] Reduce the cyclomatic complexity of this function from 44 to at most 40.
v <- insight::get_varcov(x, component = component, verbose = FALSE)
# sanity check
#' how to resolve convergence issues. Another clue might be large parameter
#' values, e.g. estimates (on the scale of the linear predictor) larger than
#' 10 in (non-identity link) generalized linear model *might* indicate
#' [complete separation](https://stats.oarc.ucla.edu/other/mult-pkg/faq/general/faqwhat-is-complete-or-quasi-complete-separation-in-logisticprobit-regression-and-how-do-we-deal-with-them/).

Check warning on line 35 in R/check_convergence.R

GitHub Actions / lint / lint

file=R/check_convergence.R,line=35,col=121,[line_length_linter] Lines should not be more than 120 characters. This line is 189 characters.
#' Complete separation can be addressed by regularization, e.g. penalized
#' regression or Bayesian regression with appropriate priors on the fixed effects.
#'
if (!info$is_linear) {
msg <- "This Breusch-Pagan Test currently only works Gaussian models."
if (info$is_count) {
paste0(msg, " You may check your model for overdispersion or zero-inflation instead (see 'check_overdispersion()' and 'check_zeroinflation()').")

Check warning on line 56 in R/check_heteroscedasticity.R

GitHub Actions / lint / lint

file=R/check_heteroscedasticity.R,line=56,col=121,[line_length_linter] Lines should not be more than 120 characters. This line is 151 characters.
}
insight::format_alert(msg)
return(NULL)
# sanity check
if (!is.numeric(model_data[[2]])) {
insight::format_error(
"Discrete or character variables are not supported for this test. Please use a continuous variable for the second argument."

Check warning on line 17 in R/check_htest.R

GitHub Actions / lint / lint

file=R/check_htest.R,line=17,col=121,[line_length_linter] Lines should not be more than 120 characters. This line is 132 characters.
)
}
m1 <- stats::lm(model_data[[1]] ~ 1)
} else if (grepl("Paired t-test", method, fixed = TRUE)) {
if (!is.numeric(model_data[[2]])) {
insight::format_error(
"Discrete or character variables are not supported for this test. Please use a continuous variable for the second argument."

Check warning on line 40 in R/check_htest.R

GitHub Actions / lint / lint

file=R/check_htest.R,line=40,col=121,[line_length_linter] Lines should not be more than 120 characters. This line is 132 characters.
)
}
d <- model_data[[1]] - model_data[[2]]
Djk <- -2 * t(Y) + matrix(diag(t(Y))) %*% matrix(rep(1, n), 1, n) + matrix(rep(1, n), n, 1) %*% diag(t(Y))
b <- 1 / (sqrt(2)) * ((2 * p + 1) / 4)^(1 / (p + 4)) * (n^(1 / (p + 4)))
if (qr(S)$rank == p) {
HZ <- n * (1 / (n^2) * sum(sum(exp(-(b^2) / 2 * Djk))) - 2 * ((1 + (b^2))^(-p / 2)) * (1 / n) * (sum(exp(-((b^2) / (2 * (1 + (b^2)))) * Dj))) + ((1 + (2 * (b^2)))^(-p / 2)))

Check warning on line 200 in R/check_htest.R

GitHub Actions / lint / lint

file=R/check_htest.R,line=200,col=121,[line_length_linter] Lines should not be more than 120 characters. This line is 177 characters.
} else {
HZ <- n * 4
}
n <- length(x)
s <- stats::sd(x)
D <- n * (m - a) / s

Check warning on line 29 in R/check_symmetry.R

GitHub Actions / lint / lint

file=R/check_symmetry.R,line=29,col=3,[object_overwrite_linter] 'D' is an exported object from package 'stats'. Avoid re-using such symbols.
z <- sqrt(2 * n) * (m - a) / s
out <- stats::pnorm(abs(z), lower.tail = FALSE)
} else {
insight::print_color(sprintf("OK: Data appears symmetrical (%s).\n", pstring), "green")
}
return(invisible(x))

Check warning on line 46 in R/check_symmetry.R

GitHub Actions / lint / lint

file=R/check_symmetry.R,line=46,col=3,[return_linter] Use implicit return behavior; explicit return() is not needed.
}