# Estimation Approach to Statistical Inference
## Means (with By Option)
### Descriptives
.descMeansBy <- function(...) {
UseMethod(".descMeansBy")
}
.descMeansBy.default <- function(frame, by, ...) {
MixedData <- data.frame(by, frame)
SplitData <- split(MixedData[-1], by)
results <- lapply(SplitData, .descMeans)
results
}
.descMeansBy.formula <- function(formula, by, ...) {
Group <- eval(formula[[3]])
Outcome <- eval(formula[[2]])
FactorialData <- data.frame(by, Group, Outcome)
SplitData <- split(FactorialData, by)
results <- lapply(SplitData, function(x) with(x, .descMeans(Outcome ~ Group)))
results
}
descMeansBy <- function(..., main = NULL, digits = 3) {
results <- .descMeansBy(...)
if (is.null(main)) {
main <- "Descriptive Statistics for the Data"
}
main <- paste(main, names(results), sep = ": ")
.formatList(results, main, digits = digits)
}
### Confidence Intervals
.ciMeansBy <- function(...) {
UseMethod(".ciMeansBy")
}
.ciMeansBy.default <- function(frame, by, conf.level = .95, ...) {
MixedData <- data.frame(by, frame)
SplitData <- split(MixedData[-1], by)
results <- lapply(SplitData, .ciMeans, conf.level = conf.level)
results
}
.ciMeansBy.formula <- function(formula, by, conf.level = .95, ...) {
Group <- eval(formula[[3]])
Outcome <- eval(formula[[2]])
FactorialData <- data.frame(by, Group, Outcome)
SplitData <- split(FactorialData, by)
results <- lapply(SplitData, function(x) with(x, .ciMeans(Outcome ~ Group, conf.level = conf.level)))
results
}
ciMeansBy <- function(..., main = NULL, digits = 3) {
results <- .ciMeansBy(...)
if (is.null(main)) {
main <- "Confidence Intervals for the Means"
}
main <- paste(main, names(results), sep = ": ")
.formatList(results, main, digits = digits)
}
### Null Hypothesis Significance tests
.nhstMeansBy <- function(...) {
UseMethod(".nhstMeansBy")
}
.nhstMeansBy.default <- function(frame, by, mu = 0, ...) {
MixedData <- data.frame(by, frame)
SplitData <- split(MixedData[-1], by)
results <- lapply(SplitData, .nhstMeans, mu = mu)
results
}
.nhstMeansBy.formula <- function(formula, by, mu = 0, ...) {
Group <- eval(formula[[3]])
Outcome <- eval(formula[[2]])
FactorialData <- data.frame(by, Group, Outcome)
SplitData <- split(FactorialData, by)
results <- lapply(SplitData, function(x) with(x, .nhstMeans(Outcome ~ Group, mu = mu)))
results
}
nhstMeansBy <- function(..., main = NULL, digits = 3) {
results <- .nhstMeansBy(...)
if (is.null(main)) {
main <- "Hypothesis Tests for the Means"
}
main <- paste(main, names(results), sep = ": ")
.formatList(results, main, digits = digits)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.