| Title: | 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 (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. |
| Authors: | Beth Chance [cre, aut, cph], Visruth Srimath Kandali [aut] (ORCID: <https://orcid.org/0009-0005-9097-0688>) |
| Maintainer: | Beth Chance <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 1.2.0.9000 |
| Built: | 2026-05-12 08:39:55 UTC |
| Source: | https://github.com/iscam4/iscam |
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.
CloudSeedingCloudSeeding
CloudSeedingA data frame with 52 rows and 2 columns:
Whether a cloud was seeded with silver iodide or not.
Volume of rainfall during the next 24 hours, in acre-feet.
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.
elephantselephants
ElephantsA data frame with 56 rows and 2 columns:
What species this Elephant was.
How many kilometers they walked per day.
doi:10.1371/journal.pone.0150331
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.
FlintMDEQFlintMDEQ
flintA data frame with 71 rows and 1 column:
Lead concentration per household, measured in parts per billion.
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/.
InfantInfant
InfantA data frame with 16 rows and 1 column:
Whether a baby selected the "helper" or "hinderer" toy.
https://pubmed.ncbi.nlm.nih.gov/18033298/
addexp creates a histogram of x and overlays an exponential density
function with .
iscamaddexp( x, main = "Histogram with exponential curve", xlab = deparse(substitute(x)), bins = NULL )iscamaddexp( x, main = "Histogram with exponential curve", xlab = deparse(substitute(x)), bins = NULL )
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. |
A histogram of x overlayed with an exponential density function.
set.seed(0) x <- rexp(100, rate = 0.5) iscamaddexp(x) iscamaddexp(x, main = "Your Active Title", xlab = "Exponential Data", bins = 20)set.seed(0) x <- rexp(100, rate = 0.5) iscamaddexp(x) iscamaddexp(x, main = "Your Active Title", xlab = "Exponential Data", bins = 20)
addlnorm creates a histogram of x and overlays a log normal density function.
iscamaddlnorm( x, main = "Histogram with log-normal curve", xlab = deparse(substitute(x)), bins = NULL )iscamaddlnorm( x, main = "Histogram with log-normal curve", xlab = deparse(substitute(x)), bins = NULL )
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. |
A histogram of x overlayed with an log normal density function.
set.seed(0) x <- rlnorm(100) iscamaddlnorm(x) iscamaddlnorm(x, main = "Your Active Title", xlab = "Log Normal Data", bins = 20)set.seed(0) x <- rlnorm(100) iscamaddlnorm(x) iscamaddlnorm(x, main = "Your Active Title", xlab = "Log Normal Data", bins = 20)
addnorm creates a histogram of x and overlays a normal density function.
iscamaddnorm( x, main = "Histogram with normal curve", xlab = deparse(substitute(x)), bins = NULL )iscamaddnorm( x, main = "Histogram with normal curve", xlab = deparse(substitute(x)), bins = NULL )
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. |
A histogram of x overlayed with an normal density function.
set.seed(0) x <- rnorm(100) iscamaddnorm(x) iscamaddnorm(x, main = "Your Active Title", xlab = "Normal Data", bins = 20)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
iscamaddt( x, df, main = "Histogram with t curve", xlab = deparse(substitute(x)), bins = NULL )iscamaddt( x, df, main = "Histogram with t curve", xlab = deparse(substitute(x)), bins = NULL )
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. |
A histogram of x overlayed with an t density function.
set.seed(0) x <- rt(100, 30) iscamaddt(x, 30) iscamaddt(x, 30, main = "Your Active Title", xlab = "t Data", bins = 20)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
iscamaddtnorm( x, df, main = "Histogram with t and normal curve", xlab = deparse(substitute(x)), bins = NULL )iscamaddtnorm( x, df, main = "Histogram with t and normal curve", xlab = deparse(substitute(x)), bins = NULL )
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. |
A histogram of x overlayed with an t density function and a normal density function.
set.seed(0) x <- rt(100, 5) iscamaddtnorm(x, 5) iscamaddtnorm(x, 5, main = "Your Active Title", xlab = "t Data", bins = 20)set.seed(0) x <- rt(100, 5) iscamaddtnorm(x, 5) iscamaddtnorm(x, 5, main = "Your Active Title", xlab = "t Data", bins = 20)
binomnorm creates a binomial distribution of the given inputs and overlays a normal approximation.
iscambinomnorm(k, n, prob, direction, verbose = TRUE)iscambinomnorm(k, n, prob, direction, verbose = TRUE)
k |
number of successes of interest |
n |
number of trials |
prob |
success probability |
direction |
"above", "below", or "two.sided" |
verbose |
Logical, defaults to |
A plot of the binomial distribution overlayed with the normal approximation
iscambinomnorm(k = 10, n = 20, prob = 0.5, direction = "two.sided")iscambinomnorm(k = 10, n = 20, prob = 0.5, direction = "two.sided")
binompower determines the rejection region corresponding to the level of
significance and the first probability and shows the binomial distribution
shading its corresponding region.
iscambinompower(LOS, n, prob1, alternative, prob2 = NULL, verbose = TRUE)iscambinompower(LOS, n, prob1, alternative, prob2 = NULL, verbose = TRUE)
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 |
A plot of the binomial distribution with the rejection region highlighted.
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)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)
binomprob calculates the probability of the number of success of interest
using a binomial distribution and plots the distribution.
iscambinomprob(k, n, prob, lower.tail, verbose = TRUE)iscambinomprob(k, n, prob, lower.tail, verbose = TRUE)
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 |
The probability of the binomial distribution along with a graph of the distribution.
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)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)
binomtest calculates performs an exact binomial test and graphs the
binomial distribution and/or binomial confidence interval.
iscambinomtest( observed, n, hypothesized = NULL, alternative, conf.level = NULL, verbose = TRUE )iscambinomtest( observed, n, hypothesized = NULL, alternative, conf.level = NULL, verbose = TRUE )
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 |
a list of the p-value along with lower and upper bound for the calculated confidence interval.
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))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))
boxplot plots the given data in a box plot. If a second categorical variable
is given, the data is grouped by this variable.
iscamboxplot( response, explanatory = NULL, main = "", xlab = "", ylab = substitute(explanatory) )iscamboxplot( response, explanatory = NULL, main = "", xlab = "", ylab = substitute(explanatory) )
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 |
A box plot.
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)" )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)" )
chisqrprob returns the upper tail probability for the given chi-square
statistic and degrees of freedom.
iscamchisqprob(xval, df, verbose = TRUE)iscamchisqprob(xval, df, verbose = TRUE)
xval |
the value of the chi-square statistic. |
df |
the degrees of freedom. |
verbose |
Logical, defaults to |
The upper tail probability for the chi-square distribution, and a plot of the chi-square distribution with the statistic and more extreme shaded.
iscamchisqprob(5, 3)iscamchisqprob(5, 3)
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.
iscamdotplot( response, explanatory = NULL, main = "", xlab = substitute(response), ylab = substitute(explanatory) )iscamdotplot( response, explanatory = NULL, main = "", xlab = substitute(response), ylab = substitute(explanatory) )
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 |
A dot plot.
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)" )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
iscamhypernorm(k, total, succ, n, lower.tail, verbose = TRUE)iscamhypernorm(k, total, succ, n, lower.tail, verbose = TRUE)
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 |
Tail probabilities from the hypergeometric distribution, hypergeometric distribution with normal distribution overlayed with the observed statistic and more extreme shaded.
iscamhypernorm(1, 20, 5, 10, TRUE)iscamhypernorm(1, 20, 5, 10, TRUE)
Hypergeometric p-value and Distribution
iscamhyperprob(k, total, succ, n, lower.tail, verbose = TRUE)iscamhyperprob(k, total, succ, n, lower.tail, verbose = TRUE)
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 |
Tail probabilities from the hypergeometric distribution, hypergeometric distribution with the observed statistic and more extreme shaded.
iscamhyperprob(1, 20, 5, 10, TRUE)iscamhyperprob(1, 20, 5, 10, TRUE)
Inverse Binomial Probability
iscaminvbinom(alpha, n, prob, lower.tail, verbose = TRUE)iscaminvbinom(alpha, n, prob, lower.tail, verbose = TRUE)
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 |
numeric which achieves at most the stated probability
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)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
iscaminvnorm(prob1, mean = 0, sd = 1, Sd = sd, direction, verbose = TRUE)iscaminvnorm(prob1, mean = 0, sd = 1, Sd = sd, direction, verbose = TRUE)
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 |
a plot of the normal distribution with the quantile of the specified probability highlighted.
iscaminvnorm(0.05, direction = "below") iscaminvnorm(0.90, mean = 100, sd = 15, direction = "above") iscaminvnorm(0.10, direction = "outside") iscaminvnorm(0.95, direction = "between")iscaminvnorm(0.05, direction = "below") iscaminvnorm(0.90, mean = 100, sd = 15, direction = "above") iscaminvnorm(0.10, direction = "outside") iscaminvnorm(0.95, direction = "between")
invt calculates the t quantile of a specified probability.
iscaminvt(prob, df, direction, verbose = TRUE)iscaminvt(prob, df, direction, verbose = TRUE)
prob |
Desired probability. |
df |
Degrees of freedom |
direction |
direction for probability calculation: "above", "below", "outside", "between". |
verbose |
Logical, defaults to |
The t value for the specified probability.
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")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")
normpower determines the rejection region corresponding to the level of
significance and the first probability and shows the normal distribution
shading its corresponding region.
iscamnormpower(LOS, n, prob1, alternative, prob2, verbose = TRUE)iscamnormpower(LOS, n, prob1, alternative, prob2, verbose = TRUE)
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 |
A plot of the normal distribution with the rejection region highlighted.
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)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)
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.
iscamnormprob( xval, mean = 0, sd = 1, direction, label = NULL, xval2 = NULL, digits = 4, verbose = TRUE )iscamnormprob( xval, mean = 0, sd = 1, direction, label = NULL, xval2 = NULL, digits = 4, verbose = TRUE )
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 |
a p-value and a plot of the normal distribution with shaded area representing probability of the observed value or more extreme occurring.
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")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")
iscamonepropztest calculates a one-proportion z-test and/or a corresponding confidence interval.
iscamonepropztest( observed, n, hypothesized = NULL, alternative = "two.sided", conf.level = NULL, verbose = TRUE )iscamonepropztest( observed, n, hypothesized = NULL, alternative = "two.sided", conf.level = NULL, verbose = TRUE )
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 |
(optional) hypothesized probability of success under the null hypothesis. |
alternative |
(optional) character string specifying the form of the alternative hypothesis. Must be one of "less", "greater", or "two.sided". |
conf.level |
(optional) confidence level(s) for a two-sided confidence interval. |
verbose |
Logical, defaults to |
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.
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)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)
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.
iscamonesamplet( xbar, sd, n, hypothesized = 0, alternative = NULL, conf.level = NULL, verbose = TRUE )iscamonesamplet( xbar, sd, n, hypothesized = 0, alternative = NULL, conf.level = NULL, verbose = TRUE )
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 |
The t value, p value, and confidence interval.
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)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)
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: , where
and are the second
and third central sample moments.
iscamsummary(x, explanatory = NULL, digits = 3)iscamsummary(x, explanatory = NULL, digits = 3)
x |
data to summarize. |
explanatory |
(optional) explanatory variable to group by. |
digits |
(optional) number of digits to round to, defaults to 3. |
A table with some summary statistics of x.
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 groupsset.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
iscamtprob(xval, df, direction, xval2 = NULL, verbose = TRUE)iscamtprob(xval, df, direction, xval2 = NULL, verbose = TRUE)
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 |
The tail probability in the specified direction using the given arguments.
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")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")
iscamtwopropztest calculates a two-proportion z-test and/or a corresponding confidence interval.
iscamtwopropztest( observed1, n1, observed2, n2, hypothesized = 0, alternative = NULL, conf.level = NULL, datatable = NULL, verbose = TRUE )iscamtwopropztest( observed1, n1, observed2, n2, hypothesized = 0, alternative = NULL, conf.level = NULL, datatable = NULL, verbose = TRUE )
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 |
(optional) hypothesized difference in probability of success under the null hypothesis. |
alternative |
(optional) character string specifying the form of the alternative hypothesis. Must be one of "less", "greater", or "two.sided". |
conf.level |
(optional) confidence level(s) for a two-sided confidence interval. |
datatable |
(optional) two-way table of counts as an alternative input method. |
verbose |
Logical, defaults to |
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.
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)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)
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.
iscamtwosamplet( x1, sd1, n1, x2, sd2, n2, hypothesized = 0, alternative = NULL, conf.level = 0, verbose = TRUE )iscamtwosamplet( x1, sd1, n1, x2, sd2, n2, hypothesized = 0, alternative = NULL, conf.level = 0, verbose = TRUE )
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 |
The t value, p value, and confidence interval.
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.
SleepDeprivationSleepDeprivation
SleepDeprivationA data frame with 21 rows and 2 columns:
The sleep condition the subject was in.
The subject's improvement in reaction times, measured in milliseconds.
https://www.nature.com/articles/nn1200_1237