ttest_num: ttest_num

View source: R/ttest_num.R

ttest_numR Documentation

ttest_num

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 population normal distributed (default: FALSE)

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

  • t2norm does the approxmation t_n \approx N(0;1) hold? ⁠(default: ⁠NA⁠= use⁠t2norm' function)

Usage

ttest_num(..., arglist = NULL)

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 statístic 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.

Value

a list with the input parameters and

  • 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

Examples

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)

sigbertklinke/exams2moodle documentation built on July 6, 2023, 3:26 p.m.