Giter Site home page Giter Site logo

indrajeetpatil / statsexpressions Goto Github PK

View Code? Open in Web Editor NEW
311.0 8.0 20.0 38.07 MB

Tidy data frames and expressions with statistical summaries ๐Ÿ“œ

Home Page: https://indrajeetpatil.github.io/statsExpressions/

License: Other

R 72.63% TeX 7.59% RMarkdown 19.16% Shell 0.14% Makefile 0.47%
statistical-tests statistical-details meta-analysis contingency-table robust correlation parametric bayesian-inference bayesian-statistics robust-statistics

statsexpressions's Issues

error in `paired` version of ANOVA when dataframe not sorted by subject ID

# data
df <-
  structure(list(
    score = c(
      70, 82.5, 97.5, 100, 52.5, 62.5,
      92.5, 70, 90, 92.5, 90, 75, 60, 90, 85, 67.5, 90, 72.5, 45, 60,
      72.5, 80, 100, 100, 97.5, 95, 65, 87.5, 90, 62.5, 100, 100, 97.5,
      100, 97.5, 95, 82.5, 82.5, 40, 92.5, 85, 72.5, 35, 27.5, 82.5
    ), condition = structure(c(
      5L, 1L, 2L, 3L, 4L, 4L, 5L, 1L,
      2L, 3L, 2L, 3L, 3L, 4L, 2L, 1L, 5L, 5L, 4L, 1L, 1L, 4L, 3L, 5L,
      2L, 5L, 1L, 2L, 3L, 4L, 4L, 5L, 1L, 2L, 3L, 2L, 3L, 4L, 1L, 5L,
      3L, 2L, 5L, 4L, 1L
    ), .Label = c("1", "2", "3", "4", "5"), class = "factor"),
    id = structure(c(
      1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L,
      2L, 3L, 3L, 4L, 3L, 4L, 3L, 4L, 3L, 4L, 4L, 5L, 5L, 5L, 5L,
      5L, 6L, 6L, 6L, 6L, 6L, 7L, 7L, 7L, 7L, 7L, 8L, 8L, 8L, 8L,
      8L, 9L, 9L, 9L, 9L, 9L
    ), .Label = c(
      "1", "2", "3", "4", "5",
      "6", "7", "8", "9"
    ), class = "factor")
  ), row.names = c(
    NA,
    45L
  ), class = "data.frame")

# expected output
friedman.test(formula = score ~ condition | id, data = df)
#> 
#>  Friedman rank sum test
#> 
#> data:  score and condition and id
#> Friedman chi-squared = 12.729, df = 4, p-value = 0.01268

# ggstatsplot output

# incorrect 
set.seed(123)
statsExpressions::expr_anova_nonparametric(
  data = df,
  x = condition,
  y = score,
  paired = TRUE,
  output = "dataframe"
)

#> # A tibble: 1 x 7
#>   statistic p.value parameter method                 estimate conf.low conf.high
#>       <dbl>   <dbl>     <dbl> <chr>                     <dbl>    <dbl>     <dbl>
#> 1      13.9 0.00773         4 Friedman rank sum test    0.543    0.482     0.855

# correct
set.seed(123)
statsExpressions::expr_anova_nonparametric(
  data = dplyr::arrange(df, id),
  x = condition,
  y = score,
  paired = TRUE,
  output = "dataframe"
)
#> # A tibble: 1 x 7
#>   statistic p.value parameter method                 estimate conf.low conf.high
#>       <dbl>   <dbl>     <dbl> <chr>                     <dbl>    <dbl>     <dbl>
#> 1      12.7  0.0127         4 Friedman rank sum test    0.527    0.458     0.849

Created on 2020-10-17 by the reprex package (v0.3.0.9001)

adding support for robust meta-analysis

library(robumeta)

# Load data
data(hierdat)

# Small-Sample Corrections - Hierarchical Dependence Model
HierModSm <-  robu(formula = effectsize ~ binge + followup + sreport
                   + age, data = hierdat, studynum = studyid, 
                   var.eff.size = var, modelweights = "HIER", small = TRUE)

class(HierModSm)
#> [1] "robu"

tibble::as_tibble(HierModSm$reg_table)
#> # A tibble: 5 x 9
#>   labels            b.r       SE      t   dfs   prob     CI.L    CI.U sig  
#>   <fct>           <dbl>    <dbl>  <dbl> <dbl>  <dbl>    <dbl>   <dbl> <fct>
#> 1 X.Intercept.  0.397   0.658     0.603  3.06 0.588  -1.68    2.47    ""   
#> 2 binge         0.452   0.102     4.44   3.59 0.0144  0.156   0.747   "**" 
#> 3 followup      0.00133 0.000723  1.84   2.03 0.205  -0.00173 0.00439 ""   
#> 4 sreport       0.539   0.143     3.76   4.36 0.0170  0.153   0.924   "**" 
#> 5 age          -0.0437  0.0379   -1.15   2.69 0.340  -0.172   0.0849  ""

Created on 2020-01-09 by the reprex package (v0.3.0)

Session info
devtools::session_info()
#> โ”€ Session info โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
#>  setting  value                       
#>  version  R version 3.6.2 (2019-12-12)
#>  os       macOS Mojave 10.14.6        
#>  system   x86_64, darwin15.6.0        
#>  ui       X11                         
#>  language (EN)                        
#>  collate  en_US.UTF-8                 
#>  ctype    en_US.UTF-8                 
#>  tz       Europe/Berlin               
#>  date     2020-01-09                  
#> 
#> โ”€ Packages โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
#>  package     * version    date       lib source                      
#>  assertthat    0.2.1      2019-03-21 [1] CRAN (R 3.6.0)              
#>  backports     1.1.5      2019-10-02 [1] CRAN (R 3.6.0)              
#>  callr         3.4.0      2019-12-09 [1] CRAN (R 3.6.0)              
#>  cli           2.0.1      2020-01-08 [1] CRAN (R 3.6.2)              
#>  crayon        1.3.4      2017-09-16 [1] CRAN (R 3.6.0)              
#>  desc          1.2.0      2018-05-01 [1] CRAN (R 3.6.0)              
#>  devtools      2.2.1      2019-09-24 [1] CRAN (R 3.6.0)              
#>  digest        0.6.23     2019-11-23 [1] CRAN (R 3.6.0)              
#>  ellipsis      0.3.0      2019-09-20 [1] CRAN (R 3.6.0)              
#>  evaluate      0.14       2019-05-28 [1] CRAN (R 3.6.0)              
#>  fansi         0.4.1      2020-01-08 [1] CRAN (R 3.6.2)              
#>  fs            1.3.1      2019-05-06 [1] CRAN (R 3.6.0)              
#>  glue          1.3.1      2019-03-12 [1] CRAN (R 3.6.0)              
#>  highr         0.8        2019-03-20 [1] CRAN (R 3.6.0)              
#>  htmltools     0.4.0      2019-10-04 [1] CRAN (R 3.6.0)              
#>  knitr         1.26       2019-11-12 [1] CRAN (R 3.6.0)              
#>  magrittr      1.5        2014-11-22 [1] CRAN (R 3.6.0)              
#>  memoise       1.1.0      2017-04-21 [1] CRAN (R 3.6.0)              
#>  pillar        1.4.3      2019-12-20 [1] CRAN (R 3.6.2)              
#>  pkgbuild      1.0.6      2019-10-09 [1] CRAN (R 3.6.0)              
#>  pkgconfig     2.0.3      2019-09-22 [1] CRAN (R 3.6.0)              
#>  pkgload       1.0.2      2018-10-29 [1] CRAN (R 3.6.0)              
#>  prettyunits   1.0.2      2015-07-13 [1] CRAN (R 3.6.0)              
#>  processx      3.4.1      2019-07-18 [1] CRAN (R 3.6.0)              
#>  ps            1.3.0      2018-12-21 [1] CRAN (R 3.6.0)              
#>  R6            2.4.1      2019-11-12 [1] CRAN (R 3.6.0)              
#>  Rcpp          1.0.3      2019-11-08 [1] CRAN (R 3.6.1)              
#>  remotes       2.1.0      2019-06-24 [1] CRAN (R 3.6.0)              
#>  rlang         0.4.2.9000 2020-01-07 [1] Github (r-lib/rlang@e48b07d)
#>  rmarkdown     2.0        2019-12-12 [1] CRAN (R 3.6.0)              
#>  robumeta    * 2.0        2017-05-29 [1] CRAN (R 3.6.0)              
#>  rprojroot     1.3-2      2018-01-03 [1] CRAN (R 3.6.0)              
#>  sessioninfo   1.1.1      2018-11-05 [1] CRAN (R 3.6.0)              
#>  stringi       1.4.3      2019-03-12 [1] CRAN (R 3.6.0)              
#>  stringr       1.4.0      2019-02-10 [1] CRAN (R 3.6.0)              
#>  testthat      2.3.1      2019-12-01 [1] CRAN (R 3.6.0)              
#>  tibble        2.1.3      2019-06-06 [1] CRAN (R 3.6.0)              
#>  usethis       1.5.1      2019-07-04 [1] CRAN (R 3.6.0)              
#>  utf8          1.1.4      2018-05-24 [1] CRAN (R 3.6.0)              
#>  vctrs         0.2.1      2019-12-17 [1] CRAN (R 3.6.2)              
#>  withr         2.1.2      2018-03-15 [1] CRAN (R 3.6.0)              
#>  xfun          0.11       2019-11-12 [1] CRAN (R 3.6.0)              
#>  yaml          2.2.0      2018-07-25 [1] CRAN (R 3.6.0)              
#>  zeallot       0.1.0      2018-01-28 [1] CRAN (R 3.6.0)              
#> 
#> [1] /Users/patil/Library/R/3.6/library
#> [2] /Library/Frameworks/R.framework/Versions/3.6/Resources/library

