Skip to content

Commit

Permalink
Merge branch 'main' into joss-paper-draft
Browse files Browse the repository at this point in the history
  • Loading branch information
IndrajeetPatil authored Feb 20, 2024
2 parents 5ca7a6f + a983381 commit 28d2afd
Show file tree
Hide file tree
Showing 13 changed files with 132 additions and 19 deletions.
16 changes: 5 additions & 11 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: report
Type: Package
Title: Automated Reporting of Results and Statistical Models
Version: 0.5.7.13
Version: 0.5.8
Authors@R:
c(person(given = "Dominique",
family = "Makowski",
Expand Down Expand Up @@ -57,10 +57,10 @@ Depends:
Imports:
bayestestR (>= 0.13.1),
effectsize (>= 0.8.6),
insight (>= 0.19.6),
parameters (>= 0.21.2),
insight (>= 0.19.7),
parameters (>= 0.21.3),
performance (>= 0.10.8),
datawizard (>= 0.9.0),
datawizard (>= 0.9.1),
stats,
tools,
utils
Expand Down Expand Up @@ -139,17 +139,11 @@ Collate:
'report_performance.R'
'report_priors.R'
'report_random.R'
'report_s.R'
'report_sample.R'
'report_statistics.R'
'report_table.R'
'utils_error_message.R'
'utils_grouped_df.R'
'zzz.R'
Roxygen: list(markdown = TRUE)
Remotes:
easystats/insight,
easystats/datawizard,
easystats/parameters,
easystats/effectsize,
easystats/bayestestR,
easystats/performance
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ export(report_participants)
export(report_performance)
export(report_priors)
export(report_random)
export(report_s)
export(report_sample)
export(report_statistics)
export(report_story)
Expand Down
7 changes: 6 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
# report 0.5.8

New features

* `report_s()` to report the interpretation of S- and p-values in an easy-to-understand
language.

Major Changes

* This release changes the licensing model of `{see}` to an MIT license.
* This release changes the licensing model of `{report}` to an MIT license.

Minor changes

Expand Down
38 changes: 38 additions & 0 deletions R/report_s.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#' Report S- and p-values in easy language.
#'
#' Reports interpretation of S- and p-values in easy language.
#'
#' @param s An S-value. Either `s` or `p` must be provided.
#' @param p A p-value. Either `s` or `p` must be provided.
#' @param test_value The value of the test parameter under the null hypothesis.
#' @param test_parameter The name of the test parameter under the null hypothesis.
#'
#' @return A string with the interpretation of the S- or p-value.
#'
#' @examples
#' report_s(s = 1.5)
#' report_s(p = 0.05)
#' @export
report_s <- function(s = NULL, p = NULL, test_value = 0, test_parameter = "parameter") {
# sanity check arguments
if ((is.null(s) || all(is.na(s))) && (is.null(p) || all(is.na(p)))) {
insight::format_error("You must provide either `s` or `p`.")
}
if (length(s) > 1 || length(p) > 1) {
insight::format_error("You must provide a single value for `s` or `p`.")
}
# make sure we have both s and p
if (!is.null(p) && !is.na(p)) {
s <- -log2(p)
} else {
p <- 2^(-s)
}
all_heads <- round(s)
chance <- sprintf("%.2g", 100 * p)
msg <- paste0(
"If the test hypothesis (", test_parameter, " = ", test_value, ") and all model assumptions were true, ",
"there is a ", chance, "% chance of observing this outcome. How weird is that? ",
"It's hardly more surprising than getting ", all_heads, " heads in a row with fair coin tosses."
)
insight::format_alert(msg)
}
2 changes: 1 addition & 1 deletion R/report_sample.R
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ report_sample <- function(data,

# create a "table row", i.e. a summary from a variable ------------------------

.report_sample_row <- function(x, digits = 1, ...) {
.report_sample_row <- function(x, ...) {
UseMethod(".report_sample_row")
}

Expand Down
1 change: 1 addition & 0 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ reference:
- report_performance
- report_priors
- report_random
- report_s
- report_sample
- report_statistics

Expand Down
4 changes: 4 additions & 0 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## R CMD check results report 0.5.8

0 errors | 0 warnings | 0 note

## R CMD check results report 0.5.7

0 errors | 0 warnings | 0 note
Expand Down
27 changes: 27 additions & 0 deletions man/report_s.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions tests/testthat/_snaps/windows/report.data.frame.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,12 @@
- name: 87 entries, such as Ackbar (n = 1); Adi Gallia (n = 1); Anakin
Skywalker (n = 1) and 84 others (0 missing)
- height: n = 87, Mean = 174.36, SD = 34.77, Median = , MAD = 19.27, range:
[66, 264], Skewness = -1.06, Kurtosis = 2.10, 6 missing
- height: n = 87, Mean = 174.60, SD = 34.77, Median = , MAD = 17.79, range:
[66, 264], Skewness = -1.09, Kurtosis = 2.13, 6 missing
- mass: n = 87, Mean = 97.31, SD = 169.46, Median = , MAD = 16.31, range: [15,
1358], Skewness = 7.34, Kurtosis = 55.42, 28 missing
- hair_color: 12 entries, such as none (n = 37); brown (n = 18); black (n = 13)
and 9 others (5 missing)
- hair_color: 11 entries, such as none (n = 38); brown (n = 18); black (n = 13)
and 8 others (5 missing)
- skin_color: 31 entries, such as fair (n = 17); light (n = 11); dark (n = 6)
and 28 others (0 missing)
- eye_color: 15 entries, such as brown (n = 21); blue (n = 19); yellow (n = 11)
Expand Down
8 changes: 8 additions & 0 deletions tests/testthat/_snaps/windows/report.htest-t-test.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@

Code
report(t.test(x, y, paired = TRUE))
Message
For paired samples, 'repeated_measures_d()' provides more options.
Output
Effect sizes were labelled following Cohen's (1988) recommendations.
Expand All @@ -86,6 +88,8 @@

Code
report(t.test(x, y, paired = TRUE, alternative = "l"))
Message
For paired samples, 'repeated_measures_d()' provides more options.
Output
Effect sizes were labelled following Cohen's (1988) recommendations.
Expand All @@ -98,6 +102,8 @@

Code
report(t.test(x, y, paired = TRUE, alternative = "g"))
Message
For paired samples, 'repeated_measures_d()' provides more options.
Output
Effect sizes were labelled following Cohen's (1988) recommendations.
Expand All @@ -110,6 +116,8 @@

Code
report(t.test(sleep2$extra.1, sleep2$extra.2, paired = TRUE))
Message
For paired samples, 'repeated_measures_d()' provides more options.
Output
Effect sizes were labelled following Cohen's (1988) recommendations.
Expand Down
10 changes: 8 additions & 2 deletions tests/testthat/_snaps/windows/report.survreg.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,16 @@
report(mod_survreg)
Output
Can't calculate log-loss.
Can't calculate proper scoring rules for models without integer response values.
Message
Can't calculate proper scoring rules for models without integer response
values.
Output
`performance_pcp()` only works for models with binary response values.
Can't calculate log-loss.
Can't calculate proper scoring rules for models without integer response values.
Message
Can't calculate proper scoring rules for models without integer response
values.
Output
`performance_pcp()` only works for models with binary response values.
We fitted a logistic model to predict survival::Surv(futime, fustat) with
ecog.ps and rx (formula: survival::Surv(futime, fustat) ~ ecog.ps + rx). The
Expand Down
20 changes: 20 additions & 0 deletions tests/testthat/_snaps/windows/report_s.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# report_s

Code
report_s(s = 4.2)
Message <simpleMessage>
If the test hypothesis (parameter = 0) and all model assumptions were
true, there is a 5.4% chance of observing this outcome. How weird is
that? It's hardly more surprising than getting 4 heads in a row with
fair coin tosses.

---

Code
report_s(p = 0.06)
Message <simpleMessage>
If the test hypothesis (parameter = 0) and all model assumptions were
true, there is a 6% chance of observing this outcome. How weird is that?
It's hardly more surprising than getting 4 heads in a row with fair coin
tosses.

9 changes: 9 additions & 0 deletions tests/testthat/test-report_s.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
test_that("report_s", {
expect_snapshot(report_s(s = 4.2), variant = "windows")
expect_snapshot(report_s(p = 0.06), variant = "windows")
})

test_that("report_s, arguments", {
expect_error(report_s())
expect_error(report_s(s = 1:2), "single value")
})

0 comments on commit 28d2afd

Please sign in to comment.