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)
+[](https://cran.r-project.org/package=inferr) [](https://travis-ci.org/rsquaredacademy/inferr) [](https://ci.appveyor.com/project/rsquaredacademy/inferr) [](https://codecov.io/github/rsquaredacademy/inferr?branch=master) [](https://cran.r-project.org/package=inferr) 
-[](https://cran.r-project.org/package=inferr)
-[](https://travis-ci.org/rsquaredacademy/inferr)
-[](https://ci.appveyor.com/project/rsquaredacademy/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 799e9a8..56130c6 100644
Binary files a/data/hsb.rda and b/data/hsb.rda differ
diff --git a/docs/articles/intro.html b/docs/articles/intro.html
index 7b13de8..fc674a0 100644
--- a/docs/articles/intro.html
+++ b/docs/articles/intro.html
@@ -80,7 +80,7 @@
Using the hsb data, test whether the average of write differs significantly from 50.
- +## 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.
+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
## ----------------------------------------
+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.
+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.
-
-
+
## 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.
+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).
-
-
+
## 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).
-
-
+
## 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.
-
-
+
## Test Statistics
## ----------------------
## N 15
diff --git a/docs/hex_inferr.png b/docs/hex_inferr.png
deleted file mode 100644
index 0a0d656..0000000
Binary files a/docs/hex_inferr.png and /dev/null differ
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
#> ----------------------------------------------------