Learn R Programming

exams.forge (version 1.0.10)

ttest_num: T-tests

Description

Computes all results for a t-test. Note that the results may differ from stats::t.test(), see the "Details". Either named parameters can be given, or a list with the parameters. You must provide either x or mean, sd and n. If x is given then any values given for mean, sd and n will be overwritten. Also either sd or sigma or both must be given.

  • x sample (default: numeric(0))

  • mean sample mean (default: mean(x))

  • n sample size (default: length(x))

  • sd sample standard deviation (default: sd(x))

  • sigma population standard deviation (default: NA = unknown)

  • mu0 true value of the mean (default: 0)

  • alternative a string specifying the alternative hypothesis (default: "two.sided"), otherwise "greater" or "less" can be used

  • alpha significance level (default: 0.05)

  • norm is the population normal distributed? (default: FALSE)

  • n.clt when the central limit theorem holds (default: getOption("n.clt", 30))

  • t2norm does the approximation \(t_n \approx N(0;1)\) hold? (default: NA= uset2norm` function)

Usage

ttest_num(..., arglist = NULL)

Value

A list with the input parameters and the following:

  • Xbar distribution of the random sampling function \(\bar{X}\), only available if sigma given

  • Statistic distribution of the test statistics

  • statistic test value

  • critical critical value(s)

  • criticalx critical value(s) in x range

  • acceptance0 acceptance interval for H0

  • acceptance0x acceptance interval for H0 in x range

  • accept1 is H1 accepted?

  • p.value p value for test

Arguments

...

named input parameters

arglist

list: named input parameters, if given ... will be ignored

Details

The results of ttest_num may differ from stats::t.test(). ttest_num is designed to return results when you compute a t-test by hand. For example, for computing the test statistic the approximation \(t_n \approx N(0; 1)\) is used if \(n>n.tapprox\). The p.value is computed from the cumulative distribution function of the normal or the t distribution.

Examples

Run this code
x <- runif(100)
ttest_num(x=x)
ttest_num(mean=mean(x), sd=sd(x), n=length(x))
ret <- ttest_num(x=x)
ret$alternative <- "less"
ttest_num(arglist=ret)

Run the code above in your browser using DataLab