Skip to content

Commit

Permalink
fixes warning in example?
Browse files Browse the repository at this point in the history
  • Loading branch information
IndrajeetPatil committed Sep 11, 2023
1 parent 70de993 commit 472d246
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 74 deletions.
16 changes: 10 additions & 6 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ message: 'To cite package "statsExpressions" in publications use:'
type: software
license: GPL-3.0-only
title: 'statsExpressions: Tidy Dataframes and Expressions with Statistical Details'
version: 1.5.1.9000
version: 1.5.2
doi: 10.21105/joss.03236
abstract: 'Utilities for producing dataframes with rich details for the most common
types of statistical approaches and tests: parametric, nonparametric, robust, and
Expand Down Expand Up @@ -116,7 +116,7 @@ references:
abstract: 'correlation: Methods for Correlation Analysis'
notes: Imports
url: https://easystats.github.io/correlation/
repository: https://CRAN.R-project.org/package=correlation
repository: https://easystats.r-universe.dev
authors:
- family-names: Makowski
given-names: Dominique
Expand All @@ -138,8 +138,12 @@ references:
given-names: Mattan S.
email: [email protected]
orcid: https://orcid.org/0000-0002-4287-4801
- family-names: Thériault
given-names: Rémi
email: [email protected]
orcid: https://orcid.org/0000-0003-4315-6788
year: '2023'
version: '>= 0.8.4'
version: '>= 0.8.5'
- type: software
title: datawizard
abstract: 'datawizard: Easy Data Wrangling and Statistical Transformations'
Expand Down Expand Up @@ -197,7 +201,7 @@ references:
email: [email protected]
orcid: https://orcid.org/0000-0003-4777-038X
year: '2023'
version: '>= 1.1.2'
version: '>= 1.1.3'
- type: software
title: effectsize
abstract: 'effectsize: Indices of Effect Size'
Expand Down Expand Up @@ -286,7 +290,7 @@ references:
email: [email protected]
orcid: https://orcid.org/0000-0002-9271-5075
year: '2023'
version: '>= 0.19.3'
version: '>= 0.19.4'
- type: software
title: magrittr
abstract: 'magrittr: A Forward-Pipe Operator for R'
Expand Down Expand Up @@ -365,7 +369,7 @@ references:
email: [email protected]
orcid: https://orcid.org/0000-0001-9560-6336
year: '2023'
version: '>= 0.10.3'
version: '>= 0.10.4'
- type: software
title: PMCMRplus
abstract: 'PMCMRplus: Calculate Pairwise Multiple Comparisons of Mean Rank Sums
Expand Down
8 changes: 4 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ Depends:
Imports:
afex (>= 1.3-0),
BayesFactor (>= 0.9.12-4.4),
correlation (>= 0.8.4),
correlation (>= 0.8.5),
datawizard (>= 0.8.0),
dplyr (>= 1.1.2),
dplyr (>= 1.1.3),
effectsize (>= 0.8.5),
glue,
insight (>= 0.19.3),
insight (>= 0.19.4),
magrittr,
parameters (>= 0.21.1),
performance (>= 0.10.3),
performance (>= 0.10.4),
PMCMRplus (>= 1.9.7),
purrr (>= 1.0.2),
rlang,
Expand Down
4 changes: 2 additions & 2 deletions R/add_expression_col.R
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ add_expression_col <- function(data,
no.parameters <- sum("df.error" %in% names(data) + "df" %in% names(data))

# special case for Bayesian contingency table analysis
if (bayesian && grepl("contingency", data$method[[1]], fixed = TRUE)) data %<>% mutate(effectsize = "Cramers_v")
if (bayesian && grepl("contingency", data$method[[1L]], fixed = TRUE)) data %<>% mutate(effectsize = "Cramers_v")

# convert needed columns to character type
df_expr <- .data_to_char(data, k, k.df, k.df.error)
Expand Down Expand Up @@ -169,7 +169,7 @@ add_expression_col <- function(data,
across(.fns = ~ .to_char(.x, k), .cols = matches("^est|^sta|p.value|.scale$|.low$|.high$|^log")),
across(.fns = ~ .to_char(.x, k.df), .cols = matches("^df$")),
across(.fns = ~ .to_char(.x, k.df.error), .cols = matches("^df.error$")),
across(.fns = ~ paste0(.x * 100, "%"), .cols = matches("^conf.level$"))
across(.fns = ~ paste0(.x * 100L, "%"), .cols = matches("^conf.level$"))
)
}

