| Title: | Companion to the Book "Investigating Statistical Concepts, Applications, and Methods" |
| Version: | 1.0.0 |
| Description: | Introductory statistics methods to accompany "Investigating Statistical Concepts, Applications, and Methods" (ISCAM) by Beth Chance & Allan Rossman (2024) https://rossmanchance.com/iscam4/. Tools to introduce statistical concepts with a focus on simulation approaches. Functions are verbose, designed to provide ample output for students to understand what each function does. Additionally, most functions are accompanied with plots. The package is designed to be used in an educational setting alongside the ISCAM textbook. |
| License: | MIT + file LICENSE |
| URL: | https://iscam4.github.io/ISCAM/, https://github.com/ISCAM4/ISCAM |
| BugReports: | https://github.com/ISCAM4/ISCAM/issues |
| Depends: | R (≥ 3.5) |
| Imports: | graphics, stats |
| Suggests: | testthat (≥ 3.0.0), usethis, vdiffr (≥ 1.0.8) |
| Config/testthat/edition: | 3 |
| Encoding: | UTF-8 |
| LazyData: | true |
| RoxygenNote: | 7.3.3 |
| NeedsCompilation: | no |
| Packaged: | 2025-10-23 17:19:28 UTC; visru |
| Author: | Beth Chance [cre, aut, cph],
Visruth Srimath Kandali
|
| Maintainer: | Beth Chance <bchance@calpoly.edu> |
| Repository: | CRAN |
| Date/Publication: | 2025-11-11 09:20:16 UTC |
ISCAM: Companion to the Book "Investigating Statistical Concepts, Applications, and Methods"
Description
Introductory statistics methods to accompany "Investigating Statistical Concepts, Applications, and Methods" (ISCAM) by Beth Chance & Allan Rossman. Tools to introduce statistical concepts with a focus on simulation approaches. Functions are verbose, designed to provide ample output for students to understand what each function does. Additionally, most functions are accompanied with plots. The package is designed to be used in an educational setting alongside the ISCAM textbook.
Author(s)
Maintainer: Beth Chance bchance@calpoly.edu [copyright holder]
Authors:
Visruth Srimath Kandali public@visruth.com (ORCID)
See Also
Useful links:
Report bugs at https://github.com/ISCAM4/ISCAM/issues
Template documentation for plotting parameters
Description
Template documentation for plotting parameters
Arguments
x |
A numeric vector representing the data to be plotted. |
main |
Optional title for the plot |
xlab |
Optional x-axis label for the plot |
bins |
Optional number of bins for the histogram. |
Template documentation for plotting parameters
Description
Template documentation for plotting parameters
Arguments
response |
Vector of numeric values to plot. |
explanatory |
Optional second categorical variable to group by. |
main |
Optional title for the plot |
xlab |
Optional x-axis label for the plot |
ylab |
Optional y-axis label for the plot. Only displayed when |
Cloud Seeding Data
Description
Our lives depend on rainfall. Consequently, scientists have long investigated whether humans can intervene and, as needed, help nature produce more rainfall. In one study, researchers in southern Florida explored whether injecting silver iodide into cumulus clouds would lead to increased rainfall. On each of 52 days that were judged to be suitable for cloud seeding, a target cloud was identified and a plane flew through the target cloud in order to seed it. Randomization was used to determine whether or not to load a seeding mechanism and seed the target cloud with silver iodide on that day. Radar was used to measure the volume of rainfall from the selected cloud during the next 24 hours. The results from Simpson, Olsen, and Eden, (1975) measure rainfall in volume units of acre-feet, “height” of rain across one acre.
Usage
CloudSeeding
Format
CloudSeeding
A data frame with 52 rows and 2 columns:
- treatment
Whether a cloud was seeded with silver iodide or not.
- rainfall
Volume of rainfall during the next 24 hours, in acre-feet.
Source
Flint Michigan Lead Data
Description
Lead poisoning can be a serious problem associated with drinking tap water. Many older water pipes are made of lead. Over time, the pipes corrode, releasing lead into the drinking water. In April 2014, the city of Flint Michigan switched its water supply to the Flint River in an effort to save money. The Michigan Department of Environmental Quality (MDEQ) tested the water at the time and declared it safe to drink. Officials were supposed to test at least 100 homes, targeting those most at risk. The U.S. Environmental Protection Agency (EPA)’s Lead and Copper Rule states that if lead concentrations exceed an action level of 15 parts per billion (ppb) in more than 10% of homes sampled, then actions must be undertaken to control corrosion, and the public must be informed.
Usage
FlintMDEQ
Format
flint
A data frame with 71 rows and 1 column:
- lead
Lead concentration per household, measured in parts per billion.
Infant Data
Description
In a study reported in the November 2007 issue of Nature, researchers investigated whether infants take into account an individual’s actions towards others in evaluating that individual as appealing or aversive, perhaps laying for the foundation for social interaction (Hamlin, Wynn, and Bloom, 2007). In other words, do children who aren’t even yet talking still form impressions as to someone’s friendliness based on their actions? In one component of the study, 10-month-old infants were shown a “climber” character (a piece of wood with “googly” eyes glued onto it) that could not make it up a hill in two tries. Then the infants were shown two scenarios for the climber’s next try, one where the climber was pushed to the top of the hill by another character (the “helper” toy) and one where the climber was pushed back down the hill by another character (the “hinderer” toy). The infant was alternately shown these two scenarios several times. Then the child was presented with both pieces of wood (the helper and the hinderer characters) and asked to pick one to play with. Videos demonstrating this component of the study can be found at https://campuspress.yale.edu/infantlab/media/.
Usage
Infant
Format
Infant
A data frame with 16 rows and 1 column:
- choice
Whether a baby selected the "helper" or "hinderer" toy.
Source
https://pubmed.ncbi.nlm.nih.gov/18033298/
Sleep Deprivation Data
Description
Researchers have established that sleep deprivation has a harmful effect on visual learning (the subject does not consolidate information to improve on the task). Stickgold, James, and Hobson (2000) investigated whether subjects could “make up” for sleep deprivation by getting a full night’s sleep in subsequent nights. This study involved randomly assigning 21 subjects (volunteers between the ages of 18 and 25) to one of two groups: one group was deprived of sleep on the night following training with a visual discrimination task, and the other group was permitted unrestricted sleep on that first night. Both groups were allowed unrestricted sleep on the following two nights, and then were re-tested on the third day. Subjects’ performance on the test was recorded as the minimum time (in milliseconds) between stimuli appearing on a computer screen for which they could accurately report what they had seen on the screen. Previous studies had shown that subjects deprived of sleep performed significantly worse the following day, but it was not clear how long these negative effects would last. The data presented here are the improvements in reaction times (in milliseconds), so a negative value indicates a decrease in performance.
Usage
SleepDeprivation
Format
SleepDeprivation
A data frame with 21 rows and 2 columns:
- sleepcondition
The sleep condition the subject was in.
- improvement
The subject's improvement in reaction times, measured in milliseconds.
Source
https://www.nature.com/articles/nn1200_1237
Elephant Walking Data
Description
Researchers Holdgate et al. (2016) studied walking behavior of elephants in North American zoos to see whether there is a difference in average distance traveled by African and Asian elephants in captivity. They put GPS loggers on 33 African elephants and 23 Asian elephants, and measured the distance (in kilometers) the elephants walked per day.
Usage
elephants
Format
Elephants
A data frame with 56 rows and 2 columns:
- Species
What species this Elephant was.
- Distance
How many kilometers they walked per day.
Source
doi:10.1371/journal.pone.0150331
Overlay an Exponential Density Function on Histogram
Description
addexp creates a histogram of x and overlays an exponential density
function with \lambda = \frac{1}{mean}.
Usage
iscamaddexp(
x,
main = "Histogram with exponential curve",
xlab = deparse(substitute(x)),
bins = NULL
)
Arguments
x |
A numeric vector representing the data to be plotted. |
main |
Optional title for the plot |
xlab |
Optional x-axis label for the plot |
bins |
Optional number of bins for the histogram. |
Value
A histogram of x overlayed with an exponential density function.
Examples
set.seed(0)
x <- rexp(100, rate = 0.5)
iscamaddexp(x)
iscamaddexp(x, main = "Your Active Title", xlab = "Exponential Data", bins = 20)
Overlay a Log Normal Density Function on Histogram
Description
addlnorm creates a histogram of x and overlays a log normal density function.
Usage
iscamaddlnorm(
x,
main = "Histogram with log-normal curve",
xlab = deparse(substitute(x)),
bins = NULL
)
Arguments
x |
A numeric vector representing the data to be plotted. |
main |
Optional title for the plot |
xlab |
Optional x-axis label for the plot |
bins |
Optional number of bins for the histogram. |
Value
A histogram of x overlayed with an log normal density function.
Examples
set.seed(0)
x <- rlnorm(100)
iscamaddlnorm(x)
iscamaddlnorm(x, main = "Your Active Title", xlab = "Log Normal Data", bins = 20)
Overlay a Normal Density Function on Histogram
Description
addnorm creates a histogram of x and overlays a normal density function.
Usage
iscamaddnorm(
x,
main = "Histogram with normal curve",
xlab = deparse(substitute(x)),
bins = NULL
)
Arguments
x |
A numeric vector representing the data to be plotted. |
main |
Optional title for the plot |
xlab |
Optional x-axis label for the plot |
bins |
Optional number of bins for the histogram. |
Value
A histogram of x overlayed with an normal density function.
Examples
set.seed(0)
x <- rnorm(100)
iscamaddnorm(x)
iscamaddnorm(x, main = "Your Active Title", xlab = "Normal Data", bins = 20)
Overlay a t Density Function on Histogram
Description
Overlay a t Density Function on Histogram
Usage
iscamaddt(
x,
df,
main = "Histogram with t curve",
xlab = deparse(substitute(x)),
bins = NULL
)
Arguments
x |
A numeric vector representing the data to be plotted. |
df |
A numeric value representing the degrees of freedom of |
main |
Optional title for the plot |
xlab |
Optional x-axis label for the plot |
bins |
Optional number of bins for the histogram. |
Value
A histogram of x overlayed with an t density function.
Examples
set.seed(0)
x <- rt(100, 30)
iscamaddt(x, 30)
iscamaddt(x, 30, main = "Your Active Title", xlab = "t Data", bins = 20)
Overlay a t Density Function and a Normal Density Function on Histogram
Description
Overlay a t Density Function and a Normal Density Function on Histogram
Usage
iscamaddtnorm(
x,
df,
main = "Histogram with t and normal curve",
xlab = deparse(substitute(x)),
bins = NULL
)
Arguments
x |
A numeric vector representing the data to be plotted. |
df |
A numeric value representing the degrees of freedom of |
main |
Optional title for the plot |
xlab |
Optional x-axis label for the plot |
bins |
Optional number of bins for the histogram. |
Value
A histogram of x overlayed with an t density function and a normal density function.
Examples
set.seed(0)
x <- rt(100, 5)
iscamaddtnorm(x, 5)
iscamaddtnorm(x, 5, main = "Your Active Title", xlab = "t Data", bins = 20)
Overlays Normal Approximation onto Binomial
Description
binomnorm creates a binomial distribution of the given inputs and overlays a normal approximation.
Usage
iscambinomnorm(k, n, prob, direction, verbose = TRUE)
Arguments
k |
number of successes of interest |
n |
number of trials |
prob |
success probability |
direction |
"above", "below", or "two.sided" |
verbose |
Logical, defaults to |
Value
A plot of the binomial distribution overlayed with the normal approximation
Examples
iscambinomnorm(k = 10, n = 20, prob = 0.5, direction = "two.sided")
Rejection Region for Binomial
Description
binompower determines the rejection region corresponding to the level of
significance and the first probability and shows the binomial distribution
shading its corresponding region.
Usage
iscambinompower(LOS, n, prob1, alternative, prob2 = NULL, verbose = TRUE)
Arguments
LOS |
A numeric value representing the level of significance |
n |
A numeric value representing the sample size |
prob1 |
A numeric value representing the first probability |
alternative |
"less", "greater", or "two.sided" |
prob2 |
A numeric value representing the second probability |
verbose |
Logical, defaults to |
Value
A plot of the binomial distribution with the rejection region highlighted.
Examples
iscambinompower(LOS = 0.05, n = 20, prob1 = 0.5, alternative = "less")
iscambinompower(LOS = 0.05, n = 20, prob1 = 0.5, alternative = "greater", prob2 = 0.75)
iscambinompower(LOS = 0.10, n = 30, prob1 = 0.4, alternative = "two.sided")
iscambinompower(LOS = 0.10, n = 30, prob1 = 0.4, alternative = "two.sided", prob2 = 0.2)
Calculate Binomial Tail Probabilities
Description
binomprob calculates the probability of the number of success of interest
using a binomial distribution and plots the distribution.
Usage
iscambinomprob(k, n, prob, lower.tail, verbose = TRUE)
Arguments
k |
number of successes of interest. |
n |
number of trials. |
prob |
success probability. Numeric between 0 & 1. |
lower.tail |
Boolean for finding the probability above (FALSE) or below (TRUE) the inputted value (inclusive) |
verbose |
Logical, defaults to |
Value
The probability of the binomial distribution along with a graph of the distribution.
Examples
iscambinomprob(k = 5, n = 20, prob = 0.4, lower.tail = TRUE)
iscambinomprob(k = 15, n = 30, prob = 0.3, lower.tail = FALSE)
iscambinomprob(k = 22, n = 25, prob = 0.9, lower.tail = TRUE)
Exact Binomial Test
Description
binomtest calculates performs an exact binomial test and graphs the
binomial distribution and/or binomial confidence interval.
Usage
iscambinomtest(
observed,
n,
hypothesized = NULL,
alternative,
conf.level = NULL,
verbose = TRUE
)
Arguments
observed |
The observed number of successes or sample proportion (assumed to be proportion if value less than one.) |
n |
number of trials. |
hypothesized |
hypothesized probability of success. |
alternative |
"less", "greater", or "two.sided" |
conf.level |
Confidence level for a two-sided confidence interval. |
verbose |
Logical, defaults to |
Value
a list of the p-value along with lower and upper bound for the calculated confidence interval.
Examples
iscambinomtest(
observed = 17,
n = 25,
hypothesized = 0.5,
alternative = "greater"
)
iscambinomtest(
observed = 12,
n = 80,
hypothesized = 0.10,
alternative = "two.sided",
conf.level = 0.95
)
iscambinomtest(
observed = 0.14,
n = 100,
hypothesized = 0.20,
alternative = "less"
)
iscambinomtest(observed = 17, n = 25, conf.level = 0.95)
iscambinomtest(observed = 12, n = 80, conf.level = c(0.90, 0.95, 0.99))
A box plot
Description
boxplot plots the given data in a box plot. If a second categorical variable
is given, the data is grouped by this variable.
Usage
iscamboxplot(
response,
explanatory = NULL,
main = "",
xlab = "",
ylab = substitute(explanatory)
)
Arguments
response |
Vector of numeric values to plot. |
explanatory |
Optional second categorical variable to group by. |
main |
Optional title for the plot |
xlab |
Optional x-axis label for the plot |
ylab |
Optional y-axis label for the plot. Only displayed when |
Value
A box plot.
Examples
iscamboxplot(
mtcars$mpg,
main = "mtcars Cylinders Dotplot",
xlab = "Number of Cylinders"
)
iscamboxplot(
mtcars$mpg,
mtcars$am,
main = "Automatic Cars Have Better Mileage on Average",
xlab = "Mileage (miles per gallon)",
ylab = "Automatic (yes coded as 1)"
)
Chi-Square Probability
Description
chisqrprob returns the upper tail probability for the given chi-square
statistic and degrees of freedom.
Usage
iscamchisqprob(xval, df, verbose = TRUE)
Arguments
xval |
the value of the chi-square statistic. |
df |
the degrees of freedom. |
verbose |
Logical, defaults to |
Value
The upper tail probability for the chi-square distribution, and a plot of the chi-square distribution with the statistic and more extreme shaded.
Examples
iscamchisqprob(5, 3)
A dot plot
Description
dotplot creates a horizontal dot plot. If a second categorical variable is
given, the data is grouped by this variable. Use names & mytitle to
specify the labels and title.
Usage
iscamdotplot(
response,
explanatory = NULL,
main = "",
xlab = substitute(response),
ylab = substitute(explanatory)
)
Arguments
response |
Vector of numeric values to plot. |
explanatory |
Optional second categorical variable to group by. |
main |
Optional title for the plot |
xlab |
Optional x-axis label for the plot |
ylab |
Optional y-axis label for the plot. Only displayed when |
Value
A dot plot.
Examples
iscamdotplot(
mtcars$cyl,
main = "mtcars Cylinders Dotplot",
xlab = "Number of Cylinders"
)
iscamdotplot(
mtcars$mpg,
mtcars$am,
main = "Automatic Cars Have Better Mileage on Average",
xlab = "Mileage (miles per gallon)",
ylab = "Automatic (yes coded as 1)"
)
Hypergeometric p-value and Distribution Overlaid with Normal Distribution
Description
Hypergeometric p-value and Distribution Overlaid with Normal Distribution
Usage
iscamhypernorm(k, total, succ, n, lower.tail, verbose = TRUE)
Arguments
k |
Number of successes of interest or difference in conditional proportions |
total |
Total number of observations in the study |
succ |
Overall number of successes |
n |
Number of observations in group A |
lower.tail |
Boolean for finding the probability above (FALSE) or below (TRUE) the inputted value (inclusive) |
verbose |
Logical, defaults to |
Value
Tail probabilities from the hypergeometric distribution, hypergeometric distribution with normal distribution overlayed with the observed statistic and more extreme shaded.
Examples
iscamhypernorm(1, 20, 5, 10, TRUE)
Hypergeometric p-value and Distribution
Description
Hypergeometric p-value and Distribution
Usage
iscamhyperprob(k, total, succ, n, lower.tail, verbose = TRUE)
Arguments
k |
Number of successes of interest or difference in conditional proportions |
total |
Total number of observations in the study |
succ |
Overall number of successes |
n |
Number of observations in group A |
lower.tail |
Boolean for finding the probability above (FALSE) or below (TRUE) the inputted value (inclusive) |
verbose |
Logical, defaults to |
Value
Tail probabilities from the hypergeometric distribution, hypergeometric distribution with the observed statistic and more extreme shaded.
Examples
iscamhyperprob(1, 20, 5, 10, TRUE)
Inverse Binomial Probability
Description
Inverse Binomial Probability
Usage
iscaminvbinom(alpha, n, prob, lower.tail, verbose = TRUE)
Arguments
alpha |
The probability of interest. |
n |
The number of trials. |
prob |
The probability of success. |
lower.tail |
Boolean for finding the probability above (FALSE) or below (TRUE) the inputted value (inclusive) |
verbose |
Logical, defaults to |
Value
numeric which achieves at most the stated probability
Examples
iscaminvbinom(alpha = 0.05, n = 30, prob = 0.5, lower.tail = TRUE)
iscaminvbinom(alpha = 0.05, n = 30, prob = 0.5, lower.tail = FALSE)
iscaminvbinom(alpha = 0.01, n = 60, prob = 0.10, lower.tail = FALSE)
Inverse Normal Calculation
Description
Inverse Normal Calculation
Usage
iscaminvnorm(prob1, mean = 0, sd = 1, Sd = sd, direction, verbose = TRUE)
Arguments
prob1 |
probability to find normal quantile of. |
mean |
mean of normal distribution. |
sd |
standard deviation of normal distribution. |
Sd |
deprecated–available for backwards compatibility. |
direction |
direction for probability calculation: "above", "below", "outside", "between". |
verbose |
Logical, defaults to |
Value
a plot of the normal distribution with the quantile of the specified probability highlighted.
Examples
iscaminvnorm(0.05, direction = "below")
iscaminvnorm(0.90, mean = 100, sd = 15, direction = "above")
iscaminvnorm(0.10, direction = "outside")
iscaminvnorm(0.95, direction = "between")
Inverse T Calculation
Description
invt calculates the t quantile of a specified probability.
Usage
iscaminvt(prob, df, direction, verbose = TRUE)
Arguments
prob |
Desired probability. |
df |
Degrees of freedom |
direction |
direction for probability calculation: "above", "below", "outside", "between". |
verbose |
Logical, defaults to |
Value
The t value for the specified probability.
Examples
iscaminvt(0.05, df = 15, direction = "below")
iscaminvt(0.10, df = 25, direction = "above")
iscaminvt(0.95, df = 30, direction = "between")
iscaminvt(0.05, df = 20, direction = "outside")
Rejection Region for Normal
Description
normpower determines the rejection region corresponding to the level of
significance and the first probability and shows the normal distribution
shading its corresponding region.
Usage
iscamnormpower(LOS, n, prob1, alternative, prob2, verbose = TRUE)
Arguments
LOS |
A numeric value representing the level of significance; 0 < |
n |
A numeric value representing the sample size |
prob1 |
A numeric value representing the first probability |
alternative |
"less", "greater", or "two.sided" |
prob2 |
A numeric value representing the second probability |
verbose |
Logical, defaults to |
Value
A plot of the normal distribution with the rejection region highlighted.
Examples
iscamnormpower(0.05, n = 100, prob1 = 0.5, alternative = "greater", prob2 = 0.6)
iscamnormpower(0.10, n = 50, prob1 = 0.25, alternative = "less", prob2 = 0.15)
iscamnormpower(0.05, n = 200, prob1 = 0.8, alternative = "two.sided", prob2 = 0.7)
Normal Tail Probability
Description
normprob finds a p-value and plots it onto a normal distribution with mean
and standard deviation as specified. The function can find the probability
above, below, between, or outside of the observed value, as specified by
directions.
Usage
iscamnormprob(
xval,
mean = 0,
sd = 1,
direction,
label = NULL,
xval2 = NULL,
digits = 4,
verbose = TRUE
)
Arguments
xval |
observed value. |
mean |
mean of normal distribution. |
sd |
standard deviation of normal distribution. |
direction |
direction for probability calculation, "above" or "below"; if
"outside" or "between" are used, a second larger observation, |
label |
horizontal axis label. |
xval2 |
second observation value. |
digits |
number of digits to display. |
verbose |
Logical, defaults to |
Value
a p-value and a plot of the normal distribution with shaded area representing probability of the observed value or more extreme occurring.
Examples
iscamnormprob(1.96, direction = "above")
iscamnormprob(-1.5, mean = 1, sd = 2, direction = "below")
iscamnormprob(0, xval2 = 1.5, direction = "between")
iscamnormprob(-1, xval2 = 1, direction = "outside")
One Proportion Z-Test and Interval
Description
iscamonepropztest calculates a one-proportion z-test and/or a corresponding confidence interval.
Usage
iscamonepropztest(
observed,
n,
hypothesized = NULL,
alternative = "two.sided",
conf.level = NULL,
verbose = TRUE
)
Arguments
observed |
The observed number of successes. If a value less than 1 is provided, it is assumed to be the sample proportion. |
n |
The sample size. |
hypothesized |
The hypothesized probability of success under the null hypothesis. This is an optional parameter. |
alternative |
A character string specifying the form of the alternative hypothesis. Must be one of "less", "greater", or "two.sided". This is an optional parameter. |
conf.level |
The confidence level(s) for a two-sided confidence interval. This is an optional parameter. |
verbose |
Logical, defaults to |
Value
This function prints the results of the one-proportion z-test and/or the confidence interval. It also generates plots to visualize the test and interval.
Examples
iscamonepropztest(observed = 35, n = 50, hypothesized = 0.5)
iscamonepropztest(
observed = 0.8,
n = 100,
hypothesized = 0.75,
alternative = "greater",
conf.level = 0.95
)
iscamonepropztest(observed = 60, n = 100, conf.level = 0.90)
One Sample T-Test
Description
onesamplet calculates a one sample t-test and/or interval from summary statistics.
It defaults to a hypothesized population mean of 0. You can optionally set an
alternative hypothesis and confidence level for a two-sided confidence interval.
Usage
iscamonesamplet(
xbar,
sd,
n,
hypothesized = 0,
alternative = NULL,
conf.level = NULL,
verbose = TRUE
)
Arguments
xbar |
Observed mean. |
sd |
Observed standard deviation. |
n |
Sample size. |
hypothesized |
Hypothesized population mean. |
alternative |
"less", "greater", or "two.sided" |
conf.level |
Confidence level. |
verbose |
Logical, defaults to |
Value
The t value, p value, and confidence interval.
Examples
iscamonesamplet(
xbar = 2.5,
sd = 1.2,
n = 30,
alternative = "greater",
hypothesized = 2
)
iscamonesamplet(
xbar = 10.3,
sd = 2,
n = 50,
alternative = "less",
hypothesized = 11
)
iscamonesamplet(
xbar = 98.2,
sd = 2,
n = 100,
alternative = "two.sided",
conf.level = 0.95
)
iscamonesamplet(xbar = 55, sd = 5, n = 40, conf.level = 0.99)
Some Summary Statistics
Description
summary calculates the five number summary, mean, and standard
deviation of the quantitative variable x. An optional second, categorical
variable can be specified and values will be calculated separately for
each group. The number of digits in output can also be specified. Skewness is
sample skewness: g_1 := \frac{m_3}{m_2^{3/2}}, where
m_2 := \frac{1}{n}\sum_{i=1}^{n}(x_i - \bar{x})^2
and m_3 := \frac{1}{n}\sum_{i=1}^{n}(x_i - \bar{x})^3 are the second
and third central sample moments.
Usage
iscamsummary(x, explanatory = NULL, digits = 3)
Arguments
x |
data to summarize. |
explanatory |
optional explanatory variable to group by. |
digits |
number of digits to round to. |
Value
A table with some summary statistics of x.
Examples
set.seed(0)
fake_data <- rnorm(30) # simulating some data
groups <- sample(c("group1","group2"), 30, TRUE)
iscamsummary(fake_data)
iscamsummary(fake_data, explanatory = groups, digits = 2) # with groups
Tail Probability for t-distribution
Description
Tail Probability for t-distribution
Usage
iscamtprob(xval, df, direction, xval2 = NULL, verbose = TRUE)
Arguments
xval |
observed value. |
df |
degrees of freedom. |
direction |
direction for probability calculation, "above" or "below"; if
"outside" or "between" are used, a second larger observation, |
xval2 |
second observation value. |
verbose |
Logical, defaults to |
Value
The tail probability in the specified direction using the given parameters.
Examples
iscamtprob(xval = -2.05, df = 10, direction = "below")
iscamtprob(xval = 1.80, df = 20, direction = "above")
iscamtprob(xval = -2, xval2 = 2, df = 15, direction = "between")
iscamtprob(xval = -2.5, xval2 = 2.5, df = 25, direction = "outside")
Two Proportion Z-Test and Interval
Description
iscamtwopropztest calculates a two-proportion z-test and/or a corresponding confidence interval.
Usage
iscamtwopropztest(
observed1,
n1,
observed2,
n2,
hypothesized = 0,
alternative = NULL,
conf.level = NULL,
datatable = NULL,
verbose = TRUE
)
Arguments
observed1 |
The observed number of successes in group 1. If a value less than 1 is provided, it is assumed to be the sample proportion. |
n1 |
The sample size for group 1. |
observed2 |
The observed number of successes in group 2. If a value less than 1 is provided, it is assumed to be the sample proportion. |
n2 |
The sample size for group 2. |
hypothesized |
The hypothesized difference in probability of success under the null hypothesis. This is an optional parameter. |
alternative |
A character string specifying the form of the alternative hypothesis. Must be one of "less", "greater", or "two.sided". This is an optional parameter. |
conf.level |
The confidence level(s) for a two-sided confidence interval. This is an optional parameter. |
datatable |
A two-way table of counts as an alternative input method. This is an optional parameter. |
verbose |
Logical, defaults to |
Value
This function prints the results of the two-proportion z-test and/or the confidence interval. It also generates plots to visualize the test and interval.
Examples
iscamtwopropztest(observed1 = 35, n1 = 50, observed2 = 28, n2 = 45)
iscamtwopropztest(
observed1 = 0.8,
n1 = 100,
observed2 = 0.6,
n2 = 80,
hypothesized = 0,
alternative = "greater",
conf.level = 0.95
)
iscamtwopropztest(observed1 = 60, n1 = 100, observed2 = 45, n2 = 90, conf.level = 0.90)
Two Sample T-Test
Description
twosamplet calculates a two sample t-test and/or interval from summary data.
It defaults to a hypothesized population mean difference of 0. You can
optionally set an alternative hypothesis and confidence level for a two-sided
confidence interval.
Usage
iscamtwosamplet(
x1,
sd1,
n1,
x2,
sd2,
n2,
hypothesized = 0,
alternative = NULL,
conf.level = 0,
verbose = TRUE
)
Arguments
x1 |
Observed mean for group 1. |
sd1 |
Observed standard deviation for group 1. |
n1 |
Sample size for group 1. |
x2 |
Observed mean for group 2. |
sd2 |
Observed standard deviation for group 2. |
n2 |
Sample size for group 2. |
hypothesized |
Hypothesized difference in population means. |
alternative |
"less", "greater", or "two.sided" |
conf.level |
Confidence level. |
verbose |
Logical, defaults to |
Value
The t value, p value, and confidence interval.