brain dump

  • retire sphericity.correction argument
  • remove insight from DESCRIPTION
  • more explicit description of robust correlation test than just pb
  • add "ordinal" to epsilon-squared effect size
  • remove alias bf_meta
  • retire all _bayes function here and just reexport them from tidyBF (this means the default output from tidyBF will have to be "expression", just to be consistent. A breaking change but can't see any other way to avoid all the code duplication happening here)
  • using correlation for Bayesian analysis than BayesFactor
  • add lifecycle badges to functions
  • use tidy_model_parameters in bf_extractor
  • retire log_e_bf10 column
  • make the switch functions less fragile (https://github.com/IndrajeetPatil/statsExpressions/blob/master/R/helpers_expr_templates.R)
  • use AKP as effect size consistently throughout robust statistics?
  • make sure all instances of effectsize functions use verbose = FALSE
  • change Hedge to Hedges in expression (https://en.wikipedia.org/wiki/Effect_size#Hedges'_g)
  • is it necessary to quote the expression elements in switch functions?
  • add example to README with kable
  • with ipmisc 6.0, you don't need to do this; just use length(unique(data$rowid))
    n = ifelse(isTRUE(paired), length(unique(data$rowid)), nrow(data)),

Feature Request one-tailed

This package is absolutely wonderful and makes some amazing plots! It would be awesome if it could also report one-tailed t-tests, rather than two-tailed.

Thank you so much for this package!

different CIs for V depending on x versus y

library(rcompanion)
data(Anderson)
Species = c(rep("Species1", 16), rep("Species2", 16))
Color   = c(rep(c("blue", "blue", "blue", "green"),4),
            rep(c("green", "green", "green", "blue"),4))

set.seed(123)
cramerV(Species, Color, ci = TRUE, digits = 5)
#>   Cramer.V lower.ci upper.ci
#> 1      0.5  0.18787  0.80501

set.seed(123)
cramerV(Color, Species, ci = TRUE, digits = 5)
#>   Cramer.V lower.ci upper.ci
#> 1      0.5  0.18787  0.80501

library(statsExpressions)

set.seed(123)
expr_contingency_tab(mtcars, am, cyl)
#> paste(NULL, chi["Pearson"]^2, "(", "2", ") = ", "8.74", ", ", 
#>     italic("p"), " = ", "0.013", ", ", widehat(italic("V"))["Cramer"], 
#>     " = ", "0.46", ", CI"["95%"], " [", "0.08", ", ", "0.75", 
#>     "]", ", ", italic("n")["obs"], " = ", 32L)

set.seed(123)
expr_contingency_tab(mtcars, cyl, am)
#> paste(NULL, chi["Pearson"]^2, "(", "2", ") = ", "8.74", ", ", 
#>     italic("p"), " = ", "0.013", ", ", widehat(italic("V"))["Cramer"], 
#>     " = ", "0.46", ", CI"["95%"], " [", "0.11", ", ", "0.73", 
#>     "]", ", ", italic("n")["obs"], " = ", 32L)

Created on 2020-10-09 by the reprex package (v0.3.0)

Add arguments to control Bayes factor output

I appreciate the response to issue IndrajeetPatil/ggstatsplot#153---the defaults make sense. But would it be possible to have an argument that controls whether BF10 or BF01 and log or not log is displayed? Personally, I like displaying the frequentist on top and Bayesian on bottom, but I would prefer to see the regular BF10. Again, I appreciate the defaults, but can you make it customizable by the user?

Effect Size Has Opposite Sign to Test Statistic

Intuitively, I expect the test statistic and effect size to have the same sign. Why is it opposite?

library(ggstatsplot)
data <- data.frame(scores = c(rpois(10, 10), rpois(10, 20)),
                   groups = factor(rep(c("No", "Yes"), each = 10)))
ggbetweenstats(data, x = groups, y = scores, type = "nonparametric")

Is the convention supposed to be factor's level 2 - factor's level 1 (baseline) and the effect size should have opposite sign?

`WRS2` feature requests: Part 2

Expecting the future releases of WRS2 to offer the following functionality so that the internal helper functions can be removed.
All of these may or may not be supported.

New functionality

Bugs

Enhancements to existing functions

  • Add ... to all functions to make writing wrappers around them easier

Consistency-related issues across functions

  • Leave out p.crit column that is sporadically found only in certain WRS2 objects
  • yuen output contains se, while yuend doesn't - better to be consistent across these two function outputs
  • contain the tr value in returned objects
  • Just like t1way, contain the CIs for explanatory effect sizes in the output of yuen itself, so that the user doesn't have to run an additional test yuen.effect.ci
> yuen(Anxiety ~ Group, data = spider)
Call:
yuen(formula = Anxiety ~ Group, data = spider)

Test statistic: 1.2958 (df = 13.91), p-value = 0.21614

Trimmed mean difference:  -6.75 
95 percent confidence interval:
-17.9294     4.4294 

Explanatory measure of effect size: 0.38 

> yuen.effect.ci(Anxiety ~ Group, data = spider)
$effsize
[1] 0.3784167

$CI
[1] 0.0000000 0.8152107

General

correct way to enter argument for `cohenG` for `rcompanion`

# setup
library(rcompanion)
library(statsExpressions)
set.seed(123)

# data
df <-
  data.frame(cat1 = rep(c("A", "B"), 10), 
             cat2 = c(rep("C", 10), rep("D", 10)))

# method-1

as.matrix(table(df))
#>     cat2
#> cat1 C D
#>    A 5 5
#>    B 5 5

rcompanion::cohenG(as.matrix(table(df)), ci = TRUE, type = "norm", R = 10)
#> $Global.statistics
#>   Dimensions Statistic Value lower.ci upper.ci
#> 1      2 x 2        OR   1.0  -0.0311    2.170
#> 2      2 x 2         P   0.5   0.2420    0.896
#> 3      2 x 2         g   0.0  -0.2580    0.396

# method-2

factor.levels <- dplyr::union(levels(df$cat1), levels(df$cat2))

df %<>%
  dplyr::mutate_at(
    .tbl = .,
    .vars = dplyr::vars(cat1, cat2),
    .funs = factor,
    levels = factor.levels
  )

as.matrix(table(df))
#>     cat2
#> cat1 A B C D
#>    A 0 0 5 5
#>    B 0 0 5 5
#>    C 0 0 0 0
#>    D 0 0 0 0

rcompanion::cohenG(as.matrix(table(df)), ci = TRUE, type = "norm", R = 10)
#> Error in if (const(t, min(1e-08, mean(t, na.rm = TRUE)/1e+06))) {: missing value where TRUE/FALSE needed

Created on 2019-10-09 by the reprex package (v0.3.0)

Session info
devtools::session_info()
#> - Session info ----------------------------------------------------------
#>  setting  value                       
#>  version  R version 3.6.1 (2019-07-05)
#>  os       Windows 10 x64              
#>  system   x86_64, mingw32             
#>  ui       RTerm                       
#>  language (EN)                        
#>  collate  English_United States.1252  
#>  ctype    English_United States.1252  
#>  tz       Europe/Berlin               
#>  date     2019-10-09                  
#> 
#> - Packages --------------------------------------------------------------
#>  package          * version    date       lib
#>  abind              1.4-5      2016-07-21 [1]
#>  assertthat         0.2.1      2019-03-21 [1]
#>  backports          1.1.5      2019-10-02 [1]
#>  BayesFactor        0.9.12-4.2 2018-05-19 [1]
#>  bayestestR         0.3.0      2019-09-22 [1]
#>  boot               1.3-23     2019-07-05 [1]
#>  broom              0.5.2.9002 2019-08-15 [1]
#>  broom.mixed        0.2.4.9000 2019-08-07 [1]
#>  broomExtra         0.0.5.9000 2019-09-22 [1]
#>  callr              3.3.2      2019-09-22 [1]
#>  car                3.0-3      2019-05-27 [1]
#>  carData            3.0-2      2018-09-30 [1]
#>  cellranger         1.1.0      2016-07-27 [1]
#>  cli                1.1.0      2019-03-19 [1]
#>  cluster            2.1.0      2019-06-19 [2]
#>  coda               0.19-3     2019-07-05 [1]
#>  codetools          0.2-16     2018-12-24 [1]
#>  coin               1.3-1      2019-08-28 [1]
#>  colorspace         1.4-1      2019-03-18 [1]
#>  crayon             1.3.4      2017-09-16 [1]
#>  curl               4.2        2019-09-24 [1]
#>  data.table         1.12.4     2019-10-03 [1]
#>  DEoptimR           1.0-8      2016-11-19 [1]
#>  desc               1.2.0      2019-04-03 [1]
#>  DescTools          0.99.29    2019-09-26 [1]
#>  devtools           2.2.1      2019-09-24 [1]
#>  digest             0.6.21     2019-09-20 [1]
#>  dplyr              0.8.3      2019-07-04 [1]
#>  ellipsis           0.3.0      2019-09-20 [1]
#>  emmeans            1.4.1      2019-09-12 [1]
#>  EMT                1.1        2013-01-29 [1]
#>  estimability       1.3        2018-02-11 [1]
#>  evaluate           0.14       2019-05-28 [1]
#>  expm               0.999-4    2019-03-21 [1]
#>  ez                 4.4-0      2016-11-02 [1]
#>  fit.models         0.5-14     2017-04-06 [1]
#>  forcats            0.4.0      2019-02-17 [1]
#>  foreign            0.8-71     2018-07-20 [2]
#>  fs                 1.3.1      2019-05-06 [1]
#>  furrr              0.1.0      2018-05-16 [1]
#>  future             1.14.0     2019-07-02 [1]
#>  generics           0.0.2      2019-03-05 [1]
#>  ggplot2            3.2.1      2019-08-10 [1]
#>  globals            0.12.4     2018-10-11 [1]
#>  glue               1.3.1      2019-03-12 [1]
#>  groupedstats       0.0.9.9000 2019-10-01 [1]
#>  gtable             0.3.0      2019-03-25 [1]
#>  gtools             3.8.1      2018-06-26 [1]
#>  haven              2.1.1      2019-07-04 [1]
#>  highr              0.8        2019-03-20 [1]
#>  hms                0.5.1      2019-08-23 [1]
#>  htmltools          0.4.0      2019-10-04 [1]
#>  insight            0.5.0.9000 2019-09-16 [1]
#>  knitr              1.25       2019-09-18 [1]
#>  lattice            0.20-38    2018-11-04 [2]
#>  lazyeval           0.2.2      2019-03-15 [1]
#>  libcoin            1.0-5      2019-08-27 [1]
#>  lifecycle          0.1.0      2019-08-01 [1]
#>  listenv            0.7.0      2018-01-21 [1]
#>  lme4               1.1-21     2019-03-05 [1]
#>  lmtest             0.9-37     2019-04-30 [1]
#>  magrittr           1.5        2014-11-22 [1]
#>  MASS               7.3-51.4   2019-03-31 [1]
#>  Matrix             1.2-17     2019-03-22 [1]
#>  MatrixModels       0.4-1      2015-08-22 [1]
#>  matrixStats        0.55.0     2019-09-07 [1]
#>  mc2d               0.1-18     2017-03-06 [1]
#>  mcmc               0.9-6      2019-03-10 [1]
#>  MCMCpack           1.4-4      2018-09-14 [1]
#>  memoise            1.1.0      2017-04-21 [1]
#>  mgcv               1.8-29     2019-09-20 [1]
#>  minqa              1.2.4      2014-10-09 [1]
#>  mnormt             1.5-5      2016-10-15 [1]
#>  modelr             0.1.5      2019-08-08 [1]
#>  modeltools         0.2-22     2018-07-16 [1]
#>  multcomp           1.4-10     2019-03-05 [1]
#>  multcompView       0.1-7      2015-07-31 [1]
#>  munsell            0.5.0      2018-06-12 [1]
#>  mvtnorm            1.0-11     2019-06-19 [1]
#>  nlme               3.1-140    2019-05-12 [2]
#>  nloptr             1.2.1      2018-10-03 [1]
#>  nortest            1.0-4      2015-07-30 [1]
#>  openxlsx           4.1.0.1    2019-05-28 [1]
#>  parameters         0.2.0      2019-09-26 [1]
#>  pbapply            1.4-2      2019-08-31 [1]
#>  pcaPP              1.9-73     2018-01-14 [1]
#>  performance        0.3.0      2019-08-05 [1]
#>  pillar             1.4.2      2019-06-29 [1]
#>  pkgbuild           1.0.5      2019-08-26 [1]
#>  pkgconfig          2.0.3      2019-09-22 [1]
#>  pkgload            1.0.2      2018-10-29 [1]
#>  plyr               1.8.4      2016-06-08 [1]
#>  prettyunits        1.0.2      2015-07-13 [1]
#>  processx           3.4.1      2019-07-18 [1]
#>  ps                 1.3.0      2018-12-21 [1]
#>  psych              1.8.12     2019-01-12 [1]
#>  purrr              0.3.2      2019-03-15 [1]
#>  quantreg           5.51       2019-08-07 [1]
#>  R6                 2.4.0      2019-02-14 [1]
#>  rcompanion       * 2.3.7      2019-09-29 [1]
#>  Rcpp               1.0.2      2019-07-25 [1]
#>  readxl             1.3.1      2019-03-13 [1]
#>  remotes            2.1.0      2019-06-24 [1]
#>  reshape            0.8.8      2018-10-23 [1]
#>  reshape2           1.4.3      2017-12-11 [1]
#>  rio                0.5.16     2018-11-26 [1]
#>  rlang              0.4.0      2019-06-25 [1]
#>  rmarkdown          1.16       2019-10-01 [1]
#>  robust             0.4-18.1   2019-07-02 [1]
#>  robustbase         0.93-5     2019-05-12 [1]
#>  rprojroot          1.3-2      2018-01-03 [1]
#>  rrcov              1.4-7      2018-11-15 [1]
#>  rsample            0.0.5      2019-07-12 [1]
#>  rstudioapi         0.10       2019-03-19 [1]
#>  sandwich           2.5-1      2019-04-06 [1]
#>  scales             1.0.0      2018-08-09 [1]
#>  sessioninfo        1.1.1      2018-11-05 [1]
#>  sjlabelled         1.1.1      2019-09-13 [1]
#>  sjmisc             2.8.2      2019-09-24 [1]
#>  sjstats            0.17.6     2019-09-08 [1]
#>  skimr              1.0.7      2019-06-20 [1]
#>  SparseM            1.77       2017-04-23 [1]
#>  statsExpressions * 0.1.1.9000 2019-10-09 [1]
#>  stringi            1.4.3      2019-03-12 [1]
#>  stringr            1.4.0      2019-02-10 [1]
#>  survival           2.44-1.1   2019-04-01 [2]
#>  testthat           2.2.1      2019-07-25 [1]
#>  TH.data            1.0-10     2019-01-21 [1]
#>  tibble             2.1.3      2019-06-06 [1]
#>  tidyr              1.0.0      2019-09-11 [1]
#>  tidyselect         0.2.5      2018-10-11 [1]
#>  TMB                1.7.15     2018-11-09 [1]
#>  usethis            1.5.1.9000 2019-09-12 [1]
#>  vctrs              0.2.0      2019-07-05 [1]
#>  withr              2.1.2      2018-03-15 [1]
#>  WRS2               1.0-0      2019-06-05 [1]
#>  xfun               0.10       2019-10-01 [1]
#>  xtable             1.8-4      2019-04-21 [1]
#>  yaml               2.2.0      2018-07-25 [1]
#>  zeallot            0.1.0      2018-01-28 [1]
#>  zip                2.0.4      2019-09-01 [1]
#>  zoo                1.8-6      2019-05-28 [1]
#>  source                              
#>  CRAN (R 3.5.0)                      
#>  CRAN (R 3.6.0)                      
#>  CRAN (R 3.6.1)                      
#>  CRAN (R 3.5.1)                      
#>  CRAN (R 3.6.1)                      
#>  CRAN (R 3.6.1)                      
#>  local                               
#>  Github (bbolker/broom.mixed@46f79ec)
#>  local                               
#>  CRAN (R 3.6.1)                      
#>  CRAN (R 3.6.0)                      
#>  CRAN (R 3.5.1)                      
#>  CRAN (R 3.5.1)                      
#>  CRAN (R 3.6.0)                      
#>  CRAN (R 3.6.1)                      
#>  CRAN (R 3.6.0)                      
#>  CRAN (R 3.5.2)                      
#>  CRAN (R 3.6.1)                      
#>  CRAN (R 3.6.0)                      
#>  CRAN (R 3.5.1)                      
#>  CRAN (R 3.6.1)                      
#>  CRAN (R 3.6.1)                      
#>  CRAN (R 3.5.0)                      
#>  Github (r-lib/desc@c860e7b)         
#>  CRAN (R 3.6.1)                      
#>  CRAN (R 3.6.1)                      
#>  CRAN (R 3.6.1)                      
#>  CRAN (R 3.6.0)                      
#>  CRAN (R 3.6.1)                      
#>  CRAN (R 3.6.1)                      
#>  CRAN (R 3.5.2)                      
#>  CRAN (R 3.5.0)                      
#>  CRAN (R 3.6.0)                      
#>  CRAN (R 3.6.0)                      
#>  CRAN (R 3.5.3)                      
#>  CRAN (R 3.5.1)                      
#>  CRAN (R 3.5.2)                      
#>  CRAN (R 3.6.1)                      
#>  CRAN (R 3.6.0)                      
#>  CRAN (R 3.5.1)                      
#>  CRAN (R 3.6.0)                      
#>  Github (r-lib/generics@c15ac43)     
#>  CRAN (R 3.6.1)                      
#>  CRAN (R 3.5.1)                      
#>  CRAN (R 3.6.0)                      
#>  local                               
#>  CRAN (R 3.6.0)                      
#>  CRAN (R 3.5.0)                      
#>  CRAN (R 3.6.0)                      
#>  CRAN (R 3.6.0)                      
#>  CRAN (R 3.6.1)                      
#>  CRAN (R 3.6.1)                      
#>  local                               
#>  CRAN (R 3.6.1)                      
#>  CRAN (R 3.6.1)                      
#>  CRAN (R 3.6.0)                      
#>  CRAN (R 3.6.1)                      
#>  CRAN (R 3.6.1)                      
#>  CRAN (R 3.5.1)                      
#>  CRAN (R 3.6.0)                      
#>  CRAN (R 3.6.0)                      
#>  CRAN (R 3.5.1)                      
#>  CRAN (R 3.6.0)                      
#>  CRAN (R 3.6.0)                      
#>  CRAN (R 3.5.1)                      
#>  CRAN (R 3.6.1)                      
#>  CRAN (R 3.5.1)                      
#>  CRAN (R 3.6.0)                      
#>  CRAN (R 3.5.2)                      
#>  CRAN (R 3.6.0)                      
#>  CRAN (R 3.6.1)                      
#>  CRAN (R 3.5.1)                      
#>  CRAN (R 3.5.0)                      
#>  CRAN (R 3.6.1)                      
#>  CRAN (R 3.5.1)                      
#>  CRAN (R 3.5.2)                      
#>  CRAN (R 3.5.1)                      
#>  CRAN (R 3.5.1)                      
#>  CRAN (R 3.6.0)                      
#>  CRAN (R 3.6.1)                      
#>  CRAN (R 3.5.1)                      
#>  CRAN (R 3.5.2)                      
#>  CRAN (R 3.6.0)                      
#>  CRAN (R 3.6.1)                      
#>  CRAN (R 3.6.1)                      
#>  CRAN (R 3.5.0)                      
#>  CRAN (R 3.6.1)                      
#>  CRAN (R 3.6.0)                      
#>  CRAN (R 3.6.1)                      
#>  CRAN (R 3.6.1)                      
#>  CRAN (R 3.6.0)                      
#>  CRAN (R 3.5.1)                      
#>  CRAN (R 3.5.1)                      
#>  CRAN (R 3.6.1)                      
#>  CRAN (R 3.6.0)                      
#>  CRAN (R 3.6.0)                      
#>  CRAN (R 3.6.0)                      
#>  CRAN (R 3.6.1)                      
#>  CRAN (R 3.6.0)                      
#>  CRAN (R 3.6.1)                      
#>  CRAN (R 3.6.1)                      
#>  CRAN (R 3.6.0)                      
#>  CRAN (R 3.6.0)                      
#>  CRAN (R 3.6.0)                      
#>  CRAN (R 3.5.1)                      
#>  CRAN (R 3.6.0)                      
#>  CRAN (R 3.6.0)                      
#>  CRAN (R 3.6.1)                      
#>  CRAN (R 3.6.0)                      
#>  CRAN (R 3.6.0)                      
#>  CRAN (R 3.5.1)                      
#>  CRAN (R 3.6.0)                      
#>  CRAN (R 3.6.1)                      
#>  CRAN (R 3.6.0)                      
#>  CRAN (R 3.6.0)                      
#>  CRAN (R 3.5.1)                      
#>  CRAN (R 3.6.0)                      
#>  CRAN (R 3.6.1)                      
#>  CRAN (R 3.6.1)                      
#>  CRAN (R 3.6.1)                      
#>  CRAN (R 3.6.0)                      
#>  CRAN (R 3.5.0)                      
#>  local                               
#>  CRAN (R 3.6.0)                      
#>  CRAN (R 3.6.0)                      
#>  CRAN (R 3.6.1)                      
#>  CRAN (R 3.6.1)                      
#>  CRAN (R 3.5.2)                      
#>  CRAN (R 3.6.0)                      
#>  CRAN (R 3.6.1)                      
#>  CRAN (R 3.5.1)                      
#>  CRAN (R 3.6.0)                      
#>  Github (r-lib/usethis@a2342b8)      
#>  CRAN (R 3.6.1)                      
#>  CRAN (R 3.5.1)                      
#>  R-Forge (R 3.6.0)                   
#>  CRAN (R 3.6.1)                      
#>  CRAN (R 3.5.3)                      
#>  CRAN (R 3.5.1)                      
#>  CRAN (R 3.5.1)                      
#>  CRAN (R 3.6.1)                      
#>  CRAN (R 3.6.0)                      
#> 
#> [1] C:/Users/inp099/Documents/R/win-library/3.6
#> [2] C:/Program Files/R/R-3.6.1/library

Select specific stats

Hello,

Is there a way to do a specific test, e.g. just the chi-squared test without the Crammer V?

Many thanks.

`expr_contingency_tab` needs to protect against wrong test label

Introduced in b536416

library(statsExpressions)

df <- dplyr::filter(mtcars, am == "0")

stats::chisq.test(table(df$am, df$cyl))
#> 
#>  Chi-squared test for given probabilities
#> 
#> data:  table(df$am, df$cyl)
#> X-squared = 7.6842, df = 2, p-value = 0.02145

expr_contingency_tab(mtcars, am, cyl)
#> Warning in stats::chisq.test(x = x_arg, correct = FALSE): Chi-squared
#> approximation may be incorrect
#> paste(chi["Pearson"]^2, "(", "2", ") = ", "8.74", ", ", italic("p"), 
#>     " = ", "0.013", ", ", widehat(italic("V"))["Cramer"], " = ", 
#>     "0.46", ", CI"["95%"], " [", "0.00", ", ", "0.78", "]", ", ", 
#>     italic("n")["obs"], " = ", 32L)

Created on 2020-10-14 by the reprex package (v0.3.0.9001)

checking results from metaBMA

  • MacOS
library(metaBMA)
#> Loading required package: Rcpp

data(towels)
set.seed(123)
meta_random(logOR, SE, study, data = towels)

#> Warning: There were 2 divergent transitions after warmup. Increasing adapt_delta above 0.95 may help. See
#> http://mc-stan.org/misc/warnings.html#divergent-transitions-after-warmup
#> Warning: Examine the pairs() plot to diagnose sampling problems

#> ### Bayesian Random-Effects Meta-Analysis ### 
#>    Prior on d:      'norm' (mean=0, sd=0.3) with support on the interval [-Inf,Inf]. 
#>    Prior on tau:    'invgamma' (shape=1, scale=0.15) with support on the interval [0,Inf]. 
#> 
#> # Bayes factors:
#>            (denominator)
#> (numerator) random_H0 random_H1
#>   random_H0         1     0.501
#>   random_H1         2     1.000

#> # Posterior summary statistics of random-effects model:
#>      mean    sd   2.5%   50% 97.5% hpd95_lower hpd95_upper  n_eff  Rhat
#> d   0.183 0.102 -0.041 0.189 0.368      -0.027       0.376 5352.8 1.001
#> tau 0.135 0.097  0.033 0.109 0.391       0.019       0.321 3909.1 1.000

Created on 2020-01-26 by the reprex package (v0.3.0)

Session info
devtools::session_info()
#> โ”€ Session info โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
#>  setting  value                       
#>  version  R version 3.6.2 (2019-12-12)
#>  os       macOS Mojave 10.14.6        
#>  system   x86_64, darwin15.6.0        
#>  ui       X11                         
#>  language (EN)                        
#>  collate  en_US.UTF-8                 
#>  ctype    en_US.UTF-8                 
#>  tz       Europe/Berlin               
#>  date     2020-01-26                  
#> 
#> โ”€ Packages โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
#>  package        * version    date       lib source                          
#>  assertthat       0.2.1      2019-03-21 [1] CRAN (R 3.6.0)                  
#>  backports        1.1.5      2019-10-02 [1] CRAN (R 3.6.0)                  
#>  bridgesampling   0.8-1      2020-01-16 [1] CRAN (R 3.6.0)                  
#>  Brobdingnag      1.2-6      2018-08-13 [1] CRAN (R 3.6.0)                  
#>  callr            3.4.1      2020-01-24 [1] CRAN (R 3.6.2)                  
#>  cli              2.0.1      2020-01-08 [1] CRAN (R 3.6.2)                  
#>  coda             0.19-3     2019-07-05 [1] CRAN (R 3.6.0)                  
#>  codetools        0.2-16     2018-12-24 [2] CRAN (R 3.6.2)                  
#>  colorspace       1.4-1      2019-03-18 [1] CRAN (R 3.6.0)                  
#>  crayon           1.3.4      2017-09-16 [1] CRAN (R 3.6.0)                  
#>  desc             1.2.0      2018-05-01 [1] CRAN (R 3.6.0)                  
#>  devtools         2.2.1      2019-09-24 [1] CRAN (R 3.6.0)                  
#>  digest           0.6.23     2019-11-23 [1] CRAN (R 3.6.0)                  
#>  dplyr            0.8.3.9000 2019-10-15 [1] Github (tidyverse/dplyr@55f4151)
#>  ellipsis         0.3.0      2019-09-20 [1] CRAN (R 3.6.0)                  
#>  evaluate         0.14       2019-05-28 [1] CRAN (R 3.6.0)                  
#>  fansi            0.4.1      2020-01-08 [1] CRAN (R 3.6.2)                  
#>  fs               1.3.1      2019-05-06 [1] CRAN (R 3.6.0)                  
#>  ggplot2          3.2.1      2019-08-10 [1] CRAN (R 3.6.0)                  
#>  glue             1.3.1      2019-03-12 [1] CRAN (R 3.6.0)                  
#>  gridExtra        2.3        2017-09-09 [1] CRAN (R 3.6.0)                  
#>  gtable           0.3.0      2019-03-25 [1] CRAN (R 3.6.0)                  
#>  highr            0.8        2019-03-20 [1] CRAN (R 3.6.0)                  
#>  htmltools        0.4.0      2019-10-04 [1] CRAN (R 3.6.0)                  
#>  inline           0.3.15     2018-05-18 [1] CRAN (R 3.6.0)                  
#>  knitr            1.27       2020-01-16 [1] CRAN (R 3.6.0)                  
#>  LaplacesDemon    16.1.1     2018-06-30 [1] CRAN (R 3.6.0)                  
#>  lattice          0.20-38    2018-11-04 [2] CRAN (R 3.6.2)                  
#>  lazyeval         0.2.2      2019-03-15 [1] CRAN (R 3.6.0)                  
#>  lifecycle        0.1.0      2019-08-01 [1] CRAN (R 3.6.0)                  
#>  logspline        2.1.15     2019-11-08 [1] CRAN (R 3.6.0)                  
#>  loo              2.2.0      2019-12-19 [1] CRAN (R 3.6.2)                  
#>  magrittr         1.5        2014-11-22 [1] CRAN (R 3.6.0)                  
#>  Matrix           1.2-18     2019-11-27 [2] CRAN (R 3.6.2)                  
#>  matrixStats      0.55.0     2019-09-07 [1] CRAN (R 3.6.0)                  
#>  memoise          1.1.0      2017-04-21 [1] CRAN (R 3.6.0)                  
#>  metaBMA        * 0.6.2      2019-09-16 [1] CRAN (R 3.6.0)                  
#>  munsell          0.5.0      2018-06-12 [1] CRAN (R 3.6.0)                  
#>  mvtnorm          1.0-12     2020-01-09 [1] CRAN (R 3.6.0)                  
#>  pillar           1.4.3      2019-12-20 [1] CRAN (R 3.6.2)                  
#>  pkgbuild         1.0.6      2019-10-09 [1] CRAN (R 3.6.0)                  
#>  pkgconfig        2.0.3      2019-09-22 [1] CRAN (R 3.6.0)                  
#>  pkgload          1.0.2      2018-10-29 [1] CRAN (R 3.6.0)                  
#>  prettyunits      1.1.1      2020-01-24 [1] CRAN (R 3.6.2)                  
#>  processx         3.4.1      2019-07-18 [1] CRAN (R 3.6.0)                  
#>  ps               1.3.0      2018-12-21 [1] CRAN (R 3.6.0)                  
#>  purrr            0.3.3      2019-10-18 [1] CRAN (R 3.6.0)                  
#>  R6               2.4.1      2019-11-12 [1] CRAN (R 3.6.0)                  
#>  Rcpp           * 1.0.3      2019-11-08 [1] CRAN (R 3.6.1)                  
#>  remotes          2.1.0      2019-06-24 [1] CRAN (R 3.6.0)                  
#>  rlang            0.4.3      2020-01-24 [1] CRAN (R 3.6.2)                  
#>  rmarkdown        2.1        2020-01-20 [1] CRAN (R 3.6.2)                  
#>  rprojroot        1.3-2      2018-01-03 [1] CRAN (R 3.6.0)                  
#>  rstan            2.19.2     2019-07-09 [1] CRAN (R 3.6.0)                  
#>  rstantools       2.0.0      2019-09-15 [1] CRAN (R 3.6.0)                  
#>  scales           1.1.0      2019-11-18 [1] CRAN (R 3.6.0)                  
#>  sessioninfo      1.1.1      2018-11-05 [1] CRAN (R 3.6.0)                  
#>  StanHeaders      2.21.0-1   2020-01-19 [1] CRAN (R 3.6.2)                  
#>  stringi          1.4.5      2020-01-11 [1] CRAN (R 3.6.2)                  
#>  stringr          1.4.0      2019-02-10 [1] CRAN (R 3.6.0)                  
#>  testthat         2.3.1      2019-12-01 [1] CRAN (R 3.6.0)                  
#>  tibble           2.1.3      2019-06-06 [1] CRAN (R 3.6.0)                  
#>  tidyselect       0.2.5      2018-10-11 [1] CRAN (R 3.6.0)                  
#>  usethis          1.5.1      2019-07-04 [1] CRAN (R 3.6.0)                  
#>  withr            2.1.2      2018-03-15 [1] CRAN (R 3.6.0)                  
#>  xfun             0.12       2020-01-13 [1] CRAN (R 3.6.2)                  
#>  yaml             2.2.0      2018-07-25 [1] CRAN (R 3.6.0)                  
#> 
#> [1] /Users/patil/Library/R/3.6/library
#> [2] /Library/Frameworks/R.framework/Versions/3.6/Resources/library

brain dump

  • Drop crayon re-exports. These are not being used anywhere except ggstatsplot
  • Remove outlier_df - it's not used anywhere but ggstatsplot
  • Have a tidy alias for specify_decimal_p (something like format_num?)
  • Remove set_cwd(). I think this is a bad idea. here::here should be encouraged.
  • retire specify_decimal_p in favor of format_num
  • remove reference to groupedstats
  • don't use parameters for testing

ungroup before running correlation analysis

df <- dplyr::group_by(mtcars, am)

statsExpressions::expr_corr_test(df, wt, mpg)
#> Adding missing grouping variables: `am`
#> # A tibble: 2 x 14
#>   group parameter1 parameter2 estimate conf.level conf.low conf.high statistic
#>   <chr> <chr>      <chr>         <dbl>      <dbl>    <dbl>     <dbl>     <dbl>
#> 1 0     wt         mpg          -0.768       0.95   -0.906    -0.481     -4.94
#> 2 1     wt         mpg          -0.909       0.95   -0.973    -0.717     -7.23
#> # โ€ฆ with 6 more variables: df.error <int>, p.value <dbl>, method <chr>,
#> #   n.obs <int>, effectsize <chr>, expression <list>

Created on 2021-02-26 by the reprex package (v1.0.0)

`yuen.effect.ci` and `statsExpressions` outputs aren't identical

library(statsExpressions)
#> Registered S3 method overwritten by 'broom.mixed':
#>   method      from 
#>   tidy.gamlss broom
#> Registered S3 methods overwritten by 'lme4':
#>   method                          from
#>   cooks.distance.influence.merMod car 
#>   influence.merMod                car 
#>   dfbeta.influence.merMod         car 
#>   dfbetas.influence.merMod        car
library(WRS2)

set.seed(123)
yuen.effect.ci(wt ~ am,
               data = mtcars,
               tr = 0.2,
               nboot = 100)
#> $effsize
#> [1] 0.9149793
#> 
#> $CI
#> [1] 0.7388653 0.9785818

set.seed(123)
expr_t_robust(mtcars,
               am,
               wt,
               type = "r",
               tr = 0.2,
               nboot = 100,
               k = 4,
               messages = FALSE)
#> paste(NULL, italic("t"), "(", "13.5838", ") = ", "5.8400", ", ", 
#>     italic("p"), " = ", "< 0.001", ", ", widehat(italic(xi)), 
#>     " = ", "0.9177", ", CI"["95%"], " [", "0.6794", ", ", "0.9942", 
#>     "]", ", ", italic("n")["obs"], " = ", 32L)

Created on 2019-12-29 by the reprex package (v0.3.0)

Session info
devtools::session_info()
#> - Session info ---------------------------------------------------------------
#>  setting  value                       
#>  version  R version 3.6.2 (2019-12-12)
#>  os       Windows 10 x64              
#>  system   x86_64, mingw32             
#>  ui       RTerm                       
#>  language (EN)                        
#>  collate  English_United States.1252  
#>  ctype    English_United States.1252  
#>  tz       Europe/Berlin               
#>  date     2019-12-29                  
#> 
#> - Packages -------------------------------------------------------------------
#>  package          * version    date       lib
#>  abind              1.4-5      2016-07-21 [1]
#>  assertthat         0.2.1      2019-03-21 [1]
#>  backports          1.1.5      2019-10-02 [1]
#>  base64enc          0.1-3      2015-07-28 [1]
#>  BayesFactor        0.9.12-4.2 2018-05-19 [1]
#>  bayestestR         0.4.0      2019-10-20 [1]
#>  boot               1.3-24     2019-12-20 [1]
#>  broom              0.5.3.9000 2019-12-15 [1]
#>  broom.mixed        0.2.4.9000 2019-08-07 [1]
#>  broomExtra         1.0.0.9000 2019-12-17 [1]
#>  callr              3.4.0      2019-12-09 [1]
#>  car                3.0-6      2019-12-23 [1]
#>  carData            3.0-3      2019-11-16 [1]
#>  cellranger         1.1.0      2016-07-27 [1]
#>  cli                2.0.0.9000 2019-12-23 [1]
#>  cluster            2.1.0      2019-06-19 [2]
#>  coda               0.19-3     2019-07-05 [1]
#>  codetools          0.2-16     2018-12-24 [1]
#>  coin               1.3-1      2019-08-28 [1]
#>  colorspace         1.4-1      2019-03-18 [1]
#>  crayon             1.3.4      2017-09-16 [1]
#>  curl               4.3        2019-12-02 [1]
#>  data.table         1.12.8     2019-12-09 [1]
#>  DEoptimR           1.0-8      2016-11-19 [1]
#>  desc               1.2.0      2019-11-11 [1]
#>  DescTools          0.99.31    2019-12-02 [1]
#>  devtools           2.2.1      2019-09-24 [1]
#>  digest             0.6.23     2019-11-23 [1]
#>  dplyr              0.8.3      2019-07-04 [1]
#>  ellipsis           0.3.0      2019-09-20 [1]
#>  emmeans            1.4.3.01   2019-11-28 [1]
#>  EMT                1.1        2013-01-29 [1]
#>  estimability       1.3        2018-02-11 [1]
#>  evaluate           0.14       2019-05-28 [1]
#>  expm               0.999-4    2019-03-21 [1]
#>  ez                 4.4-0      2016-11-02 [1]
#>  fansi              0.4.0      2018-11-05 [1]
#>  fit.models         0.5-14     2017-04-06 [1]
#>  forcats            0.4.0      2019-02-17 [1]
#>  foreign            0.8-72     2019-08-02 [2]
#>  fs                 1.3.1      2019-05-06 [1]
#>  generics           0.0.2      2019-03-05 [1]
#>  ggplot2            3.2.1      2019-08-10 [1]
#>  glue               1.3.1      2019-03-12 [1]
#>  groupedstats       0.1.0.9000 2019-11-26 [1]
#>  gtable             0.3.0      2019-03-25 [1]
#>  gtools             3.8.1      2018-06-26 [1]
#>  haven              2.2.0      2019-11-08 [1]
#>  highr              0.8        2019-03-20 [1]
#>  hms                0.5.2      2019-10-30 [1]
#>  htmltools          0.4.0      2019-10-04 [1]
#>  insight            0.7.1.1    2019-12-28 [1]
#>  jsonlite           1.6        2018-12-07 [1]
#>  knitr              1.26       2019-11-12 [1]
#>  lattice            0.20-38    2018-11-04 [2]
#>  lazyeval           0.2.2      2019-03-15 [1]
#>  libcoin            1.0-5      2019-08-27 [1]
#>  lifecycle          0.1.0      2019-08-01 [1]
#>  lme4               1.1-21     2019-03-05 [1]
#>  lmtest             0.9-37     2019-04-30 [1]
#>  magrittr           1.5        2014-11-22 [1]
#>  MASS               7.3-51.5   2019-12-20 [1]
#>  Matrix             1.2-18     2019-11-27 [1]
#>  MatrixModels       0.4-1      2015-08-22 [1]
#>  matrixStats        0.55.0     2019-09-07 [1]
#>  mc2d               0.1-18     2017-03-06 [1]
#>  memoise            1.1.0      2017-04-21 [1]
#>  mgcv               1.8-31     2019-11-09 [1]
#>  minqa              1.2.4      2014-10-09 [1]
#>  mnormt             1.5-5      2016-10-15 [1]
#>  modelr             0.1.5      2019-08-08 [1]
#>  modeltools         0.2-22     2018-07-16 [1]
#>  multcomp           1.4-11     2019-12-10 [1]
#>  multcompView       0.1-8      2019-12-19 [1]
#>  munsell            0.5.0      2018-06-12 [1]
#>  mvtnorm            1.0-11     2019-06-19 [1]
#>  nlme               3.1-142    2019-11-07 [2]
#>  nloptr             1.2.1      2018-10-03 [1]
#>  nortest            1.0-4      2015-07-30 [1]
#>  openxlsx           4.1.4      2019-12-06 [1]
#>  parameters         0.3.0.1    2019-12-24 [1]
#>  pbapply            1.4-2      2019-08-31 [1]
#>  pcaPP              1.9-73     2018-01-14 [1]
#>  performance        0.4.2.1    2019-12-24 [1]
#>  pillar             1.4.3      2019-12-20 [1]
#>  pkgbuild           1.0.6      2019-10-09 [1]
#>  pkgconfig          2.0.3      2019-09-22 [1]
#>  pkgload            1.0.2      2018-10-29 [1]
#>  plyr               1.8.5      2019-12-10 [1]
#>  prettyunits        1.0.2      2015-07-13 [1]
#>  processx           3.4.1      2019-07-18 [1]
#>  ps                 1.3.0      2018-12-21 [1]
#>  psych              1.9.12     2019-12-20 [1]
#>  purrr              0.3.3      2019-10-18 [1]
#>  R6                 2.4.1      2019-11-12 [1]
#>  rcompanion         2.3.9      2019-12-27 [1]
#>  Rcpp               1.0.3      2019-11-08 [1]
#>  readxl             1.3.1      2019-03-13 [1]
#>  remotes            2.1.0      2019-06-24 [1]
#>  repr               1.0.2      2019-12-16 [1]
#>  reshape            0.8.8      2018-10-23 [1]
#>  reshape2           1.4.3      2017-12-11 [1]
#>  rio                0.5.16     2018-11-26 [1]
#>  rlang              0.4.2      2019-11-23 [1]
#>  rmarkdown          2.0        2019-12-12 [1]
#>  robust             0.4-18.2   2019-12-26 [1]
#>  robustbase         0.93-5     2019-05-12 [1]
#>  rprojroot          1.3-2      2018-01-03 [1]
#>  rrcov              1.4-9      2019-11-25 [1]
#>  rstudioapi         0.10       2019-03-19 [1]
#>  sandwich           2.5-1      2019-04-06 [1]
#>  scales             1.1.0      2019-11-18 [1]
#>  sessioninfo        1.1.1      2018-11-05 [1]
#>  sjlabelled         1.1.1      2019-09-13 [1]
#>  sjmisc             2.8.2      2019-09-24 [1]
#>  sjstats            0.17.7     2019-11-14 [1]
#>  skimr              2.0.2      2019-11-26 [1]
#>  statsExpressions * 0.2.0.9000 2019-12-28 [1]
#>  stringi            1.4.3      2019-03-12 [1]
#>  stringr            1.4.0      2019-02-10 [1]
#>  survival           3.1-8      2019-12-03 [1]
#>  testthat           2.3.1      2019-12-01 [1]
#>  TH.data            1.0-10     2019-01-21 [1]
#>  tibble             2.1.3      2019-06-06 [1]
#>  tidyr              1.0.0      2019-09-11 [1]
#>  tidyselect         0.2.5      2018-10-11 [1]
#>  TMB                1.7.15     2018-11-09 [1]
#>  usethis            1.5.1.9000 2019-12-12 [1]
#>  vctrs              0.2.1      2019-12-17 [1]
#>  withr              2.1.2      2018-03-15 [1]
#>  WRS2             * 1.0-0      2019-06-05 [1]
#>  xfun               0.11       2019-11-12 [1]
#>  xtable             1.8-4      2019-04-21 [1]
#>  yaml               2.2.0      2018-07-25 [1]
#>  zeallot            0.1.0      2018-01-28 [1]
#>  zip                2.0.4      2019-09-01 [1]
#>  zoo                1.8-6      2019-05-28 [1]
#>  source                               
#>  CRAN (R 3.5.0)                       
#>  CRAN (R 3.6.0)                       
#>  CRAN (R 3.6.1)                       
#>  CRAN (R 3.5.0)                       
#>  CRAN (R 3.5.1)                       
#>  CRAN (R 3.6.1)                       
#>  CRAN (R 3.6.1)                       
#>  local                                
#>  Github (bbolker/broom.mixed@46f79ec) 
#>  local                                
#>  CRAN (R 3.6.1)                       
#>  CRAN (R 3.6.1)                       
#>  CRAN (R 3.6.1)                       
#>  CRAN (R 3.5.1)                       
#>  Github (r-lib/cli@0293ae7)           
#>  CRAN (R 3.6.2)                       
#>  CRAN (R 3.6.0)                       
#>  CRAN (R 3.5.2)                       
#>  CRAN (R 3.6.1)                       
#>  CRAN (R 3.6.0)                       
#>  CRAN (R 3.5.1)                       
#>  CRAN (R 3.6.1)                       
#>  CRAN (R 3.6.1)                       
#>  CRAN (R 3.5.0)                       
#>  Github (r-lib/desc@61205f6)          
#>  CRAN (R 3.6.1)                       
#>  CRAN (R 3.6.1)                       
#>  CRAN (R 3.6.1)                       
#>  CRAN (R 3.6.2)                       
#>  CRAN (R 3.6.1)                       
#>  CRAN (R 3.6.1)                       
#>  CRAN (R 3.5.2)                       
#>  CRAN (R 3.5.0)                       
#>  CRAN (R 3.6.0)                       
#>  CRAN (R 3.6.0)                       
#>  CRAN (R 3.5.3)                       
#>  Github (brodieG/fansi@ab11e9c)       
#>  CRAN (R 3.5.1)                       
#>  CRAN (R 3.5.2)                       
#>  CRAN (R 3.6.2)                       
#>  CRAN (R 3.6.0)                       
#>  Github (r-lib/generics@c15ac43)      
#>  CRAN (R 3.6.1)                       
#>  CRAN (R 3.6.0)                       
#>  local                                
#>  CRAN (R 3.6.0)                       
#>  CRAN (R 3.5.0)                       
#>  CRAN (R 3.6.1)                       
#>  CRAN (R 3.6.0)                       
#>  CRAN (R 3.6.1)                       
#>  CRAN (R 3.6.1)                       
#>  local                                
#>  CRAN (R 3.6.0)                       
#>  CRAN (R 3.6.1)                       
#>  CRAN (R 3.6.2)                       
#>  CRAN (R 3.6.0)                       
#>  CRAN (R 3.6.1)                       
#>  CRAN (R 3.6.1)                       
#>  CRAN (R 3.6.0)                       
#>  CRAN (R 3.6.0)                       
#>  CRAN (R 3.5.1)                       
#>  CRAN (R 3.6.1)                       
#>  CRAN (R 3.6.1)                       
#>  CRAN (R 3.5.1)                       
#>  CRAN (R 3.6.1)                       
#>  CRAN (R 3.5.1)                       
#>  CRAN (R 3.6.0)                       
#>  CRAN (R 3.6.1)                       
#>  CRAN (R 3.5.1)                       
#>  CRAN (R 3.5.0)                       
#>  CRAN (R 3.6.1)                       
#>  CRAN (R 3.5.1)                       
#>  CRAN (R 3.6.1)                       
#>  CRAN (R 3.6.1)                       
#>  CRAN (R 3.5.1)                       
#>  CRAN (R 3.6.0)                       
#>  CRAN (R 3.6.2)                       
#>  CRAN (R 3.5.1)                       
#>  CRAN (R 3.5.2)                       
#>  CRAN (R 3.6.1)                       
#>  Github (easystats/parameters@78e4442)
#>  CRAN (R 3.6.1)                       
#>  CRAN (R 3.5.0)                       
#>  local                                
#>  CRAN (R 3.6.2)                       
#>  CRAN (R 3.6.1)                       
#>  CRAN (R 3.6.1)                       
#>  CRAN (R 3.6.0)                       
#>  CRAN (R 3.6.1)                       
#>  CRAN (R 3.5.1)                       
#>  CRAN (R 3.6.1)                       
#>  CRAN (R 3.6.0)                       
#>  CRAN (R 3.6.2)                       
#>  CRAN (R 3.6.1)                       
#>  CRAN (R 3.6.1)                       
#>  local                                
#>  CRAN (R 3.6.1)                       
#>  CRAN (R 3.6.0)                       
#>  CRAN (R 3.6.0)                       
#>  CRAN (R 3.6.1)                       
#>  CRAN (R 3.6.0)                       
#>  CRAN (R 3.5.1)                       
#>  CRAN (R 3.6.0)                       
#>  CRAN (R 3.6.2)                       
#>  CRAN (R 3.6.1)                       
#>  CRAN (R 3.6.1)                       
#>  CRAN (R 3.6.0)                       
#>  CRAN (R 3.5.1)                       
#>  CRAN (R 3.6.1)                       
#>  CRAN (R 3.6.0)                       
#>  CRAN (R 3.6.0)                       
#>  CRAN (R 3.6.1)                       
#>  CRAN (R 3.6.0)                       
#>  CRAN (R 3.6.1)                       
#>  CRAN (R 3.6.1)                       
#>  CRAN (R 3.6.1)                       
#>  CRAN (R 3.6.1)                       
#>  local                                
#>  CRAN (R 3.6.0)                       
#>  CRAN (R 3.6.0)                       
#>  CRAN (R 3.6.1)                       
#>  CRAN (R 3.6.1)                       
#>  CRAN (R 3.5.2)                       
#>  CRAN (R 3.6.2)                       
#>  CRAN (R 3.6.1)                       
#>  CRAN (R 3.6.2)                       
#>  CRAN (R 3.6.1)                       
#>  Github (r-lib/usethis@23dd62c)       
#>  CRAN (R 3.6.2)                       
#>  CRAN (R 3.5.1)                       
#>  R-Forge (R 3.6.0)                    
#>  CRAN (R 3.6.1)                       
#>  CRAN (R 3.5.3)                       
#>  CRAN (R 3.5.1)                       
#>  CRAN (R 3.5.1)                       
#>  CRAN (R 3.6.1)                       
#>  CRAN (R 3.6.0)                       
#> 
#> [1] C:/Users/inp099/Documents/R/win-library/3.6
#> [2] C:/Program Files/R/R-3.6.2/library

McNemar's test: is this supposed to work?

# setup
set.seed(123)
library(ggplot2)
library(ggalluvial)
data(vaccinations)

df <- vaccinations %>%
  dplyr::mutate(.data = ., survey = droplevels(survey)) %>%
  tidyr::uncount(., freq)

table(df$survey, df$response)
#>            
#>             Missing Never Sometimes Always
#>   ms153_NSA      92   132       584    145
#>   ms432_NSA     498    93       215    147
#>   ms460_NSA       7   163       401    382

stats::mcnemar.test(table(df$survey, df$response))
#> Error in stats::mcnemar.test(table(df$survey, df$response)): 'x' must be square with at least two rows and columns

rcompanion::cohenG(table(df$survey, df$response))
#> Error in rcompanion::cohenG(table(df$survey, df$response)): Matrix must be square with at least two rows and columns

Created on 2020-03-27 by the reprex package (v0.3.0.9001)

breaking tests after parameter update

These are the issues for the current parameters I'm submitting:

  > base::assign(".ptime", proc.time(), pos = "CheckExEnv")
  > ### Name: expr_anova_bayes
  > ### Title: Expression containing Bayesian one-way ANOVA results
  > ### Aliases: expr_anova_bayes
  > 
  > ### ** Examples
  > 
  > # setup
  > set.seed(123)
  > library(statsExpressions)
  > 
  > expr_anova_bayes(
  +   data = ggplot2::msleep,
  +   x = vore,
  +   y = sleep_rem
  + )
  Error: Can't recycle `..1` (size 7) to match `..2` (size 0).
  Backtrace:
      โ–ˆ
   1. โ”œโ”€statsExpressions::expr_anova_bayes(...)
   2. โ”‚ โ””โ”€tidyBF::bf_oneway_anova(...)
   3. โ”‚   โ””โ”€tidyBF::bf_extractor(bf_object, ...)
   4. โ”‚     โ””โ”€dplyr::bind_cols(...)
   5. โ”‚       โ””โ”€vctrs::vec_cbind(!!!dots, .name_repair = .name_repair)
   6. โ””โ”€vctrs::stop_incompatible_size(...)
   7.   โ””โ”€vctrs:::stop_incompatible(...)
   8.     โ””โ”€vctrs:::stop_vctrs(...)
  Execution halted

Have you resolved this issue, i.e. does statsExpressions work with the latest parameters?

Customisation of Subtitle Formatting

Could it be easier in future to customise the subtitle formatting style? For example,

image

I would like to have the test statistic on linear scale rather than log scale (most texts use linear scale) and p-value shown in format

image

Also, isn't it commonly known as the U test? I wonder why W is used for the test statistic.

Using `alternative` argument

I'm using one_sample_test in one-tailed comparison, and the alternative argument is missing.

Either this is something that you may not consider as from previous issue (#10), or is this something related with issue from another repository IndrajeetPatil/pairwiseComparisons#28

Any plan to add this in near future?

Thanks

roadmap for `0.7.0`

  • use parameters to extract a dataframe from onesampb
  • remove summary table here https://indrajeetpatil.github.io/statsExpressions/articles/stats_details.html#two-sample-tests-1
  • use effectsize instead of rcompanion to extract effect sizes for non-parametric tests
  • see if effectsize would add a column effsize.method to the output dataframe with more detailed description of the effect size
  • if model_parameters returns effect sizes for non-parametric tests as well, collapse individual expr_t_* and expr_anova_* type functions to one function
  • move bf_ functions to statsExpressions and cover them under type argument

pending `WRS2` feature requests

Expecting the future releases of WRS2 to offer the following functionality so that the internal helper functions can be removed. All of these may or may not be supported.

  • Effect size measure + its confidence intervals for WRS2::rmanova
  • Confidence intervals for effect size measure for WRS2::t1way
  • Confidence intervals for percentage bend correlation, both WRS2::pbcor and WRS2::pball
  • Confidence intervals for effect size measure for WRS2::yuend
  • Supporting bootstrap-t method for one-sample test (new function? WRS2::trimcibt)
  • Fix bug (#13 (comment))
  • IndrajeetPatil/pairwiseComparisons#12

failing rev-dep checks for insight

insight was just submitted, and this is the result of the rev-dep-checks:

  Running the tests in โ€˜tests/testthat.Rโ€™ failed.
  Complete output:
    > library(testthat)
    > library(statsExpressions)
    > 
    > test_check("statsExpressions")
    Starting 2 test processes
    โ•โ• Skipped tests โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
    โ— On CRAN (19)
    
    โ•โ• Failed tests โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
    โ”€โ”€ Failure (test-t-dataframes.R:23:5):  dataframes for parametric t-tests โ”€โ”€โ”€โ”€โ”€โ”€
    `df_1` (`actual`) not equal to structure(...) (`expected`).
    
         names(actual) | names(expected)     
     [4] "p.value"     | "p.value"       [4] 
     [5] "method"      | "method"        [5] 
     [6] "estimate"    | "estimate"      [6] 
     [7] "conf.level"  - "ci.width"      [7] 
     [8] "conf.low"    | "conf.low"      [8] 
     [9] "conf.high"   | "conf.high"     [9] 
    [10] "effectsize"  | "effectsize"    [10]
    
    `actual$conf.level` is a double vector (0.89, 0.99, 0.9, 0.5)
    `expected$conf.level` is absent
    
    `actual$ci.width` is absent
    `expected$ci.width` is a double vector (0.89, 0.99, 0.9, 0.5)
    โ”€โ”€ Failure (test-t-dataframes.R:98:5):  dataframes for parametric t-tests โ”€โ”€โ”€โ”€โ”€โ”€
    `df_2_between` (`actual`) not equal to structure(...) (`expected`).
    
         names(actual) | names(expected)     
     [7] "p.value"     | "p.value"       [7] 
     [8] "method"      | "method"        [8] 
     [9] "estimate"    | "estimate"      [9] 
    [10] "conf.level"  - "ci.width"      [10]
    [11] "conf.low"    | "conf.low"      [11]
    [12] "conf.high"   | "conf.high"     [12]
    [13] "effectsize"  | "effectsize"    [13]
    
    `actual$conf.level` is a double vector (0.89, 0.99, 0.9, 0.5)
    `expected$conf.level` is absent
    
    `actual$ci.width` is absent
    `expected$ci.width` is a double vector (0.89, 0.99, 0.9, 0.5)
    โ”€โ”€ Failure (test-t-dataframes.R:191:5):  dataframes for parametric t-tests โ”€โ”€โ”€โ”€โ”€
    `df_2_within` (`actual`) not equal to structure(...) (`expected`).
    
         names(actual) | names(expected)     
     [5] "p.value"     | "p.value"       [5] 
     [6] "method"      | "method"        [6] 
     [7] "estimate"    | "estimate"      [7] 
     [8] "conf.level"  - "ci.width"      [8] 
     [9] "conf.low"    | "conf.low"      [9] 
    [10] "conf.high"   | "conf.high"     [10]
    [11] "effectsize"  | "effectsize"    [11]
    
    `actual$conf.level` is a double vector (0.89, 0.99, 0.9, 0.5)
    `expected$conf.level` is absent
    
    `actual$ci.width` is absent
    `expected$ci.width` is a double vector (0.89, 0.99, 0.9, 0.5)
    
    [ FAIL 3 | WARN 0 | SKIP 19 | PASS 69 ]
    Error: Test failures
    Execution halted

I think you have already adressed this? But just wanted to be sure so your update is ready once insight is on CRAN. :-)

Use a weights vector/column for raw data

I've tried using the ggstatsplot package with raw survey response data, and I find it really straightforward to do. However, it would be great if I could specify the weight column in the same formula, or some other way.

The following functions have a weight argument:

count(x, wt = weight, ...) # weighted count
xtabs(data[, "weight"] ~ data[, x] + data[, y]) # weighted crosstab
weighted.mean(x, w = weight) # weighted mean
radiant.data::weighted.sd(x, wt = weight) # weighted standard deviation...

It would be great to be able to pass the weight argument from the same dataset, or from an external vector, into the ggstatsplot functions like so:

ggstatsplot::ggwithinstats(dataset, x = var1, y = var2, wt = weight)

ggbarstats - paired - subtitle/caption not shown

Seems like stats are not shown when paired option is enabled (using ggstatsplot "v0.1.2")
Cheers

dfEx<-data.frame(cat1= rep(c("A","B"),10), cat2=c(rep("C",10),rep("D",10)))
ggstatsplot::ggbarstats(
data=dfEx,
x=cat1,
y=cat2,
paired=T,
nboot=10
)
#> Registered S3 methods overwritten by 'broom.mixed':
#>   method         from 
#>   augment.lme    broom
#>   augment.merMod broom
#>   glance.lme     broom
#>   glance.merMod  broom
#>   glance.stanreg broom
#>   tidy.brmsfit   broom
#>   tidy.gamlss    broom
#>   tidy.lme       broom
#>   tidy.merMod    broom
#>   tidy.rjags     broom
#>   tidy.stanfit   broom
#>   tidy.stanreg   broom
#> Registered S3 methods overwritten by 'car':
#>   method                          from
#>   influence.merMod                lme4
#>   cooks.distance.influence.merMod lme4
#>   dfbeta.influence.merMod         lme4
#>   dfbetas.influence.merMod        lme4
#> # A tibble: 2 x 11
#>   cat2  counts  perc N     A     B     statistic p.value parameter method
#>   <fct>  <int> <dbl> <chr> <chr> <chr>     <dbl>   <dbl>     <dbl> <chr> 
#> 1 D         10    50 (n =~ 50.0~ 50.0~         0       1         1 Chi-s~
#> 2 C         10    50 (n =~ 50.0~ 50.0~         0       1         1 Chi-s~
#> # ... with 1 more variable: significance <chr>

Created on 2019-10-08 by the reprex package (v0.3.0)

use `afex` instead of `ez` for `expr_anova_parametric`

within

library(afex)
library(statsExpressions)

set.seed(123)
fit_all <- aov_ez("id", "value", iris_long, within = "condition")

as.data.frame(parameters::model_parameters(fit_all, omega_squared = "partial"))
#>   Parameter Sum_Squares Sum_Squares_Error      df df_error Mean_Square        F
#> 1 condition    1656.263          317.8893 1.14911 171.2174    1.856641 776.3182
#>              p Omega2_partial
#> 1 1.324548e-69      0.7068709

set.seed(123)
expr_anova_parametric(iris_long, condition, value, id, paired = TRUE, output = "dataframe")
#> # A tibble: 1 x 10
#>   statistic parameter1 parameter2  p.value group term  estimate ci.width
#>       <dbl>      <dbl>      <dbl>    <dbl> <chr> <chr>    <dbl>    <dbl>
#> 1      776.       1.15       171. 1.32e-69 rowi~ cond~    0.707     0.95
#> # ... with 2 more variables: conf.low <dbl>, conf.high <dbl>

Created on 2020-12-21 by the reprex package (v0.3.0.9001)

use `parameters` to tidy up meta-analysis results

library(metafor)
#> Loading required package: Matrix
#> Loading 'metafor' package (version 2.1-0). For an overview 
#> and introduction to the package please type: help(metafor).
library(ggstatsplot)
#> Registered S3 method overwritten by 'broom.mixed':
#>   method      from 
#>   tidy.gamlss broom
#> Registered S3 methods overwritten by 'car':
#>   method                          from
#>   influence.merMod                lme4
#>   cooks.distance.influence.merMod lme4
#>   dfbeta.influence.merMod         lme4
#>   dfbetas.influence.merMod        lme4

### calculate log risk ratios and corresponding sampling variances
dat <- escalc(measure="RR", ai=tpos, bi=tneg, ci=cpos, di=cneg, data=dat.bcg)

### random-effects model, using log risk ratios and variances as input
### note: method="REML" is the default, so one could leave this out
x <- rma(yi, vi, data=dat, method="REML")

# setup
ggstatsplot:::parameters_tidy(x) %>%
  dplyr::filter(., !grepl(x = term, pattern = "Study", ignore.case = TRUE))

#> # A tibble: 1 x 8
#>   term        estimate std.error conf.low conf.high statistic   p.value weight
#>   <chr>          <dbl>     <dbl>    <dbl>     <dbl>     <dbl>     <dbl>  <dbl>
#> 1 (Intercept)   -0.715     0.180    -1.07    -0.362     -3.97 0.0000705     NA

long-term restructuring

  • add sample size info to bf-related expressions
  • check if a 0-parameter template can be repurposed for bf-expressions
  • only support symbols, and not strings as argument inputs
  • check if things work as expected with for loops
  • instead of showing centrality in Bayesian template, show what the estimate actually is
  • use {glue} for creating expressions
  • Use rlang::parse_expr() to parse expressions

Issue with "kruskal.test.default"

Hi, we've been trying to run these two simple use cases described below using "ggbetweenstats", but we are only able to run the first one. The second gives an error related to kruskal.test. However, we've been able to run kruskal test on the entire group or pairwise. We don't quite understand what's going on. It might seem obvious to someone else but we are a bit ofuscated with this. We've noticed that setting 'results.subtitle=FALSE' allows to make the plot, but stats are not reported, as expected. Any clue on this issue will be appreciated, we would expect to get stats and plot without issue.

Many thanks for your time

library(ggstatsplot)

r1<-data.frame(treatment=c("a", "b", "b", "b", "c", "d", "d"),
Age=1:7,
Group=c("G1", "G1", "G1", "G1", "G1", "G1", "G1"),
stringsAsFactors=F)

r2<-data.frame(treatment=c("a", "a", "a", "a", "a", "e", "f"),
Age=1:7,
Group=c("G2", "G2", "G2", "G2", "G2", "G2", "G2"),
stringsAsFactors=F)

str(r1)
#> 'data.frame':    7 obs. of  3 variables:
#>  $ treatment: chr  "a" "b" "b" "b" ...
#>  $ Age      : int  1 2 3 4 5 6 7
#>  $ Group    : chr  "G1" "G1" "G1" "G1" ...
str(r2)
#> 'data.frame':    7 obs. of  3 variables:
#>  $ treatment: chr  "a" "a" "a" "a" ...
#>  $ Age      : int  1 2 3 4 5 6 7
#>  $ Group    : chr  "G2" "G2" "G2" "G2" ...

r1
#>   treatment Age Group
#> 1         a   1    G1
#> 2         b   2    G1
#> 3         b   3    G1
#> 4         b   4    G1
#> 5         c   5    G1
#> 6         d   6    G1
#> 7         d   7    G1
r2
#>   treatment Age Group
#> 1         a   1    G2
#> 2         a   2    G2
#> 3         a   3    G2
#> 4         a   4    G2
#> 5         a   5    G2
#> 6         e   6    G2
#> 7         f   7    G2

table(r1)
#> , , Group = G1
#> 
#>          Age
#> treatment 1 2 3 4 5 6 7
#>         a 1 0 0 0 0 0 0
#>         b 0 1 1 1 0 0 0
#>         c 0 0 0 0 1 0 0
#>         d 0 0 0 0 0 1 1
table(r2)
#> , , Group = G2
#> 
#>          Age
#> treatment 1 2 3 4 5 6 7
#>         a 1 1 1 1 1 0 0
#>         e 0 0 0 0 0 1 0
#>         f 0 0 0 0 0 0 1

ggstatsplot::ggbetweenstats(
  data = r1,
  x = "treatment",
  y = "Age",
  type="np",
  messages=F
)
#> Warning in ~as.numeric(as.character(.)): NAs introduced by coercion
#> Warning in stats::qt(p = 1 - (0.05/2), df = n - 1, lower.tail = TRUE): NaNs
#> produced

#> Warning in stats::qt(p = 1 - (0.05/2), df = n - 1, lower.tail = TRUE): NaNs
#> produced

ggstatsplot::ggbetweenstats(
  data = r2,
  x = "treatment",
  y = "Age",
  type="np",
  messages=F
)
#> Error in kruskal.test.default(Input$x, Input$g): all observations are in the same group

Created on 2019-09-10 by the reprex package (v0.3.0)

adding CI related info for effect sizes

mod <- effectsize::cohens_d(sleep$extra, sleep$group)

A <- c(48, 48, 77, 86, 85, 85)
B <- c(14, 34, 34, 77)
mod2 <- effectsize::rank_biserial(A, B)

get_ci_method <- purrr::compose(tibble::as_tibble, purrr::attr_getter("ci_method"))

dplyr::rename_with(get_ci_method(mod), ~ paste0("ci_", .x))
#> # A tibble: 1 x 2
#>   ci_method ci_distribution
#>   <chr>     <chr>          
#> 1 ncp       t

dplyr::rename_with(get_ci_method(mod2), ~ paste0("ci_", .x))
#> # A tibble: 1 x 2
#>   ci_method ci_iterations
#>   <chr>             <dbl>
#> 1 bootstrap           200

Created on 2021-02-16 by the reprex package (v1.0.0)

return expressions as a list column in a dataframe

proof of concept

library(ggplot2)
library(statsExpressions)

df <- tibble(x = rnorm(100))

df_res <- expr_t_onesample(df, x, output = "dataframe")

attr(df_res, "subtitle") <- expr_t_onesample(df, x, type = "p")
attr(df_res, "caption") <- expr_t_onesample(df, x, type = "bf")

ggplot(df, aes(x)) +
  geom_histogram(alpha = 0.5) +
  labs(
    subtitle = attributes(df_res)$subtitle,
    caption = attributes(df_res)$caption
  )
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

Created on 2021-01-19 by the reprex package (v0.3.0)

Session info
devtools::session_info()
#> โ”€ Session info โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
#>  setting  value                       
#>  version  R version 4.0.3 (2020-10-10)
#>  os       macOS Mojave 10.14.6        
#>  system   x86_64, darwin17.0          
#>  ui       X11                         
#>  language (EN)                        
#>  collate  en_US.UTF-8                 
#>  ctype    en_US.UTF-8                 
#>  tz       Europe/Berlin               
#>  date     2021-01-19                  
#> 
#> โ”€ Packages โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
#>  package          * version    date       lib
#>  abind              1.4-5      2016-07-21 [1]
#>  afex               0.28-1     2021-01-12 [1]
#>  assertthat         0.2.1      2019-03-21 [1]
#>  BayesFactor        0.9.12-4.2 2018-05-19 [1]
#>  bayestestR         0.8.0.1    2021-01-07 [1]
#>  bbmle              1.0.23.1   2020-02-03 [1]
#>  bdsmatrix          1.3-4      2020-01-13 [1]
#>  boot               1.3-25     2020-04-26 [2]
#>  bridgesampling     1.0-0      2020-02-26 [1]
#>  Brobdingnag        1.2-6      2018-08-13 [1]
#>  callr              3.5.1      2020-10-13 [1]
#>  car                3.0-10     2020-09-29 [1]
#>  carData            3.0-4      2020-05-22 [1]
#>  cellranger         1.1.0      2016-07-27 [1]
#>  cli                2.2.0      2020-11-20 [1]
#>  coda               0.19-4     2020-09-30 [1]
#>  codetools          0.2-16     2018-12-24 [2]
#>  colorspace         2.0-0      2020-11-11 [1]
#>  correlation        0.5.0      2021-01-01 [1]
#>  crayon             1.3.4      2017-09-16 [1]
#>  curl               4.3        2019-12-02 [1]
#>  data.table         1.13.6     2020-12-30 [1]
#>  DBI                1.1.1      2021-01-15 [1]
#>  desc               1.2.0      2018-05-01 [1]
#>  devtools           2.3.2      2020-09-18 [1]
#>  digest             0.6.27     2020-10-24 [1]
#>  dplyr              1.0.3      2021-01-15 [1]
#>  effectsize         0.4.3      2021-01-18 [1]
#>  ellipsis           0.3.1      2020-05-15 [1]
#>  emmeans            1.5.3      2020-12-09 [1]
#>  estimability       1.3        2018-02-11 [1]
#>  evaluate           0.14       2019-05-28 [1]
#>  fansi              0.4.2      2021-01-15 [1]
#>  farver             2.0.3      2020-01-16 [1]
#>  fastGHQuad         1.0        2018-09-30 [1]
#>  forcats            0.5.0      2020-03-01 [1]
#>  foreign            0.8-80     2020-05-24 [2]
#>  fs                 1.5.0      2020-07-31 [1]
#>  generics           0.1.0      2020-10-31 [1]
#>  ggplot2          * 3.3.3      2020-12-30 [1]
#>  glue               1.4.2      2020-08-27 [1]
#>  gridExtra          2.3        2017-09-09 [1]
#>  gtable             0.3.0      2019-03-25 [1]
#>  gtools             3.8.2      2020-03-31 [1]
#>  haven              2.3.1      2020-06-01 [1]
#>  highr              0.8        2019-03-20 [1]
#>  hms                1.0.0      2021-01-13 [1]
#>  htmltools          0.5.1      2021-01-12 [1]
#>  httr               1.4.2      2020-07-20 [1]
#>  inline             0.3.17     2020-12-01 [1]
#>  insight            0.12.0     2021-01-14 [1]
#>  ipmisc             5.0.2      2021-01-09 [1]
#>  jsonlite           1.7.2      2020-12-09 [1]
#>  knitr              1.30       2020-09-22 [1]
#>  labeling           0.4.2      2020-10-20 [1]
#>  LaplacesDemon      16.1.4     2020-02-06 [1]
#>  lattice            0.20-41    2020-04-02 [2]
#>  lifecycle          0.2.0      2020-03-06 [1]
#>  lme4               1.1-26     2020-12-01 [1]
#>  lmerTest           3.1-3      2020-10-23 [1]
#>  logspline          2.1.16     2020-05-08 [1]
#>  loo                2.4.1      2020-12-09 [1]
#>  magrittr           2.0.1      2020-11-17 [1]
#>  MASS               7.3-53     2020-09-09 [2]
#>  Matrix             1.2-18     2019-11-27 [2]
#>  MatrixModels       0.4-1      2015-08-22 [1]
#>  matrixStats        0.57.0     2020-09-25 [1]
#>  mc2d               0.1-18     2017-03-06 [1]
#>  memoise            1.1.0      2017-04-21 [1]
#>  metaBMA            0.6.6      2021-01-08 [1]
#>  metafor            2.4-0      2020-03-19 [1]
#>  metaplus           0.7-11     2018-04-01 [1]
#>  mime               0.9        2020-02-04 [1]
#>  minqa              1.2.4      2014-10-09 [1]
#>  multcomp           1.4-15     2020-11-14 [1]
#>  munsell            0.5.0      2018-06-12 [1]
#>  mvtnorm            1.1-1      2020-06-09 [1]
#>  nlme               3.1-149    2020-08-23 [2]
#>  nloptr             1.2.2.2    2020-07-02 [1]
#>  numDeriv           2016.8-1.1 2019-06-06 [1]
#>  openxlsx           4.2.3      2020-10-27 [1]
#>  parameters         0.11.0     2021-01-15 [1]
#>  pbapply            1.4-3      2020-08-18 [1]
#>  performance        0.6.1.1    2021-01-01 [1]
#>  pillar             1.4.7      2020-11-20 [1]
#>  pkgbuild           1.2.0      2020-12-15 [1]
#>  pkgconfig          2.0.3      2019-09-22 [1]
#>  pkgload            1.1.0      2020-05-29 [1]
#>  plyr               1.8.6      2020-03-03 [1]
#>  prettyunits        1.1.1      2020-01-24 [1]
#>  processx           3.4.5      2020-11-30 [1]
#>  ps                 1.5.0      2020-12-05 [1]
#>  purrr              0.3.4      2020-04-17 [1]
#>  R6                 2.5.0      2020-10-28 [1]
#>  Rcpp               1.0.6      2021-01-15 [1]
#>  RcppParallel       5.0.2      2020-06-24 [1]
#>  readxl             1.3.1      2019-03-13 [1]
#>  remotes            2.2.0      2020-07-21 [1]
#>  reshape            0.8.8      2018-10-23 [1]
#>  reshape2           1.4.4      2020-04-09 [1]
#>  rio                0.5.16     2018-11-26 [1]
#>  rlang              0.4.10     2020-12-30 [1]
#>  rmarkdown          2.6        2020-12-14 [1]
#>  rprojroot          2.0.2      2020-11-15 [1]
#>  rstan              2.21.2     2020-07-27 [1]
#>  rstantools         2.1.1      2020-07-06 [1]
#>  sandwich           3.0-0      2020-10-02 [1]
#>  scales             1.1.1      2020-05-11 [1]
#>  sessioninfo        1.1.1      2018-11-05 [1]
#>  StanHeaders        2.21.0-7   2020-12-17 [1]
#>  statmod            1.4.35     2020-10-19 [1]
#>  statsExpressions * 0.7.0      2021-01-19 [1]
#>  stringi            1.5.3      2020-09-09 [1]
#>  stringr            1.4.0      2019-02-10 [1]
#>  survival           3.2-7      2020-09-28 [2]
#>  testthat           3.0.1      2020-12-17 [1]
#>  TH.data            1.0-10     2019-01-21 [1]
#>  tibble             3.0.5      2021-01-15 [1]
#>  tidyr              1.1.2      2020-08-27 [1]
#>  tidyselect         1.1.0      2020-05-11 [1]
#>  usethis            2.0.0      2020-12-10 [1]
#>  V8                 3.4.0      2020-11-04 [1]
#>  vctrs              0.3.6      2020-12-17 [1]
#>  withr              2.4.0      2021-01-16 [1]
#>  WRS2               1.1-0      2020-06-19 [1]
#>  xfun               0.20       2021-01-06 [1]
#>  xml2               1.3.2      2020-04-23 [1]
#>  xtable             1.8-4      2019-04-21 [1]
#>  yaml               2.2.1      2020-02-01 [1]
#>  zeallot            0.1.0      2018-01-28 [1]
#>  zip                2.1.1      2020-08-27 [1]
#>  zoo                1.8-8      2020-05-02 [1]
#>  source                                
#>  CRAN (R 4.0.2)                        
#>  CRAN (R 4.0.3)                        
#>  CRAN (R 4.0.2)                        
#>  CRAN (R 4.0.2)                        
#>  Github (easystats/bayestestR@f19a7e5) 
#>  CRAN (R 4.0.2)                        
#>  CRAN (R 4.0.2)                        
#>  CRAN (R 4.0.3)                        
#>  CRAN (R 4.0.2)                        
#>  CRAN (R 4.0.2)                        
#>  CRAN (R 4.0.2)                        
#>  CRAN (R 4.0.2)                        
#>  CRAN (R 4.0.2)                        
#>  CRAN (R 4.0.2)                        
#>  CRAN (R 4.0.3)                        
#>  CRAN (R 4.0.2)                        
#>  CRAN (R 4.0.3)                        
#>  CRAN (R 4.0.2)                        
#>  Github (easystats/correlation@6f68768)
#>  CRAN (R 4.0.2)                        
#>  CRAN (R 4.0.1)                        
#>  CRAN (R 4.0.2)                        
#>  CRAN (R 4.0.3)                        
#>  CRAN (R 4.0.2)                        
#>  CRAN (R 4.0.2)                        
#>  CRAN (R 4.0.2)                        
#>  CRAN (R 4.0.3)                        
#>  CRAN (R 4.0.3)                        
#>  CRAN (R 4.0.2)                        
#>  CRAN (R 4.0.3)                        
#>  CRAN (R 4.0.2)                        
#>  CRAN (R 4.0.1)                        
#>  CRAN (R 4.0.3)                        
#>  CRAN (R 4.0.2)                        
#>  CRAN (R 4.0.2)                        
#>  CRAN (R 4.0.2)                        
#>  CRAN (R 4.0.3)                        
#>  CRAN (R 4.0.2)                        
#>  CRAN (R 4.0.2)                        
#>  CRAN (R 4.0.3)                        
#>  CRAN (R 4.0.2)                        
#>  CRAN (R 4.0.2)                        
#>  CRAN (R 4.0.2)                        
#>  CRAN (R 4.0.2)                        
#>  CRAN (R 4.0.2)                        
#>  CRAN (R 4.0.2)                        
#>  CRAN (R 4.0.3)                        
#>  CRAN (R 4.0.3)                        
#>  CRAN (R 4.0.2)                        
#>  CRAN (R 4.0.3)                        
#>  CRAN (R 4.0.3)                        
#>  CRAN (R 4.0.3)                        
#>  CRAN (R 4.0.3)                        
#>  CRAN (R 4.0.2)                        
#>  CRAN (R 4.0.2)                        
#>  CRAN (R 4.0.2)                        
#>  CRAN (R 4.0.3)                        
#>  CRAN (R 4.0.2)                        
#>  CRAN (R 4.0.3)                        
#>  CRAN (R 4.0.2)                        
#>  CRAN (R 4.0.2)                        
#>  CRAN (R 4.0.3)                        
#>  CRAN (R 4.0.3)                        
#>  CRAN (R 4.0.3)                        
#>  CRAN (R 4.0.3)                        
#>  CRAN (R 4.0.2)                        
#>  CRAN (R 4.0.2)                        
#>  CRAN (R 4.0.2)                        
#>  CRAN (R 4.0.2)                        
#>  CRAN (R 4.0.3)                        
#>  CRAN (R 4.0.2)                        
#>  CRAN (R 4.0.2)                        
#>  CRAN (R 4.0.2)                        
#>  CRAN (R 4.0.2)                        
#>  CRAN (R 4.0.3)                        
#>  CRAN (R 4.0.2)                        
#>  CRAN (R 4.0.2)                        
#>  CRAN (R 4.0.3)                        
#>  CRAN (R 4.0.2)                        
#>  CRAN (R 4.0.2)                        
#>  CRAN (R 4.0.2)                        
#>  CRAN (R 4.0.3)                        
#>  CRAN (R 4.0.2)                        
#>  Github (easystats/performance@429b7ff)
#>  CRAN (R 4.0.3)                        
#>  CRAN (R 4.0.3)                        
#>  CRAN (R 4.0.2)                        
#>  CRAN (R 4.0.2)                        
#>  CRAN (R 4.0.2)                        
#>  CRAN (R 4.0.2)                        
#>  CRAN (R 4.0.3)                        
#>  CRAN (R 4.0.3)                        
#>  CRAN (R 4.0.2)                        
#>  CRAN (R 4.0.2)                        
#>  CRAN (R 4.0.3)                        
#>  CRAN (R 4.0.2)                        
#>  CRAN (R 4.0.2)                        
#>  CRAN (R 4.0.2)                        
#>  CRAN (R 4.0.2)                        
#>  CRAN (R 4.0.2)                        
#>  CRAN (R 4.0.2)                        
#>  CRAN (R 4.0.3)                        
#>  CRAN (R 4.0.3)                        
#>  CRAN (R 4.0.3)                        
#>  CRAN (R 4.0.3)                        
#>  CRAN (R 4.0.2)                        
#>  CRAN (R 4.0.2)                        
#>  CRAN (R 4.0.2)                        
#>  CRAN (R 4.0.2)                        
#>  CRAN (R 4.0.3)                        
#>  CRAN (R 4.0.2)                        
#>  CRAN (R 4.0.3)                        
#>  CRAN (R 4.0.2)                        
#>  CRAN (R 4.0.2)                        
#>  CRAN (R 4.0.3)                        
#>  CRAN (R 4.0.3)                        
#>  CRAN (R 4.0.2)                        
#>  CRAN (R 4.0.3)                        
#>  CRAN (R 4.0.2)                        
#>  CRAN (R 4.0.2)                        
#>  CRAN (R 4.0.3)                        
#>  CRAN (R 4.0.2)                        
#>  CRAN (R 4.0.3)                        
#>  CRAN (R 4.0.3)                        
#>  CRAN (R 4.0.2)                        
#>  CRAN (R 4.0.3)                        
#>  CRAN (R 4.0.2)                        
#>  CRAN (R 4.0.2)                        
#>  CRAN (R 4.0.2)                        
#>  CRAN (R 4.0.2)                        
#>  CRAN (R 4.0.2)                        
#>  CRAN (R 4.0.2)                        
#> 
#> [1] /Users/patil/Library/R/4.0/library
#> [2] /Library/Frameworks/R.framework/Versions/4.0/Resources/library

supporting for loop for all functions

  • expr_anova_bayes
  • expr_anova_nonparametric
  • expr_anova_parametric
  • expr_anova_robust
  • expr_contingency_tab
  • expr_corr_test
  • expr_meta_random
  • expr_t_bayes
  • expr_t_nonparametric
  • expr_t_onesample
  • expr_t_parametric
  • expr_t_robust

use `insight` helpers

  • use insight::check_if_installed
  • use insight::format_value instead of ipmisc::format_num when not p-values
ipmisc::format_num(1.2344, k = 3)
#> [1] "1.234"

insight::format_value(1.2344, digits = 3)
#> [1] "1.234"

Created on 2021-03-31 by the reprex package (v1.0.0)

`expr_anova_parametric`: changing `conf.level` doesn't work

set.seed(123)
library(statsExpressions)

expr_anova_parametric(mtcars, cyl, wt, conf.level = 0.90)
#> paste(NULL, italic("F")["Welch"], "(", "2", ",", "18.97", ") = ", 
#>     "20.25", ", ", italic("p"), " = ", "< 0.001", ", ", widehat(omega["p"]^2), 
#>     " = ", "0.58", ", CI"["90%"], " [", "0.36", ", ", "0.71", 
#>     "]", ", ", italic("n")["obs"], " = ", 32L)

expr_anova_parametric(mtcars, cyl, wt, conf.level = 0.95)
#> paste(NULL, italic("F")["Welch"], "(", "2", ",", "18.97", ") = ", 
#>     "20.25", ", ", italic("p"), " = ", "< 0.001", ", ", widehat(omega["p"]^2), 
#>     " = ", "0.58", ", CI"["95%"], " [", "0.36", ", ", "0.71", 
#>     "]", ", ", italic("n")["obs"], " = ", 32L)

Created on 2020-04-22 by the reprex package (v0.3.0.9001)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.