Expand Down
4 changes: 2 additions & 2 deletions R/contingency_table.R
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ contingency_table <- function(data,
conf.level = 0.95,
sampling.plan = "indepMulti",
fixed.margin = "rows",
prior.concentration = 1,
prior.concentration = 1.0,
...) {
type <- stats_type_switch(type)
test <- ifelse(quo_is_null(enquo(y)), "1way", "2way")
Expand Down Expand Up @@ -163,7 +163,7 @@ contingency_table <- function(data,
}

p1s <- rdirichlet(n = 100000L, alpha = prior.concentration * ratio)
pr_h1 <- map_dbl(1:100000, ~ stats::dmultinom(as.matrix(xtab), prob = p1s[.x, ], log = TRUE))
pr_h1 <- map_dbl(1:100000L, ~ stats::dmultinom(as.matrix(xtab), prob = p1s[.x, ], log = TRUE))

# BF = (log) prob of data under alternative - (log) prob of data under null
# computing Bayes Factor and formatting the results
Expand Down
31 changes: 7 additions & 24 deletions R/meta_analysis.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,38 +41,21 @@
#' set.seed(123)
#' library(statsExpressions)
#'
#' # a data frame with estimates and standard errors
#' # (`mag` dataset from `{metaplus}`)
#' df <- tibble::tribble(
#' ~study, ~estimate, ~std.error,
#' "Abraham", -0.83, 1.247,
#' "Bertschat", -1.056, 0.414,
#' "Ceremuzynski", -1.278, 0.808,
#' "Feldstedt", -0.043, 1.429,
#' "Golf", 0.223, 0.489,
#' "ISIS-4", -2.407, 1.072,
#' "LIMIT-2", -1.28, 1.193,
#' "Morton", -1.191, 1.661,
#' "Pereira", -0.695, 0.536,
#' "Rasmussen", -2.208, 1.109,
#' "Schechter", -2.038, 0.78,
#' "Schechter 1", -0.85, 0.618,
#' "Schechter 2", -0.793, 0.625,
#' "Singh", -0.299, 0.146,
#' "Smith", -1.57, 0.574,
#' "Thogersen", 0.057, 0.031
#' )
#' @examplesIf requireNamespace("metaplus", quietly = TRUE)
#' # let's use `mag` dataset from `{metaplus}`
#' data(mag, package = "metaplus")
#' dat <- dplyr::rename(mag, estimate = yi, std.error = sei)
#'
#' # parametric
#' meta_analysis(df)
#' meta_analysis(dat)
#'
#' @examplesIf identical(Sys.getenv("NOT_CRAN"), "true") && requireNamespace("metaplus", quietly = TRUE)
#' # robust
#' meta_analysis(df, type = "random", random = "normal")
#' meta_analysis(dat, type = "random", random = "normal")
#'
#' @examplesIf identical(Sys.getenv("NOT_CRAN"), "true") && requireNamespace("metaBMA", quietly = TRUE)
#' # Bayesian
#' meta_analysis(df, type = "bayes")
#' meta_analysis(dat, type = "bayes")
#'
#' @export
meta_analysis <- function(data,
Expand Down
2 changes: 1 addition & 1 deletion R/oneway_anova.R
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ oneway_anova <- function(data,
# parametric ---------------------------------------

if (type == "parametric") {
c(k.df, k.df.error) %<-% c(ifelse(!paired, 0L, k), ifelse(!paired && var.equal, 0L, k))
c(k.df, k.df.error) %<-% c(ifelse(paired, k, 0L), ifelse(!paired && var.equal, 0L, k))

# styler: off
if (effsize.type %in% c("unbiased", "omega")) .f.es <- effectsize::omega_squared
Expand Down
12 changes: 6 additions & 6 deletions codemeta.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"codeRepository": "https://github.com/IndrajeetPatil/statsExpressions",
"issueTracker": "https://github.com/IndrajeetPatil/statsExpressions/issues",
"license": "https://spdx.org/licenses/GPL-3.0",
"version": "1.5.1.9000",
"version": "1.5.2",
"programmingLanguage": {
"@type": "ComputerLanguage",
"name": "R",
Expand Down Expand Up @@ -213,7 +213,7 @@
"@type": "SoftwareApplication",
"identifier": "correlation",
"name": "correlation",
"version": ">= 0.8.4",
"version": ">= 0.8.5",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
Expand All @@ -239,7 +239,7 @@
"@type": "SoftwareApplication",
"identifier": "dplyr",
"name": "dplyr",
"version": ">= 1.1.2",
"version": ">= 1.1.3",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
Expand Down Expand Up @@ -277,7 +277,7 @@
"@type": "SoftwareApplication",
"identifier": "insight",
"name": "insight",
"version": ">= 0.19.3",
"version": ">= 0.19.4",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
Expand Down Expand Up @@ -315,7 +315,7 @@
"@type": "SoftwareApplication",
"identifier": "performance",
"name": "performance",
"version": ">= 0.10.3",
"version": ">= 0.10.4",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
Expand Down Expand Up @@ -431,7 +431,7 @@
},
"SystemRequirements": null
},
"fileSize": "4131.443KB",
"fileSize": "4130.563KB",
"citation": [
{
"@type": "ScholarlyArticle",
Expand Down
33 changes: 8 additions & 25 deletions man/meta_analysis.Rd

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

2 changes: 1 addition & 1 deletion man/reexports.Rd

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

4 changes: 1 addition & 3 deletions tests/testthat/test-meta_random_bayes.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@
# Bayesian meta-analysis often crashes R session on macOS
# this makes sure this test will be run after all others



test_that(
desc = "meta_analysis works - bayesian",
code = {
skip_if_not_installed("metaBMA")
skip_if_not_installed("metaplus")

data(mag, package = "metaplus")
dat <- mag %>% rename(estimate = yi, std.error = sei)
dat <- dplyr::rename(mag, estimate = yi, std.error = sei)

set.seed(123)
df <- suppressWarnings(meta_analysis(
Expand Down

0 comments on commit 472d246

Please sign in to comment.