Nothing
#| label = "setup", #| message = FALSE, #| warning = FALSE, #| include = FALSE, #| echo = FALSE source("../setup.R") pkgs <- c( "ggplot2", "metaplus" ) successfully_loaded <- purrr::map_lgl(pkgs, requireNamespace, quietly = TRUE) can_evaluate <- all(successfully_loaded) if (can_evaluate) { purrr::walk(pkgs, library, character.only = TRUE) } else { knitr::opts_chunk$set(eval = FALSE) }
This vignette can be cited as:
#| label = "citation", #| echo = FALSE, #| comment = "" citation("statsExpressions")
#| label = "onesample", #| file = "../../man/examples/examples-one_sample_test.R" # ----------------------- parametric --------------------------------------- set.seed(123) one_sample_test( data = ggplot2::msleep, x = brainwt, test.value = 0.275, type = "parametric" ) # ----------------------- non-parametric ----------------------------------- set.seed(123) one_sample_test( data = ggplot2::msleep, x = brainwt, test.value = 0.275, type = "nonparametric" ) # ----------------------- robust -------------------------------------------- set.seed(123) one_sample_test( data = ggplot2::msleep, x = brainwt, test.value = 0.275, type = "robust" ) # ----------------------- Bayesian --------------------------------------- set.seed(123) one_sample_test( data = ggplot2::msleep, x = brainwt, test.value = 0.275, type = "bayes", bf.prior = 0.8 )
#| label = "twosample_w" # data df <- dplyr::filter(bugs_long, condition %in% c("LDLF", "LDHF")) # ----------------------- parametric --------------------------------------- set.seed(123) two_sample_test( data = df, x = condition, y = desire, paired = TRUE, subject.id = subject, type = "p" ) # ----------------------- non-parametric ----------------------------------- set.seed(123) two_sample_test( data = df, x = condition, y = desire, paired = TRUE, subject.id = subject, type = "np" ) # ----------------------- robust -------------------------------------------- set.seed(123) two_sample_test( data = df, x = condition, y = desire, paired = TRUE, subject.id = subject, type = "r" ) # ----------------------- Bayesian --------------------------------------- set.seed(123) two_sample_test( data = df, x = condition, y = desire, paired = TRUE, subject.id = subject, type = "bayes" )
#| label = "twosample_b" # ----------------------- parametric --------------------------------------- # unequal variance set.seed(123) two_sample_test( data = ToothGrowth, x = supp, y = len, type = "p" ) # equal variance set.seed(123) two_sample_test( data = ToothGrowth, x = supp, y = len, var.equal = TRUE, type = "p" ) # ----------------------- non-parametric ----------------------------------- set.seed(123) two_sample_test( data = ToothGrowth, x = supp, y = len, type = "np" ) # ----------------------- robust -------------------------------------------- set.seed(123) two_sample_test( data = ToothGrowth, x = supp, y = len, type = "r" ) # ----------------------- Bayesian --------------------------------------- set.seed(123) two_sample_test( data = ToothGrowth, x = supp, y = len, type = "bayes" )
#| label = "anova_w" suppressPackageStartupMessages(library(afex)) # ----------------------- parametric --------------------------------------- set.seed(123) oneway_anova( data = bugs_long, x = condition, y = desire, paired = TRUE, subject.id = subject, type = "p" ) # ----------------------- non-parametric ----------------------------------- set.seed(123) oneway_anova( data = bugs_long, x = condition, y = desire, paired = TRUE, subject.id = subject, type = "np" ) # ----------------------- robust -------------------------------------------- set.seed(123) oneway_anova( data = bugs_long, x = condition, y = desire, paired = TRUE, subject.id = subject, type = "r" ) # ----------------------- Bayesian --------------------------------------- set.seed(123) oneway_anova( data = bugs_long, x = condition, y = desire, paired = TRUE, subject.id = subject, type = "bayes" )
#| label = "anova_b" # ----------------------- parametric --------------------------------------- # unequal variance set.seed(123) oneway_anova( data = iris, x = Species, y = Sepal.Length, type = "p" ) # equal variance set.seed(123) oneway_anova( data = iris, x = Species, y = Sepal.Length, var.equal = TRUE, type = "p" ) # ----------------------- non-parametric ----------------------------------- set.seed(123) oneway_anova( data = iris, x = Species, y = Sepal.Length, type = "np" ) # ----------------------- robust -------------------------------------------- set.seed(123) oneway_anova( data = iris, x = Species, y = Sepal.Length, type = "r" ) # ----------------------- Bayesian --------------------------------------- set.seed(123) oneway_anova( data = iris, x = Species, y = Sepal.Length, type = "bayes" )
#| label = "conttabs" # ------------------------ frequentist ----------------------------- # unpaired set.seed(123) contingency_table( data = mtcars, x = am, y = vs, paired = FALSE ) # paired ## example data paired_data <- tibble( response_before = structure(c(1L, 2L, 1L, 2L), levels = c("no", "yes"), class = "factor"), response_after = structure(c(1L, 1L, 2L, 2L), levels = c("no", "yes"), class = "factor"), Freq = c(65L, 25L, 5L, 5L) ) set.seed(123) contingency_table( data = paired_data, x = response_before, y = response_after, paired = TRUE, counts = "Freq" ) # ------------------------ Bayesian ----------------------------- # unpaired set.seed(123) contingency_table( data = mtcars, x = am, y = vs, paired = FALSE, type = "bayes" )
#| label = "gof" # ------------------------ frequentist ----------------------------- # with counts set.seed(123) contingency_table( data = as.data.frame(HairEyeColor), x = Eye, counts = Freq ) # ------------------------ Bayesian ----------------------------- set.seed(123) contingency_table( data = as.data.frame(HairEyeColor), x = Eye, counts = Freq, ratio = c(0.2, 0.2, 0.3, 0.3), type = "bayes" )
#| label = "corr", #| file = "../../man/examples/examples-corr_test.R"
#| label = "meta" library(metaplus) # renaming columns to `{statsExpressions}` conventions df <- dplyr::rename(mag, estimate = yi, std.error = sei) # ----------------------- parametric --------------------------------------- set.seed(123) meta_analysis(df, type = "parametric") # ----------------------- robust -------------------------------------------- set.seed(123) meta_analysis(df, type = "robust") # ----------------------- Bayesian --------------------------------------- # suppress warnings about divergent transitions after warmup set.seed(123) suppressWarnings(meta_analysis(df, type = "bayes"))
#| label = "centrality", #| file = "../../man/examples/examples-centrality_description.R"
# ----------------------- parametric ----------------------- # if `var.equal = TRUE`, then Student's *t*-test will be run pairwise_comparisons( data = ggplot2::msleep, x = vore, y = brainwt, type = "parametric", var.equal = TRUE, paired = FALSE, p.adjust.method = "bonferroni" ) # if `var.equal = FALSE`, then Games-Howell test will be run pairwise_comparisons( data = ggplot2::msleep, x = vore, y = brainwt, type = "parametric", var.equal = FALSE, paired = FALSE, p.adjust.method = "bonferroni" ) # ----------------------- non-parametric ------------------- pairwise_comparisons( data = ggplot2::msleep, x = vore, y = brainwt, type = "nonparametric", paired = FALSE, p.adjust.method = "none" ) # ----------------------- robust --------------------------- pairwise_comparisons( data = ggplot2::msleep, x = vore, y = brainwt, type = "robust", paired = FALSE, p.adjust.method = "fdr" ) # ----------------------- Bayesian ------------------------- pairwise_comparisons( data = ggplot2::msleep, x = vore, y = brainwt, type = "bayes", paired = FALSE )
# ----------------------- parametric ----------------------- pairwise_comparisons( data = bugs_long, x = condition, y = desire, subject.id = subject, type = "parametric", paired = TRUE, p.adjust.method = "BH" ) # ----------------------- non-parametric ------------------- pairwise_comparisons( data = bugs_long, x = condition, y = desire, subject.id = subject, type = "nonparametric", paired = TRUE, p.adjust.method = "BY" ) # ----------------------- robust --------------------------- pairwise_comparisons( data = bugs_long, x = condition, y = desire, subject.id = subject, type = "robust", paired = TRUE, p.adjust.method = "hommel" ) # ----------------------- Bayesian ------------------------- pairwise_comparisons( data = bugs_long, x = condition, y = desire, subject.id = subject, type = "bayes", paired = TRUE, bf.prior = 0.77 )
If you find any bugs or have any suggestions/remarks, please file an issue on GitHub: https://github.com/IndrajeetPatil/statsExpressions/issues
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.