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

Bump insight version for .get_dep_version, etc. #387

Merged
merged 2 commits into from
Aug 18, 2023
Merged
Show file tree
Hide file tree
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
Expand Up @@ -57,7 +57,7 @@ Depends:
Imports:
bayestestR (>= 0.13.0),
effectsize (> 0.8.2),
insight (>= 0.19.1),
insight (>= 0.19.3.2),
parameters (>= 0.20.2),
performance (>= 0.10.2),
datawizard (>= 0.7.0),
Expand Down
6 changes: 4 additions & 2 deletions R/report_htest_chi2.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

# report_effectsize ---------------------

.report_effectsize_chi2 <- function(x, table, dot_args, type, rules = "funder2019") {
.report_effectsize_chi2 <- function(x, table, dot_args, rules = "funder2019") {
if (grepl("Pearson", x$method, fixed = TRUE)) {
args <- c(list(x), dot_args)
table <- do.call(effectsize::effectsize, args)
Expand All @@ -31,10 +31,12 @@
main <- paste0("Adjusted Cramer's v = ", insight::format_value(table[[estimate]]))
} else if (estimate %in% "Tschuprows_t") {
main <- paste0("Tschuprow's t = ", insight::format_value(table[[estimate]]))
} else if (estimate %in% "Tschuprows_t_adjusted") {
main <- paste0("Adjusted Tschuprow's t = ", insight::format_value(table[[estimate]]))
} else if (estimate %in% "Pearsons_c") {
main <- paste0("Pearson's c = ", insight::format_value(table[[estimate]]))
} else if (estimate %in% "phi_adjusted") {
main <- paste0("Adjusted's Phi = ", insight::format_value(table[[estimate]]))
main <- paste0("Adjusted Phi = ", insight::format_value(table[[estimate]]))
} else if (estimate %in% "Cohens_h") {
main <- paste0("Cohen's h = ", insight::format_value(table[[estimate]]))
} else if (estimate %in% "Odds_ratio") {
Expand Down
14 changes: 0 additions & 14 deletions tests/testthat/_snaps/report.lm.md

This file was deleted.

32 changes: 0 additions & 32 deletions tests/testthat/_snaps/report_sample.md

This file was deleted.

15 changes: 12 additions & 3 deletions tests/testthat/_snaps/windows/report.htest-chi2.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,21 @@
---

Code
report_effectsize(x, type = "tschuprows_t")
report_effectsize(x, type = "tschuprows_t", adjust = FALSE)
Output
Effect sizes were labelled following Funder's (2019) recommendations.

very small (Tschuprow's t = 0.09, 95% CI [0.06, 1.00])

---

Code
report_effectsize(x, type = "tschuprows_t")
Output


(Adjusted Tschuprow's t = 0.08, 95% CI [0.06, 1.00])

---

Code
Expand All @@ -95,7 +104,7 @@
Output
Effect sizes were labelled following Funder's (2019) recommendations.

large (Adjusted's Phi = 0.36, 95% CI [0.25, 1.00])
large (Adjusted Phi = 0.36, 95% CI [0.25, 1.00])

---

Expand All @@ -122,5 +131,5 @@
Output


(Risk_ratio = 2.54, 95% CI [1.87, 3.45])
(Risk_ratio = 2.54, 95% CI [1.80, 3.60])

69 changes: 14 additions & 55 deletions tests/testthat/_snaps/windows/report.lm.md
Original file line number Diff line number Diff line change
@@ -1,58 +1,3 @@
# report.lm - lm

Code
report(lm(Sepal.Width ~ Species, data = iris))
Output
We fitted a linear model (estimated using OLS) to predict Sepal.Width with
Species (formula: Sepal.Width ~ Species). The model explains a statistically
significant and substantial proportion of variance (R2 = 0.40, F(2, 147) =
49.16, p < .001, adj. R2 = 0.39). The model's intercept, corresponding to
Species = setosa, is at 3.43 (95% CI [3.33, 3.52], t(147) = 71.36, p < .001).
Within this model:

- The effect of Species [versicolor] is statistically significant and negative
(beta = -0.66, 95% CI [-0.79, -0.52], t(147) = -9.69, p < .001; Std. beta =
-1.51, 95% CI [-1.82, -1.20])
- The effect of Species [virginica] is statistically significant and negative
(beta = -0.45, 95% CI [-0.59, -0.32], t(147) = -6.68, p < .001; Std. beta =
-1.04, 95% CI [-1.35, -0.73])

Standardized parameters were obtained by fitting the model on a standardized
version of the dataset. 95% Confidence Intervals (CIs) and p-values were
computed using a Wald t-distribution approximation.

---

Code
report(lm(wt ~ as.factor(am) * as.factor(cyl), data = mtcars))
Output
We fitted a linear model (estimated using OLS) to predict wt with am and cyl
(formula: wt ~ as.factor(am) * as.factor(cyl)). The model explains a
statistically significant and substantial proportion of variance (R2 = 0.73,
F(5, 26) = 13.73, p < .001, adj. R2 = 0.67). The model's intercept,
corresponding to am = 0 and cyl = 0, is at 2.94 (95% CI [2.27, 3.60], t(26) =
9.08, p < .001). Within this model:

- The effect of am [1] is statistically significant and negative (beta = -0.89,
95% CI [-1.67, -0.11], t(26) = -2.36, p = 0.026; Std. beta = -0.91, 95% CI
[-1.71, -0.12])
- The effect of cyl [6] is statistically non-significant and positive (beta =
0.45, 95% CI [-0.43, 1.33], t(26) = 1.06, p = 0.298; Std. beta = 0.46, 95% CI
[-0.43, 1.36])
- The effect of cyl [8] is statistically significant and positive (beta = 1.17,
95% CI [0.43, 1.91], t(26) = 3.23, p = 0.003; Std. beta = 1.19, 95% CI [0.44,
1.95])
- The effect of am [1] × as cyl6 is statistically non-significant and positive
(beta = 0.26, 95% CI [-0.92, 1.43], t(26) = 0.45, p = 0.654; Std. beta = 0.26,
95% CI [-0.94, 1.47])
- The effect of am [1] × as cyl8 is statistically non-significant and positive
(beta = 0.16, 95% CI [-1.02, 1.33], t(26) = 0.28, p = 0.783; Std. beta = 0.16,
95% CI [-1.04, 1.36])

Standardized parameters were obtained by fitting the model on a standardized
version of the dataset. 95% Confidence Intervals (CIs) and p-values were
computed using a Wald t-distribution approximation.

# report.lm - glm

Code
Expand Down Expand Up @@ -87,3 +32,17 @@
version of the dataset. 95% Confidence Intervals (CIs) and p-values were
computed using a Wald z-distribution approximation.

# report.lm - lm intercept-only

Code
out
Output
We fitted a constant (intercept-only) linear model (estimated using OLS) to
predict d_wide$group0 - d_wide$group1 (formula: d_wide$group0 - d_wide$group1 ~
1). The model's intercept is at -1.58 (95% CI [-2.46, -0.70], t(9) = -4.06, p =
0.003).

Standardized parameters were obtained by fitting the model on a standardized
version of the dataset. 95% Confidence Intervals (CIs) and p-values were
computed using a Wald t-distribution approximation.

89 changes: 0 additions & 89 deletions tests/testthat/_snaps/windows/report.lm.new.md

This file was deleted.

4 changes: 2 additions & 2 deletions tests/testthat/_snaps/windows/report_performance.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@
Output
[1] "The model's explanatory power is substantial (R2 = 0.54)"

---
# report_performance Bayesian 2)

Code
report_performance(x7)
Output
The model's explanatory power is substantial (R2 = 0.83, 95% CI [0.79, 0.87],
The model's explanatory power is substantial (R2 = 0.83, 95% CI [0.79, 0.86],
adj. R2 = 0.83) and the part related to the fixed effects alone (marginal R2)
is of 0.95 (95% CI [0.93, 0.97])

Expand Down
32 changes: 32 additions & 0 deletions tests/testthat/_snaps/windows/report_sample.md
Original file line number Diff line number Diff line change
Expand Up @@ -618,3 +618,35 @@
Species [versicolor], % | 36.9
Species [virginica], % | 56.3

# report_sample, with more than one grouping variable

Code
out
Output
# Descriptive Statistics

Variable | setosa, a (n=16) | versicolor, a (n=17) | virginica, a (n=9) | setosa, b (n=15) | versicolor, b (n=17) | virginica, b (n=22) | setosa, c (n=19) | versicolor, c (n=16) | virginica, c (n=19) | Total (n=150)
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Mean Sepal.Length (SD) | 5.13 (0.36) | 6.08 (0.48) | 6.59 (0.44) | 4.91 (0.31) | 5.84 (0.54) | 6.77 (0.63) | 4.97 (0.36) | 5.88 (0.53) | 6.38 (0.69) | 5.84 (0.83)
Mean Sepal.Width (SD) | 3.50 (0.42) | 2.76 (0.40) | 3.02 (0.25) | 3.34 (0.25) | 2.81 (0.25) | 3.05 (0.36) | 3.44 (0.43) | 2.74 (0.29) | 2.87 (0.30) | 3.06 (0.44)

# report_sample, print vertical

Code
print(out, layout = "vertical")
Output
# Descriptive Statistics

Groups | Mean Sepal.Length (SD) | Mean Sepal.Width (SD) | Mean Petal.Length (SD)
----------------------------------------------------------------------------------------------
setosa, a (n=16) | 5.13 (0.36) | 3.50 (0.42) | 1.50 (0.12)
versicolor, a (n=17) | 6.08 (0.48) | 2.76 (0.40) | 4.37 (0.44)
virginica, a (n=9) | 6.59 (0.44) | 3.02 (0.25) | 5.57 (0.52)
setosa, b (n=15) | 4.91 (0.31) | 3.34 (0.25) | 1.47 (0.17)
versicolor, b (n=17) | 5.84 (0.54) | 2.81 (0.25) | 4.25 (0.44)
virginica, b (n=22) | 6.77 (0.63) | 3.05 (0.36) | 5.73 (0.57)
setosa, c (n=19) | 4.97 (0.36) | 3.44 (0.43) | 1.43 (0.21)
versicolor, c (n=16) | 5.88 (0.53) | 2.74 (0.29) | 4.16 (0.53)
virginica, c (n=19) | 6.38 (0.69) | 2.87 (0.30) | 5.34 (0.49)
Total (n=150) | 5.84 (0.83) | 3.06 (0.44) | 3.76 (1.77)

11 changes: 8 additions & 3 deletions tests/testthat/test-report.htest-chi2.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
test_that("report.htest-chi2", {
M <- as.table(rbind(c(762, 327, 468), c(484, 239, 477)))
dimnames(M) <- list(gender = c("F", "M"), party = c("Democrat", "Independent", "Republican"))
x <- chisq.test(M)
m <- as.table(rbind(c(762, 327, 468), c(484, 239, 477)))
dimnames(m) <- list(gender = c("F", "M"), party = c("Democrat", "Independent", "Republican"))
x <- chisq.test(m)

expect_snapshot(
variant = "windows",
Expand Down Expand Up @@ -45,6 +45,11 @@ test_that("report.htest-chi2", {
report_effectsize(x, type = "pearsons_c")
)

expect_snapshot(
variant = "windows",
report_effectsize(x, type = "tschuprows_t", adjust = FALSE)
)

expect_snapshot(
variant = "windows",
report_effectsize(x, type = "tschuprows_t")
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-report.lm.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ test_that("report.lm - lm intercept-only", {
)

model_io <- lm(d_wide$group0 - d_wide$group1 ~ 1)
out <- report(model_io)
expect_snapshot(out)
out <- suppressWarnings(report(model_io, verbose = FALSE))
expect_snapshot(variant = "windows", out)
})
4 changes: 2 additions & 2 deletions tests/testthat/test-report_sample.R
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ test_that("report_sample, with more than one grouping variable", {
)
# verified against
expected <- aggregate(iris["Sepal.Length"], iris[c("Species", "grp")], mean)
expect_snapshot(out)
expect_snapshot(variant = "windows", out)
})

test_that("report_sample, numeric select", {
Expand All @@ -286,5 +286,5 @@ test_that("report_sample, print vertical", {
iris$grp <- sample(letters[1:3], nrow(iris), TRUE)
iris_grp <- datawizard::data_group(iris, c("Species", "grp"))
out <- report_sample(iris_grp, select = 1:3)
expect_snapshot(print(out, layout = "vertical"))
expect_snapshot(variant = "windows", print(out, layout = "vertical"))
})