From 7d00a5e646ba808c1a439760bea91a20f0c37939 Mon Sep 17 00:00:00 2001 From: Aravind Hebbali Date: Wed, 31 Jan 2018 17:48:10 +0530 Subject: [PATCH] Revert "API changes (#13)" This reverts commit 9f3153d817dbed85fa3b4745b63332d6d06de8ba. --- DESCRIPTION | 3 +- NAMESPACE | 9 -- R/RcppExports.R | 4 +- R/infer-anova.R | 44 ++++---- R/infer-binom-test.R | 25 ++--- R/infer-chisq-assoc-test.R | 39 +++----- R/infer-chisq-gof-test.R | 52 +++------- R/infer-cochran-q-test.R | 23 ++--- R/infer-levene-test.R | 18 +++- R/infer-os-prop-test.R | 6 +- R/infer-os-t-test.R | 74 ++++++++------ R/infer-os-var-test.R | 36 +++---- R/infer-output.R | 4 +- R/infer-runs-test.R | 4 +- R/infer-utils.R | 111 ++++++--------------- README.Rmd | 8 +- README.md | 108 +++++++++----------- data/hsb.rda | Bin 1715 -> 1674 bytes docs/articles/intro.html | 40 ++++---- docs/hex_inferr.png | Bin 7621 -> 0 bytes docs/reference/infer_binom_calc.html | 14 +-- docs/reference/infer_chisq_assoc_test.html | 59 ++++------- docs/reference/infer_chisq_gof_test.html | 61 ++++------- docs/reference/infer_cochran_qtest.html | 40 +++----- docs/reference/infer_oneway_anova.html | 65 ++++-------- docs/reference/infer_os_prop_test.html | 81 +++++++-------- docs/reference/infer_os_t_test.html | 85 +++++----------- docs/reference/infer_os_var_test.html | 85 +++++----------- man/infer_binom_calc.Rd | 8 +- man/infer_chisq_assoc_test.Rd | 12 +-- man/infer_chisq_gof_test.Rd | 10 +- man/infer_cochran_qtest.Rd | 8 +- man/infer_oneway_anova.Rd | 10 +- man/infer_os_prop_test.Rd | 2 +- man/infer_os_t_test.Rd | 14 ++- man/infer_os_var_test.Rd | 16 ++- tests/testthat/test-anova.R | 11 +- tests/testthat/test-binom.R | 15 +-- tests/testthat/test-chisq.R | 12 +-- tests/testthat/test-chisqgof.R | 26 +++-- tests/testthat/test-cochran.R | 22 +++- tests/testthat/test-os-vartest.R | 16 +-- tests/testthat/test-runs.R | 8 ++ tests/testthat/test-ttest.R | 20 ++-- tests/testthat/test-utils.R | 6 +- vignettes/intro.Rmd | 22 ++-- 46 files changed, 541 insertions(+), 795 deletions(-) delete mode 100644 docs/hex_inferr.png diff --git a/DESCRIPTION b/DESCRIPTION index 1a5a825..cedb8f4 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -11,12 +11,11 @@ Depends: License: MIT + file LICENSE URL: https://rsquaredacademy.github.io/inferr/, https://github.com/rsquaredacademy/inferr BugReports: https://github.com/rsquaredacademy/inferr/issues -Imports: +Imports: dplyr, magrittr, purrr, Rcpp, - rlang, shiny, tibble, tidyr diff --git a/NAMESPACE b/NAMESPACE index beed2bd..e08dbb3 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -76,24 +76,15 @@ export(var_test) export(var_test_shiny) importFrom(Rcpp,sourceCpp) importFrom(dplyr,funs) -importFrom(dplyr,group_by) importFrom(dplyr,group_by_) importFrom(dplyr,mutate) -importFrom(dplyr,pull) importFrom(dplyr,select) importFrom(dplyr,select_) importFrom(dplyr,summarise_all) importFrom(magrittr,"%>%") -importFrom(magrittr,subtract) -importFrom(magrittr,use_series) importFrom(purrr,map) importFrom(purrr,map_dbl) -importFrom(purrr,map_df) importFrom(purrr,map_int) -importFrom(rlang,"!!!") -importFrom(rlang,"!!") -importFrom(rlang,enquo) -importFrom(rlang,quos) importFrom(shiny,runApp) importFrom(stats,anova) importFrom(stats,as.formula) diff --git a/R/RcppExports.R b/R/RcppExports.R index 49b3de1..97c2d3a 100644 --- a/R/RcppExports.R +++ b/R/RcppExports.R @@ -2,10 +2,10 @@ # Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393 nsignC <- function(x) { - .Call('_inferr_nsignC', PACKAGE = 'inferr', x) + .Call(`_inferr_nsignC`, x) } gvar <- function(ln, ly) { - .Call('_inferr_gvar', PACKAGE = 'inferr', ln, ly) + .Call(`_inferr_gvar`, ln, ly) } diff --git a/R/infer-anova.R b/R/infer-anova.R index 5f9e93f..9b3c865 100644 --- a/R/infer-anova.R +++ b/R/infer-anova.R @@ -1,10 +1,9 @@ #' @importFrom stats as.formula lm pf -#' @importFrom rlang enquo !! #' @title One Way ANOVA #' @description One way analysis of variance -#' @param data a \code{data.frame} or a \code{tibble} -#' @param x numeric; column in \code{data} -#' @param y factor; column in \code{data} +#' @param data a data frame +#' @param x character vector; name of a continuous variable from \code{data} +#' @param y character vector; name of a categorical variable from \code{data} #' @param ... additional arguments passed to or from other methods #' @return \code{owanova} returns an object of class \code{"owanova"}. #' An object of class \code{"owanova"} is a list containing the @@ -32,8 +31,8 @@ #' #' @seealso \code{\link[stats]{anova}} #' @examples -#' infer_oneway_anova(mtcars, mpg, cyl) -#' infer_oneway_anova(hsb, write, prog) +#' infer_oneway_anova(mtcars, 'mpg', 'cyl') +#' infer_oneway_anova(hsb, 'write', 'prog') #' @export #' infer_oneway_anova <- function(data, x, y, ...) UseMethod('infer_oneway_anova') @@ -41,25 +40,28 @@ infer_oneway_anova <- function(data, x, y, ...) UseMethod('infer_oneway_anova') #' @export infer_oneway_anova.default <- function(data, x, y, ...) { - x1 <- enquo(x) - y1 <- enquo(y) + if (!is.data.frame(data)) { + stop('data must be a data frame') + } - fdata <- - data %>% - select(!! x1, !! y1) + if (!x %in% colnames(data)) { + stop('x must be a column in data') + } - sample_mean <- anova_avg(fdata, !! x1) - sample_stats <- anova_split(fdata, !! x1, !! y1, sample_mean) - k <- anova_calc(fdata, sample_stats, !! x1, !! y1) + if (!y %in% colnames(data)) { + stop('y must be a column in data') + } + sample_mean <- anova_avg(data, x) + sample_stats <- anova_split(data, x, y, sample_mean) + k <- anova_calc(data, sample_stats, x, y) - result <- list(between = k$sstr, within = k$ssee, total = k$total, - df_btw = k$df_sstr, df_within = k$df_sse, - df_total = k$df_sst, ms_btw = k$mstr, ms_within = k$mse, - f = k$f, p = k$sig, r2 = round(k$reg$r.squared, 4), - ar2 = round(k$reg$adj.r.squared, 4), - sigma = round(k$reg$sigma, 4), obs = k$obs, - tab = sample_stats[, c(1, 2, 3, 5)]) + + result <- list( between = k$sstr, within = k$ssee, total = k$total, df_btw = k$df_sstr, + df_within = k$df_sse, df_total = k$df_sst, ms_btw = k$mstr, + ms_within = k$mse, f = k$f, p = k$sig, r2 = round(k$reg$r.squared, 4), + ar2 = round(k$reg$adj.r.squared, 4), sigma = round(k$reg$sigma, 4), + obs = k$obs, tab = round(sample_stats[, c(1, 2, 3, 5)], 3)) class(result) <- 'infer_oneway_anova' return(result) diff --git a/R/infer-binom-test.R b/R/infer-binom-test.R index fd0fb83..5fe03cc 100644 --- a/R/infer-binom-test.R +++ b/R/infer-binom-test.R @@ -5,8 +5,7 @@ #' @param n number of observations #' @param success number of successes #' @param prob assumed probability of success on a trial -#' @param data a \code{data.frame} or a \code{tibble} -#' @param variable factor; column in \code{data} +#' @param data binary/dichotomous factor #' @param ... additional arguments passed to or from other methods #' @return \code{binom_test} returns an object of class \code{"binom_test"}. #' An object of class \code{"binom_test"} is a list containing the @@ -31,7 +30,7 @@ #' infer_binom_calc(32, 13, prob = 0.5) #' #' # using data set -#' infer_binom_test(hsb, female, prob = 0.5) +#' infer_binom_test(as.factor(hsb$female), prob = 0.5) #' @export #' infer_binom_calc <- function(n, success, prob = 0.5, ...) UseMethod('infer_binom_calc') @@ -82,19 +81,13 @@ print.infer_binom_calc <- function(x, ...) { #' @export #' @rdname infer_binom_calc -infer_binom_test <- function(data, variable, prob = 0.5) { +infer_binom_test <- function(data, prob = 0.5) { - varyable <- enquo(variable) - - fdata <- - data %>% - pull(!! varyable) - - if (!is.factor(fdata)) { - stop('variable must be of type factor', call. = FALSE) + if (!is.factor(data)) { + stop('data must be of type factor', call. = FALSE) } - if (nlevels(fdata) > 2) { + if (nlevels(data) > 2) { stop('Binomial test is applicable only to binary data i.e. categorical data with 2 levels.', call. = FALSE) } @@ -106,8 +99,8 @@ infer_binom_test <- function(data, variable, prob = 0.5) { stop('prob must be between 0 and 1', call. = FALSE) } - n <- length(fdata) - k <- table(fdata)[[2]] + n <- length(data) + k <- table(data)[[2]] infer_binom_calc.default(n, k, prob) } @@ -118,6 +111,6 @@ infer_binom_test <- function(data, variable, prob = 0.5) { binom_test <- function(data, prob = 0.5) { .Deprecated("infer_binom_test()") - + infer_binom_test(data, prob = 0.5) } diff --git a/R/infer-chisq-assoc-test.R b/R/infer-chisq-assoc-test.R index 2b5a46e..48f0f8c 100644 --- a/R/infer-chisq-assoc-test.R +++ b/R/infer-chisq-assoc-test.R @@ -1,11 +1,9 @@ #' @importFrom stats pchisq -#' @importFrom dplyr pull #' @title Chi Square Test of Association #' @description Chi Square test of association to examine if there is a #' relationship between two categorical variables. -#' @param data a \code{data.frame} or \code{tibble} -#' @param x factor; column in \code{data} -#' @param y factor; column in \code{data} +#' @param x a categorical variable +#' @param y a categorical variable #' @return \code{infer_chisq_assoc_test} returns an object of class #' \code{"infer_chisq_assoc_test"}. An object of class #' \code{"infer_chisq_assoc_test"} is a list containing the @@ -32,37 +30,26 @@ #' @references Sheskin, D. J. 2007. Handbook of Parametric and Nonparametric #' Statistical Procedures, 4th edition. : Chapman & Hall/CRC. #' @examples -#' infer_chisq_assoc_test(hsb, female, schtyp) +#' infer_chisq_assoc_test(as.factor(hsb$female), as.factor(hsb$schtyp)) #' -#' infer_chisq_assoc_test(hsb, female, ses) +#' infer_chisq_assoc_test(as.factor(hsb$female), as.factor(hsb$ses)) #' @export #' -infer_chisq_assoc_test <- function(data, x, y) UseMethod('infer_chisq_assoc_test') +infer_chisq_assoc_test <- function(x, y) UseMethod('infer_chisq_assoc_test') #' @export -infer_chisq_assoc_test.default <- function(data, x, y) { +infer_chisq_assoc_test.default <- function(x, y) { - x1 <- enquo(x) - y1 <- enquo(y) - - xone <- - data %>% - pull(!! x1) - - yone <- - data %>% - pull(!! y1) - - if (!is.factor(xone)) { + if (!is.factor(x)) { stop('x must be a categorical variable') } - if (!is.factor(yone)) { + if (!is.factor(y)) { stop('y must be a categorical variable') } # dimensions - k <- table(xone, yone) + k <- table(x, y) dk <- dim(k) ds <- prod(dk) nr <- dk[1] @@ -71,7 +58,7 @@ infer_chisq_assoc_test.default <- function(data, x, y) { if (ds == 4) { - twoway <- matrix(table(xone, yone), nrow = 2) + twoway <- matrix(table(x, y), nrow = 2) df <- df_chi(twoway) ef <- efmat(twoway) k <- pear_chsq(twoway, df, ef) @@ -81,7 +68,7 @@ infer_chisq_assoc_test.default <- function(data, x, y) { } else { - twoway <- matrix(table(xone, yone), nrow = dk[1]) + twoway <- matrix(table(x, y), nrow = dk[1]) ef <- efm(twoway, dk) df <- df_chi(twoway) k <- pear_chi(twoway, df, ef) @@ -89,7 +76,7 @@ infer_chisq_assoc_test.default <- function(data, x, y) { } - j <- chigf(xone, yone, k$chi) + j <- chigf(x, y, k$chi) result <- if (ds == 4) { list(chi = k$chi, chilr = m$chilr, chimh = p$chimh, chiy = n$chi_y, @@ -112,7 +99,7 @@ infer_chisq_assoc_test.default <- function(data, x, y) { chisq_test <- function(x, y) { .Deprecated("infer_chisq_assoc_test()") - + infer_chisq_assoc_test(x, y) } diff --git a/R/infer-chisq-gof-test.R b/R/infer-chisq-gof-test.R index 707bd3c..ed6730c 100644 --- a/R/infer-chisq-gof-test.R +++ b/R/infer-chisq-gof-test.R @@ -1,8 +1,7 @@ #' @title Chi Square Goodness of Fit Test #' @description Test whether the observed proportions for a categorical variable #' differ from hypothesized proportions -#' @param data a \code{data.frame} or \code{tibble} -#' @param x factor; column in \code{data} +#' @param x categorical variable #' @param y expected proportions #' @param correct logical; if TRUE continuity correction is applied #' @return \code{infer_chisq_gof_test} returns an object of class @@ -28,35 +27,18 @@ #' @references Sheskin, D. J. 2007. Handbook of Parametric and Nonparametric #' Statistical Procedures, 4th edition. : Chapman & Hall/CRC. #' @examples -#' infer_chisq_gof_test(hsb, race, c(20, 20, 20, 140)) +#' infer_chisq_gof_test(as.factor(hsb$race), c(20, 20, 20, 140)) #' #' # apply continuity correction -#' infer_chisq_gof_test(hsb, race, c(20, 20, 20, 140), correct = TRUE) +#' infer_chisq_gof_test(as.factor(hsb$race), c(20, 20, 20, 140), correct = TRUE) #' @export #' -infer_chisq_gof_test <- function(data, x, y, correct = FALSE) UseMethod('infer_chisq_gof_test') +infer_chisq_gof_test <- function(x, y, correct = FALSE) UseMethod('infer_chisq_gof_test') #' @export -infer_chisq_gof_test.default <- function(data, x, y, correct = FALSE) { +infer_chisq_gof_test.default <- function(x, y, correct = FALSE) { - x1 <- enquo(x) - - xcheck <- - data %>% - pull(!! x1) - - xlen <- - data %>% - pull(!! x1) %>% - length - - xone <- - data %>% - pull(!! x1) %>% - table %>% - as.vector - - if (!is.factor(xcheck)) { + if (!is.factor(x)) { stop('x must be an object of class factor') } @@ -68,13 +50,10 @@ infer_chisq_gof_test.default <- function(data, x, y, correct = FALSE) { stop('correct must be either TRUE or FALSE') } - - varname <- - data %>% - select(!! x1) %>% - names - - n <- length(xone) + x1 <- x + varname <- l(deparse(substitute(x))) + x <- as.vector(table(x)) + n <- length(x) if (length(y) != n) { stop('Length of y must be equal to the number of categories in x') @@ -83,19 +62,19 @@ infer_chisq_gof_test.default <- function(data, x, y, correct = FALSE) { df <- n - 1 if (sum(y) == 1) { - y <- xlen * y + y <- length(x1) * y } if ((df == 1) || (correct == TRUE)) { - k <- chi_cort(xone, y) + k <- chi_cort(x, y) } else { - k <- chigof(xone, y) + k <- chigof(x, y) } sig <- round(pchisq(k$chi, df, lower.tail = FALSE), 4) - result <- list(chisquare = k$chi, pvalue = sig, df = df, ssize = length(xcheck), - names = levels(xcheck), level = nlevels(xcheck), obs = xone, exp = y, + result <- list(chisquare = k$chi, pvalue = sig, df = df, ssize = length(x1), + names = levels(x1), level = nlevels(x1), obs = x, exp = y, deviation = format(k$dev, nsmall = 2), std = format(k$std, nsmall = 2), varname = varname) @@ -110,6 +89,7 @@ infer_chisq_gof_test.default <- function(data, x, y, correct = FALSE) { chisq_gof <- function(x, y, correct = FALSE) { .Deprecated("infer_chisq_gof_test()") + infer_chisq_gof_test(x, y, correct = FALSE) } diff --git a/R/infer-cochran-q-test.R b/R/infer-cochran-q-test.R index d21f1a3..e81f854 100644 --- a/R/infer-cochran-q-test.R +++ b/R/infer-cochran-q-test.R @@ -1,9 +1,8 @@ -#' @importFrom rlang quos !!! #' @title Cochran Q Test #' @description Test if the proportions of 3 or more dichotomous variables are #' equal in the same population. -#' @param data a \code{data.frame} or \code{tibble} -#' @param ... columns in \code{data} +#' @param x a data frame/vector +#' @param ... numeric vectors #' @return \code{infer_cochran_qtest} returns an object of class #' \code{"infer_cochran_qtest"}. An object of class \code{"infer_cochran_qtest"} #' is a list containing the following components: @@ -19,28 +18,25 @@ #' Statistical Procedures, 4th edition. : Chapman & Hall/CRC. #' #' @examples -#' infer_cochran_qtest(exam, exam1, exam2, exam3) +#' infer_cochran_qtest(exam) #' @export #' -infer_cochran_qtest <- function(data, ...) UseMethod('infer_cochran_qtest') +infer_cochran_qtest <- function(x, ...) UseMethod('infer_cochran_qtest') #' @export -infer_cochran_qtest.default <- function(data, ...) { +infer_cochran_qtest.default <- function(x, ...) { - vars <- quos(...) + data <- coch_data(x, ...) - fdata <- data %>% - select(!!! vars) - - if (ncol(fdata) < 3) { + if (ncol(data) < 3) { stop('Please specify at least 3 variables.') } - if (any(sapply(lapply(fdata, as.factor), nlevels) > 2)) { + if (any(sapply(lapply(data, as.factor), nlevels) > 2)) { stop('Please specify dichotomous/binary variables only.') } - k <- cochran_comp(fdata) + k <- cochran_comp(data) result <- list(n = k$n, df = k$df, q = k$q, pvalue = k$pvalue) class(result) <- 'infer_cochran_qtest' return(result) @@ -54,6 +50,7 @@ infer_cochran_qtest.default <- function(data, ...) { cochran_test <- function(x, ...) { .Deprecated("infer_cochran_qtest()") + infer_cochran_qtest(x, ...) } diff --git a/R/infer-levene-test.R b/R/infer-levene-test.R index f553b1b..e8f8b11 100644 --- a/R/infer-levene-test.R +++ b/R/infer-levene-test.R @@ -67,6 +67,8 @@ infer_levene_test.default <- function(variable, ..., group_var = NULL, varname <- deparse(substitute(variable)) + + if (is.null(group_var)) { if (is.data.frame(variable)) { @@ -95,11 +97,23 @@ infer_levene_test.default <- function(variable, ..., group_var = NULL, } + if (!is.factor(group_var)) { group_var <- as.factor(group_var) } - - k <- lev_comp(variable, group_var, trim.mean) + k <- lev_comp(variable, group_var, trim.mean) + # comp <- complete.cases(variable, group_var) + # n <- length(comp) + # k <- nlevels(group_var) + # cvar <- variable[comp] + # gvar <- group_var[comp] + # lens <- tapply(cvar, gvar, length) + # avgs <- tapply(cvar, gvar, mean) + # sds <- tapply(cvar, gvar, sd) + + # bf <- lev_metric(cvar, gvar, mean) + # lev <- lev_metric(cvar, gvar, median) + # bft <- lev_metric(cvar, gvar, mean, trim = trim.mean) out <- list(bf = k$bf, p_bf = k$p_bf, lev = k$lev, p_lev = k$p_lev, bft = k$bft, p_bft = k$p_bft, avgs = k$avgs, sds = k$sds, diff --git a/R/infer-os-prop-test.R b/R/infer-os-prop-test.R index 90b15b8..53c87a6 100644 --- a/R/infer-os-prop-test.R +++ b/R/infer-os-prop-test.R @@ -33,7 +33,7 @@ #' infer_os_prop_test(200, prob = 0.5, phat = 0.3) #' #' # using data set -#' infer_os_prop_test(hsb$female, prob = 0.5) +#' infer_os_prop_test(as.factor(hsb$female), prob = 0.5) #' @export #' infer_os_prop_test <- function(n, prob = 0.5, alternative = c('both', 'less', @@ -117,8 +117,8 @@ infer_os_prop_test.factor <- function(n, prob = 0.5, } n1 <- length(n) - n2 <- table(n)[[2]] - phat <- round(n2 / n1, 4) + n2 <- table(n)[[2]] + phat <- round(n2 / n1, 4) prob <- prob alternative <- alternative diff --git a/R/infer-os-t-test.R b/R/infer-os-t-test.R index d378dbf..29bc707 100644 --- a/R/infer-os-t-test.R +++ b/R/infer-os-t-test.R @@ -1,8 +1,7 @@ #' @title One Sample t Test #' @description \code{infer_os_t_test} performs t tests on the equality of means. It tests the #' hypothesis that a sample has a mean equal to a hypothesized value. -#' @param data a \code{data.frame} or \code{tibble} -#' @param x numeric; column in \code{data} +#' @param x a numeric vector #' @param mu a number indicating the true value of the mean #' @param alpha acceptable tolerance for type I error #' @param type a character string specifying the alternative hypothesis, must be @@ -38,33 +37,27 @@ #' #' @examples #' # lower tail -#' infer_os_t_test(hsb, write, mu = 50, type = 'less') +#' infer_os_t_test(hsb$write, mu = 50, type = 'less') #' #' # upper tail -#' infer_os_t_test(hsb, write, mu = 50, type = 'greater') +#' infer_os_t_test(hsb$write, mu = 50, type = 'greater') #' #' # both tails -#' infer_os_t_test(hsb, write, mu = 50, type = 'both') +#' infer_os_t_test(hsb$write, mu = 50, type = 'both') #' #' # all tails -#' infer_os_t_test(hsb, write, mu = 50, type = 'all') +#' infer_os_t_test(hsb$write, mu = 50, type = 'all') #' @export #' -infer_os_t_test <- function(data, x, mu = 0, alpha = 0.05, +infer_os_t_test <- function(x, mu = 0, alpha = 0.05, type = c("both", "less", "greater", "all"), ...) UseMethod('infer_os_t_test') #' @export #' -infer_os_t_test.default <- function(data, x, mu = 0, alpha = 0.05, +infer_os_t_test.default <- function(x, mu = 0, alpha = 0.05, type = c("both", "less", "greater", "all"), ...) { - x1 <- enquo(x) - - xone <- - data %>% - pull(!! x1) - - if (!is.numeric(xone)) { + if (!is.numeric(x)) { stop('x must be numeric') } if (!is.numeric(mu)) { @@ -74,21 +67,46 @@ infer_os_t_test.default <- function(data, x, mu = 0, alpha = 0.05, stop('alpha must be numeric') } - type <- match.arg(type) + type <- match.arg(type) + var_name <- l(deparse(substitute(x))) + k <- ttest_comp(x, mu, alpha, type) + # n <- length(x) + # a <- (alpha / 2) + # df <- n - 1 + # conf <- 1 - alpha + # Mean <- round(mean(x), 4) + # stddev <- round(sd(x), 4) + # std_err <- round(stddev / sqrt(n), 4) + # test_stat <- round((Mean - mu) / std_err, 3) + + # if (type == 'less') { + # cint <- c(-Inf, test_stat + qt(1 - alpha, df) ) + # } else if (type == 'greater') { + # cint <- c(test_stat - qt(1 - alpha, df), Inf) + # } else { + # cint <- qt(1 - a, df) + # cint <- test_stat + c(-cint, cint) + # } - var_name <- - data %>% - select(!! x1) %>% - names + # confint <- round(mu + cint * std_err, 4) + # mean_diff <- round((Mean - mu), 4) + # mean_diff_l <- confint[1] - mu + # mean_diff_u <- confint[2] - mu + # p_l <- pt(test_stat, df) + # p_u <- pt(test_stat, df, lower.tail = FALSE) - k <- ttest_comp(xone, mu, alpha, type) + # if (p_l < 0.5) { + # p <- p_l * 2 + # } else { + # p <- p_u * 2 + # } - result <- list(mu = k$mu, n = k$n, df = k$df, Mean = k$Mean, - stddev = k$stddev, std_err = k$std_err, - test_stat = k$test_stat, confint = k$confint, - mean_diff = k$mean_diff, mean_diff_l = k$mean_diff_l, - mean_diff_u = k$mean_diff_u, p_l = k$p_l, p_u = k$p_u, - p = k$p, conf = k$conf, type = type, var_name = var_name) + + result <- list(mu = k$mu, n = k$n, df = k$df, Mean = k$Mean, stddev = k$stddev, + std_err = k$std_err, test_stat = k$test_stat, confint = k$confint, + mean_diff = k$mean_diff, mean_diff_l = k$mean_diff_l, + mean_diff_u = k$mean_diff_u, p_l = k$p_l, p_u = k$p_u, p = k$p, conf = k$conf, + type = type, var_name = var_name) class(result) <- 'infer_os_t_test' return(result) @@ -103,7 +121,7 @@ ttest <- function(x, mu = 0, alpha = 0.05, type = c("both", "less", "greater", "all"), ...) { .Deprecated("infer_os_t_test()") - + infer_os_t_test(x, mu, alpha, type, ...) } diff --git a/R/infer-os-var-test.R b/R/infer-os-var-test.R index 41a665d..6a73d24 100644 --- a/R/infer-os-var-test.R +++ b/R/infer-os-var-test.R @@ -3,8 +3,7 @@ #' @description \code{infer_os_var_test} performs tests on the equality of standard #' deviations (variances).It tests that the standard deviation of a sample is #' equal to a hypothesized value. -#' @param data a \code{data.frame} or \code{tibble} -#' @param x numeric; column in \code{data} +#' @param x a numeric vector #' @param sd hypothesised standard deviation #' @param confint confidence level #' @param alternative a character string specifying the alternative hypothesis, @@ -37,33 +36,27 @@ #' @seealso \code{\link[stats]{var.test}} #' @examples #' # lower tail -#' infer_os_var_test(mtcars, mpg, 5, alternative = 'less') +#' infer_os_var_test(mtcars$mpg, 5, alternative = 'less') #' #' # upper tail -#' infer_os_var_test(mtcars, mpg, 5, alternative = 'greater') +#' infer_os_var_test(mtcars$mpg, 5, alternative = 'greater') #' #' # both tails -#' infer_os_var_test(mtcars, mpg, 5, alternative = 'both') +#' infer_os_var_test(mtcars$mpg, 5, alternative = 'both') #' #' # all tails -#' infer_os_var_test(mtcars, mpg, 5, alternative = 'all') +#' infer_os_var_test(mtcars$mpg, 5, alternative = 'all') #' @export #' -infer_os_var_test <- function(data, x, sd, confint = 0.95, +infer_os_var_test <- function(x, sd, confint = 0.95, alternative = c('both', 'less', 'greater', 'all'), ...) UseMethod('infer_os_var_test') #' @export #' -infer_os_var_test.default <- function(data, x, sd, confint = 0.95, +infer_os_var_test.default <- function(x, sd, confint = 0.95, alternative = c('both', 'less', 'greater', 'all'), ...) { - x1 <- enquo(x) - - xone <- - data %>% - pull(!! x1) - - if (!is.numeric(xone)) { + if (!is.numeric(x)) { stop('x must be numeric') } @@ -75,14 +68,9 @@ infer_os_var_test.default <- function(data, x, sd, confint = 0.95, stop('confint must be numeric') } - type <- match.arg(alternative) - - varname <- - data %>% - select(!! x1) %>% - names - - k <- osvar_comp(xone, sd, confint) + type <- match.arg(alternative) + varname <- l(deparse(substitute(x))) + k <- osvar_comp(x, sd, confint) result <- list(n = k$n, sd = k$sd, sigma = k$sigma, se = k$se, chi = k$chi, df = k$df, p_lower = k$p_lower, p_upper = k$p_upper, p_two = k$p_two, @@ -102,7 +90,7 @@ os_vartest <- function(x, sd, confint = 0.95, alternative = c('both', 'less', 'greater', 'all'), ...) { .Deprecated("infer_os_var_test()") - + infer_os_var_test(x, sd, confint, alternative, ...) } diff --git a/R/infer-output.R b/R/infer-output.R index 64c017e..90b423d 100644 --- a/R/infer-output.R +++ b/R/infer-output.R @@ -39,8 +39,8 @@ print_owanova <- function(data) { cat(fg('Category', w8), fs(), fg('N', w9), fs(), fg('Mean', w10), fs(), fg('Std. Dev.', w11), '\n') cat(rep("-", wr), sep = "", '\n') for (i in seq_len(q)) { - cat(fc(data$tab[[i, 1]], w8), fs(), fg(data$tab[[i, 2]], w9), fs(), fk(format(round(data$tab[[i, 3]], 3), nsmall = 3), w10), - fs(), fk(format(round(data$tab[[i, 4]], 3), nsmall = 3), w11), '\n') + cat(fc(data$tab[[i, 1]], w8), fs(), fg(data$tab[[i, 2]], w9), fs(), fk(data$tab[[i, 3]], w10), + fs(), fk(data$tab[[i, 4]], w11), '\n') } cat(rep("-", wr), sep = "", '\n\n') diff --git a/R/infer-runs-test.R b/R/infer-runs-test.R index 53b3d9d..b51146b 100644 --- a/R/infer-runs-test.R +++ b/R/infer-runs-test.R @@ -63,8 +63,8 @@ infer_runs_test.default <- function(x, drop = FALSE, threshold = NA) { n <- length(x) - # if (!(is.numeric(x) || is.integer(x))) - # stop("x must be numeric or integer") + if (!(is.numeric(x) || is.integer(x))) + stop("x must be numeric or integer") if (is.na(threshold)) { y <- unique(x) diff --git a/R/infer-utils.R b/R/infer-utils.R index 837773c..85a0145 100644 --- a/R/infer-utils.R +++ b/R/infer-utils.R @@ -1,62 +1,30 @@ -#' @importFrom dplyr group_by group_by_ select_ summarise_all funs mutate -#' @importFrom magrittr %>% use_series +#' @importFrom dplyr group_by_ select_ summarise_all funs mutate +#' @importFrom magrittr %>% #' @importFrom stats var sd #' @importFrom tibble tibble as_data_frame anova_split <- function(data, x, y, sample_mean) { - - x1 <- enquo(x) - y1 <- enquo(y) - - by_factor <- - data %>% - group_by(!! y1) %>% - select(!! y1, !! x1) %>% - summarise_all(funs(length, mean, var, sd)) %>% - as_data_frame() %>% - mutate( - sst = length * ((mean - sample_mean) ^ 2), - sse = (length - 1) * var - ) - - return(by_factor) - + by_factor <- data %>% + group_by_(y) %>% + select_(y, x) %>% + summarise_all(funs(length, mean, var, sd)) %>% + as_data_frame() %>% + mutate( + sst = length * ((mean - sample_mean) ^ 2), + sse = (length - 1) * var + ) + return(by_factor) } anova_avg <- function(data, y) { - - y1 <- enquo(y) - - avg <- - data %>% - select(!! y1) %>% + avg <- data %>% + select_(y) %>% summarise_all(funs(mean)) - return(unlist(avg, use.names = FALSE)) - } anova_calc <- function(data, sample_stats, x, y) { - - x1 <- enquo(x) - y1 <- enquo(y) - - var_names <- - data %>% - select(!! x1, !! y1) %>% - names - - sstr <- - sample_stats %>% - use_series(sst) %>% - sum %>% - round(3) - - ssee <- - sample_stats %>% - use_series(sse) %>% - sum %>% - round(3) - + sstr <- round(sum(sample_stats$sst), 3) + ssee <- round(sum(sample_stats$sse), 3) total <- round(sstr + ssee, 3) df_sstr <- nrow(sample_stats) - 1 df_sse <- nrow(data) - nrow(sample_stats) @@ -66,7 +34,7 @@ anova_calc <- function(data, sample_stats, x, y) { f <- round(mstr / mse, 3) sig <- round(1- pf(f, df_sstr, df_sse), 3) obs <- nrow(data) - regs <- paste(var_names[1], '~ as.factor(', var_names[2], ')') + regs <- paste(x, '~ as.factor(', y, ')') model <- lm(as.formula(regs), data = data) reg <- summary(model) out <- list(sstr = sstr, ssee = ssee, total = total, df_sstr = df_sstr, @@ -241,32 +209,17 @@ coch_data <- function(x, ...) { return(data) } -#' @importFrom purrr map_df -#' @importFrom magrittr subtract -cochran_comp <- function(data) { +cochran_comp <- function(data) { n <- nrow(data) k <- ncol(data) df <- k - 1 - - cs <- - data %>% - map_df(.f = as.numeric) %>% - subtract(1) %>% - sums - + cs <- sums(data) q <- coch(k, cs$cls_sum, cs$cl, cs$g, cs$gs_sum) - pvalue <- 1 - pchisq(q, df) - - out <- list(n = n, - df = df, - q = q, - pvalue = round(pvalue, 4)) - + out <- list(n = n, df = df, q = q, pvalue = round(pvalue, 4)) return(out) - - } +} # levene test @@ -390,7 +343,7 @@ prop_fact <- function(dat, p) { cases <- 1 - row_sum[2] ratio <- cases / controls odds_ratio <- p[1] / p[2] - out <- list(cases = cases, controls = controls, ratio = ratio, + out <- list(cases = cases, controls = controls, ratio = ratio, odds_ratio = odds_ratio) return(out) } @@ -421,14 +374,14 @@ dat_per[d1[1], d1[2]] <- 1.0 mccomp <- function(dat) { p <- mctestp(dat) - test_stat <- tetat(p) + test_stat <- tetat(p) df <- nrow(dat) - 1 - pvalue <- mcpval(test_stat, df) + pvalue <- mcpval(test_stat, df) exactp <- mcpex(dat) cstat <- mcstat(p) cpvalue <- mccpval(cstat, df) kappa <- mckappa(dat) - std_err <- mcserr(dat, kappa) + std_err <- mcserr(dat, kappa) clu <- mcconf(std_err, kappa) k <- prop_fact(dat, p) @@ -472,7 +425,7 @@ prop_comp <- function(n, prob, alternative, phat) { } out <- list(n = n, phat = phat, p = prob, z = z, sig = sig, alt = alt, - obs = obs, exp = exp, deviation = format(dev, nsmall = 2), + obs = obs, exp = exp, deviation = format(dev, nsmall = 2), std = format(std, nsmall = 2)) return(out) @@ -504,7 +457,7 @@ osvar_comp <- function(x, sd, confint) { c_upr <- round(tv / qchisq(a, df), 4) out <- list(n = n, sd = sd, sigma = sigma, se = se, chi = chi, df = df, - p_lower = p_lower, p_upper = p_upper, p_two = p_two, xbar = xbar, + p_lower = p_lower, p_upper = p_upper, p_two = p_two, xbar = xbar, c_lwr = c_lwr, c_upr = c_upr, conf = conf) return(out) @@ -567,7 +520,7 @@ prop_comp2 <- function(var1, var2, alt) { ut <- round(pnorm(z, lower.tail = FALSE), 4) tt <- round(pnorm(abs(z), lower.tail = FALSE) * 2, 4) - + if (alt == "all") { sig = c('two-tail' = tt, 'lower-tail' = lt, 'upper-tail' = ut) @@ -712,7 +665,7 @@ indsig <- function(n1, n2, s1, s2, mean_diff) { fsig <- function(s1, s2, n1, n2) { out <- round(min(pf(round(s1 / s2, 4), (n1 - 1), (n2 -1)), - pf(round(s1 / s2, 4), (n1 - 1), (n2 -1), + pf(round(s1 / s2, 4), (n1 - 1), (n2 -1), lower.tail = FALSE)) * 2, 4) return(out) } @@ -728,8 +681,8 @@ indpool <- function(n1, n2, mean_diff, se_dif) { } else { sig_pooled <- round(pt(t_pooled, df_pooled, lower.tail = FALSE) * 2, 4) } - out <- list(df_pooled = df_pooled, t_pooled = t_pooled, - sig_pooled_l = sig_pooled_l, sig_pooled_u = sig_pooled_u, + out <- list(df_pooled = df_pooled, t_pooled = t_pooled, + sig_pooled_l = sig_pooled_l, sig_pooled_u = sig_pooled_u, sig_pooled = sig_pooled) return(out) } @@ -1016,4 +969,4 @@ check_x <- function(data, x) { unlist() %>% (is.factor) %>% `!` -} +} \ No newline at end of file diff --git a/README.Rmd b/README.Rmd index 39759fa..abb367c 100644 --- a/README.Rmd +++ b/README.Rmd @@ -82,19 +82,19 @@ library(inferr) ``` ```{r infer1} -infer_os_t_test(hsb, write, mu = 50, type = 'all') +infer_os_t_test(hsb$write, mu = 50, type = 'all') ``` ##### ANOVA ```{r anova} -infer_oneway_anova(hsb, write, prog) +infer_oneway_anova(hsb, 'write', 'prog') ``` ##### Chi Square Test of Independence ```{r chi1} -infer_chisq_assoc_test(hsb, female, schtyp) +infer_chisq_assoc_test(as.factor(hsb$female), as.factor(hsb$schtyp)) ``` ##### Levene's Test @@ -106,7 +106,7 @@ infer_levene_test(hsb$read, group_var = hsb$race) ##### Cochran's Q Test ```{r cochran} -infer_cochran_qtest(exam, exam1, exam2, exam3) +infer_cochran_qtest(exam) ``` ##### McNemar Test diff --git a/README.md b/README.md index ab46f03..a91bdec 100644 --- a/README.md +++ b/README.md @@ -1,54 +1,44 @@ +inferr: Inferential statistics with R +-------------------------------------------------------------------------------- -## inferr: Inferential statistics with R +**Author:** [Aravind Hebbali](http://www.aravindhebbali.com)
**License:** [MIT](https://opensource.org/licenses/MIT) -**Author:** [Aravind Hebbali](http://www.aravindhebbali.com)
-**License:** -[MIT](https://opensource.org/licenses/MIT) +[![CRAN\_Status\_Badge](http://www.r-pkg.org/badges/version/inferr)](https://cran.r-project.org/package=inferr) [![Travis-CI Build Status](https://travis-ci.org/rsquaredacademy/inferr.svg?branch=master)](https://travis-ci.org/rsquaredacademy/inferr) [![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/github/rsquaredacademy/inferr?branch=master&svg=true)](https://ci.appveyor.com/project/rsquaredacademy/inferr) [![Coverage Status](https://img.shields.io/codecov/c/github/rsquaredacademy/inferr/master.svg)](https://codecov.io/github/rsquaredacademy/inferr?branch=master) [![](https://cranlogs.r-pkg.org/badges/grand-total/inferr)](https://cran.r-project.org/package=inferr) ![](https://img.shields.io/badge/lifecycle-maturing-blue.svg) -[![CRAN\_Status\_Badge](http://www.r-pkg.org/badges/version/inferr)](https://cran.r-project.org/package=inferr) -[![Travis-CI Build -Status](https://travis-ci.org/rsquaredacademy/inferr.svg?branch=master)](https://travis-ci.org/rsquaredacademy/inferr) -[![AppVeyor Build -Status](https://ci.appveyor.com/api/projects/status/github/rsquaredacademy/inferr?branch=master&svg=true)](https://ci.appveyor.com/project/rsquaredacademy/inferr) -[![](https://cranlogs.r-pkg.org/badges/grand-total/inferr)](https://cran.r-project.org/package=inferr) -## Overview +Overview +-------- -Inferential statistics allows us to make generalizations about -populations using data drawn from the population. We use them when it is -impractical or impossible to collect data about the whole population -under study and instead, we have a sample that represents the population -under study and using inferential statistics technique, we make -generalizations about the population from the sample. +Inferential statistics allows us to make generalizations about populations using data drawn from the population. We use them when it is impractical or impossible to collect data about the whole population under study and instead, we have a sample that represents the population under study and using inferential statistics technique, we make generalizations about the population from the sample. The **inferr** package: - - builds upon the statistical tests provided in **stats** - - provides additional and flexible input options - - more detailed and structured test results - -As of version 0.1, **inferr** includes a select set of parametric and -non-parametric statistical tests which are listed below: - - - One Sample t Test - - Paired Sample t Test - - Independent Sample t Test - - One Sample Proportion Test - - Two Sample Proportion Test - - One Sample Variance Test - - Two Sample Variance Test - - Binomial Test - - ANOVA - - Chi Square Goodness of Fit Test - - Chi Square Independence Test - - Levene’s Test - - Cochran’s Q Test - - McNemar Test - - Runs Test for Randomness - -## Installation +- builds upon the statistical tests provided in **stats** +- provides additional and flexible input options +- more detailed and structured test results + +As of version 0.1, **inferr** includes a select set of parametric and non-parametric statistical tests which are listed below: + +- One Sample t Test +- Paired Sample t Test +- Independent Sample t Test +- One Sample Proportion Test +- Two Sample Proportion Test +- One Sample Variance Test +- Two Sample Variance Test +- Binomial Test +- ANOVA +- Chi Square Goodness of Fit Test +- Chi Square Independence Test +- Levene's Test +- Cochran's Q Test +- McNemar Test +- Runs Test for Randomness + +Installation +------------ ``` r # install inferr from CRAN @@ -59,21 +49,23 @@ install.packages("inferr") devtools::install_github("rsquaredacademy/inferr") ``` -## Shiny App +Shiny App +--------- Use `infer_launch_shiny_app()` to explore the package using a shiny app. -## Vignettes +Vignettes +--------- - - [Introduction to - inferr](http://www.rsquaredacademy.com/inferr/articles/index.html) +- [Introduction to inferr](http://www.rsquaredacademy.com/inferr/articles/index.html) -## Usage +Usage +----- ##### One Sample t Test ``` r -infer_os_t_test(hsb, write, mu = 50, type = 'all') +infer_os_t_test(hsb$write, mu = 50, type = 'all') #> One-Sample Statistics #> --------------------------------------------------------------------------------- #> Variable Obs Mean Std. Err. Std. Dev. [95% Conf. Interval] @@ -91,7 +83,7 @@ infer_os_t_test(hsb, write, mu = 50, type = 'all') ##### ANOVA ``` r -infer_oneway_anova(hsb, write, prog) +infer_oneway_anova(hsb, 'write', 'prog') #> ANOVA #> ---------------------------------------------------------------------- #> Sum of @@ -104,11 +96,11 @@ infer_oneway_anova(hsb, write, prog) #> #> Report #> ----------------------------------------- -#> Category N Mean Std. Dev. +#> Category N Mean Std. Dev. #> ----------------------------------------- -#> 1 45 51.333 9.398 -#> 2 105 56.257 7.943 -#> 3 50 46.760 9.319 +#> 1 45 51.333 9.398 +#> 2 105 56.257 7.943 +#> 3 50 46.760 9.319 #> ----------------------------------------- #> #> Number of obs = 200 R-squared = 0.1776 @@ -118,7 +110,7 @@ infer_oneway_anova(hsb, write, prog) ##### Chi Square Test of Independence ``` r -infer_chisq_assoc_test(hsb, female, schtyp) +infer_chisq_assoc_test(as.factor(hsb$female), as.factor(hsb$schtyp)) #> Chi Square Statistics #> #> Statistics DF Value Prob @@ -133,7 +125,7 @@ infer_chisq_assoc_test(hsb, female, schtyp) #> ---------------------------------------------------- ``` -##### Levene’s Test +##### Levene's Test ``` r infer_levene_test(hsb$read, group_var = hsb$race) @@ -158,10 +150,10 @@ infer_levene_test(hsb$read, group_var = hsb$race) #> ------------------------------------------------------------------------- ``` -##### Cochran’s Q Test +##### Cochran's Q Test ``` r -infer_cochran_qtest(exam, exam1, exam2, exam3) +infer_cochran_qtest(exam) #> Test Statistics #> ---------------------- #> N 15 @@ -212,6 +204,4 @@ infer_mcnemar_test(table(himath, hiread)) #> ---------------------- ``` -Please note that this project is released with a [Contributor Code of -Conduct](CONDUCT.md). By participating in this project you agree to -abide by its terms. +Please note that this project is released with a [Contributor Code of Conduct](CONDUCT.md). By participating in this project you agree to abide by its terms. diff --git a/data/hsb.rda b/data/hsb.rda index 799e9a85cead5274e6beb95f585ff0d28b266f7b..56130c695995bf2295eb74d2dd418bdbbea9d692 100644 GIT binary patch literal 1674 zcmV;526g#DT4*^jL0KkKSz*h$%m5JAfBgUd|NsC0|NsC0|NsC0|NsC0|NsC0|NsBM z0140qo&X7sL?lZbG(?dnqI#GJ(V7BcWN2xG(UW9G6Esbv(_u~NPfbrm(UTE`Fal)2 z6EsJnV2wRbBTY=y@j>Xs^pn*5O++fG{v$-Er?eU;p)pS;rcE+WP-qzd00001>Hq^k z000000000000010Pr({u8VJHQG(ARBXeNn(06~Pn022TJ0001)G{RsL00000n2aU? z02*i+4H_B%8Udz*5HcD74FCYipa5h6lT3{?WN0)10B8Y-Xwyt4h6o8Xr4-cl15GsA zf?xmu0$>0FU;qFB5vC>q7yu>%Ns|BoMkk;FFaXf~G`NtE$%`rq3m~#VWKacAMn!<4 z#fnIYl%*h~7SO3emd1j>L}D?rwo#?Ds+J8FwOSa)GubJOl(+w&b195iurZ3^xUCF0V{Iu)R>cQNm-RLXwf4G zo!~&jtavGcONOWmh1s0LC`xR;Vsq8$RgSrr=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les/intro.html @@ -80,7 +80,7 @@ @@ -121,7 +121,7 @@

Example

Using the hsb data, test whether the average of write differs significantly from 50.

-
infer_os_t_test(hsb, write, mu = 50, type = 'all')
+
infer_os_t_test(hsb$write, mu = 50, type = 'all')
##                               One-Sample Statistics                               
 ## ---------------------------------------------------------------------------------
 ##  Variable    Obs     Mean     Std. Err.    Std. Dev.    [95% Conf. Interval] 
@@ -358,7 +358,7 @@ 

Examples

Using the mtcars data, compare the standard deviation of mpg to a hypothesized value.

# Lower Tail Test
-infer_os_var_test(mtcars, mpg, 0.3, alternative = 'less')
+infer_os_var_test(mtcars$mpg, 0.3, alternative = 'less')
##                             One-Sample Statistics                             
 ## -----------------------------------------------------------------------------
 ##  Variable    Obs     Mean      Std. Err.    Std. Dev.    [95% Conf. Interval] 
@@ -378,8 +378,7 @@ 

## mpg 12511.436 31 1.0000 ## ----------------------------------------

# Test all alternatives
-
-infer_os_var_test(mtcars, mpg, 0.3, alternative = 'all')
+infer_os_var_test(mtcars$mpg, 0.3, alternative = 'all')
##                             One-Sample Statistics                             
 ## -----------------------------------------------------------------------------
 ##  Variable    Obs     Mean      Std. Err.    Std. Dev.    [95% Conf. Interval] 
@@ -476,8 +475,7 @@ 

Examples

Using the hsb data, test whether the proportion of females and males are equal.

# Using variables
-
-infer_binom_test(hsb, female, prob = 0.5)
+infer_binom_test(as.factor(hsb$female), prob = 0.5)
##              Binomial Test              
 ##  ---------------------------------------
 ##   Group     N     Obs. Prop    Exp. Prop 
@@ -526,8 +524,7 @@ 

Examples

Using the hsb data, test whether the mean of write differs between the three program types.

- -
infer_oneway_anova(hsb, write, prog)
+
infer_oneway_anova(hsb, 'write', 'prog')
##                                 ANOVA                                  
 ## ----------------------------------------------------------------------
 ##                    Sum of                                             
@@ -540,11 +537,11 @@ 

## ## Report ## ----------------------------------------- -## Category N Mean Std. Dev. +## Category N Mean Std. Dev. ## ----------------------------------------- -## 1 45 51.333 9.398 -## 2 105 56.257 7.943 -## 3 50 46.760 9.319 +## 1 45 51.333 9.398 +## 2 105 56.257 7.943 +## 3 50 46.760 9.319 ## ----------------------------------------- ## ## Number of obs = 200 R-squared = 0.1776 @@ -560,8 +557,8 @@

Example

Using the hsb data, test whether the observed proportions for race differs significantly from the hypothesized proportions.

# basic example
-
-infer_chisq_gof_test(hsb, race, c(20, 20, 20 , 140))
+race <- as.factor(hsb$race) +infer_chisq_gof_test(race, c(20, 20, 20 , 140))
##     Test Statistics     
 ## -----------------------
 ## Chi-Square       5.0286 
@@ -582,8 +579,8 @@ 

Continuity Correction

# using continuity correction
-
-infer_chisq_gof_test(hsb, race, c(20, 20, 20 , 140), correct = TRUE)
+race <- as.factor(hsb$race) +infer_chisq_gof_test(race, c(20, 20, 20 , 140), correct = TRUE)
##     Test Statistics     
 ## -----------------------
 ## Chi-Square       4.3821 
@@ -611,8 +608,7 @@ 

Examples

Using the hsb data, test if there is a relationship between the type of school attended (schtyp) and students’ gender (female).

- -
infer_chisq_assoc_test(hsb, female, schtyp)
+
infer_chisq_assoc_test(as.factor(hsb$female), as.factor(hsb$schtyp))
##                Chi Square Statistics                 
 ## 
 ## Statistics                     DF    Value      Prob 
@@ -626,8 +622,7 @@ 

## Cramer's V 0.0153 ## ----------------------------------------------------

Using the hsb data, test if there is a relationship between the type of school attended (schtyp) and students’ socio economic status (ses).

- -
infer_chisq_assoc_test(hsb, schtyp, ses)
+
infer_chisq_assoc_test(as.factor(hsb$schtyp), as.factor(hsb$ses))
##                Chi Square Statistics                 
 ## 
 ## Statistics                     DF    Value      Prob 
@@ -757,8 +752,7 @@ 

Example

The exam data set contains scores of 15 students for three exams (exam1, exam2, exam3). Test if three exams are equally difficult.

- -
infer_cochran_qtest(exam, exam1, exam2, exam3)
+
##    Test Statistics     
 ## ----------------------
 ## N                   15 
diff --git a/docs/hex_inferr.png b/docs/hex_inferr.png
deleted file mode 100644
index 0a0d656e149cb2ee318575a6a54f4568e2d0744c..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001

liter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Z?VrO%
z2@Fi-e#^aM@%Ey_-=2tq&1G#VxIM5rE3ilr-=taW*&ZH!}Q5ngo5Sy;wfEaQ45N*x+HTN5pO4
z%bFu5zDGs-Y79-b(TQ@HxHyIgt&c78#$-2Cn}$vv$m
zlWFt);SolC!#R_uy%|Xj6$)0=(kuJIOpe_*tay9)K?R*D6s~}W(f^#xCK>hQ1OPO&
zFDEPdBQa_)>G|zu;tp>kLpo%7y^rIFu6HYzc;Mi)&!)eX9~=G9l9eA5>}KY@g6+}L
zoMFS0^MuyKMZ3Jcsh^SzdY@=r>i$xbJ1N=YVFQQ3F4&41CE=%b<1~aU?U!(%x7Mz@
z2G6BOY6A^IiOH&|<#n~vS=o)ND4Z0LF|W_={^sG7S*0+P-hDo50X+Iic@WjFE9>3{
z_xn|?N3qPtM^7(g0|!>_F^L*iLrU$|1ONbo#6i!<%Sc0A%*xf72Vw1MX~W~^?1ug+
z2LR$yer^aWM;k9jOB*`}7YUA|jvfw12WtrqLm>^ghMSy?y@PUqht0D9O+BjsM=Mcl
z4k<}|aX&FMfwPSlg3-^}$;DI5PlDrLykhA4zumkXjQ@goIZAM-I3w(A#KaW*9BlPm
zU7Z+3d4%~m&>SAtwqm;SivMOnw=oCr%-Z!ZZB4t&OcQ@i~)Y8TIc
z8-TWg7d^ns$0NXt=3-&Zzn(`lHEh7F4=?erH

diff --git a/docs/reference/infer_binom_calc.html b/docs/reference/infer_binom_calc.html
index 643edad..656dc8a 100644
--- a/docs/reference/infer_binom_calc.html
+++ b/docs/reference/infer_binom_calc.html
@@ -6,7 +6,7 @@
 
 
 
-Binomial Test — infer_binom_calc • inferr
+Binomial Test — infer_binom_calc • inferr
 
 
 
@@ -111,7 +111,7 @@ 

Binomial Test

infer_binom_calc(n, success, prob = 0.5, ...)
 
-infer_binom_test(data, variable, prob = 0.5)
+infer_binom_test(data, prob = 0.5)

Arguments

@@ -134,13 +134,7 @@

Ar

- - - - - - - +
data

a data.frame or a tibble

variable

factor; column in data

binary/dichotomous factor

@@ -192,7 +186,7 @@

Examp #> Upper Pr(k >= 13) 0.892336 #> --------------------------------------------
# using data set -infer_binom_test(hsb, female, prob = 0.5)
#> Binomial Test +infer_binom_test(as.factor(hsb$female), prob = 0.5)
#> Binomial Test #> --------------------------------------- #> Group N Obs. Prop Exp. Prop #> --------------------------------------- diff --git a/docs/reference/infer_chisq_assoc_test.html b/docs/reference/infer_chisq_assoc_test.html index b41688f..209beb6 100644 --- a/docs/reference/infer_chisq_assoc_test.html +++ b/docs/reference/infer_chisq_assoc_test.html @@ -11,8 +11,8 @@ + - @@ -23,17 +23,14 @@ - - + - + - - @@ -109,48 +106,26 @@

Chi Square Test of Association

relationship between two categorical variables.

-
infer_chisq_assoc_test(data, x, y)
+
infer_chisq_assoc_test(x, y)

Arguments

- - - - - - - - - - - - - - -
data

a data.frame or tibble

x

factor; column in data

y

factor; column in data

+
+
x
+
a categorical variable
+
y
+
a categorical variable
+

Value

infer_chisq_assoc_test returns an object of class -"infer_chisq_assoc_test". An object of class -"infer_chisq_assoc_test" is a list containing the +"infer_chisq_assoc_test". An object of class +"infer_chisq_assoc_test" is a list containing the following components:

-
chi

chi square

-
chilr

likelihood ratio chi square

-
chimh

mantel haenszel chi square

-
chiy

continuity adjusted chi square

-
sig

p-value of chi square

-
siglr

p-value of likelihood ratio chi square

-
sigmh

p-value of mantel haenszel chi square

-
sigy

p-value of continuity adjusted chi square

-
phi

phi coefficient

-
cc

contingency coefficient

-
cv

cramer's v

-
ds

product of dimensions of the table of x and y

-
df

degrees of freedom

-

Deprecated Function

+

chisq_test() has been deprecated. Instead use infer_chisq_assoc_test().

@@ -165,7 +140,7 @@

See a

Examples

-
infer_chisq_assoc_test(hsb, female, schtyp)
#> Chi Square Statistics +
infer_chisq_assoc_test(as.factor(hsb$female), as.factor(hsb$schtyp))
#> Chi Square Statistics #> #> Statistics DF Value Prob #> ---------------------------------------------------- @@ -175,9 +150,9 @@

Examp #> Mantel-Haenszel Chi-Square 1 0.0468 0.8287 #> Phi Coefficient 0.0153 #> Contingency Coefficient 0.0153 -#> Cramer's V 0.0153 +#> Cramer's V 0.0153 #> ----------------------------------------------------

-infer_chisq_assoc_test(hsb, female, ses)
#> Chi Square Statistics +infer_chisq_assoc_test(as.factor(hsb$female), as.factor(hsb$ses))
#> Chi Square Statistics #> #> Statistics DF Value Prob #> ---------------------------------------------------- @@ -185,7 +160,7 @@

Examp #> Likelihood Ratio Chi-Square 2 4.6789 0.0964 #> Phi Coefficient 0.1513 #> Contingency Coefficient 0.1496 -#> Cramer's V 0.1513 +#> Cramer's V 0.1513 #> ----------------------------------------------------