safeTTest {safestats} | R Documentation |
Safe Student's T-Test.
Description
A safe t-test adapted from t.test()
to perform one and two sample t-tests on vectors of data.
Usage
safeTTest(
x,
y = NULL,
designObj = NULL,
paired = FALSE,
varEqual = TRUE,
pilot = FALSE,
alpha = NULL,
alternative = NULL,
ciValue = NULL,
na.rm = FALSE,
...
)
safe.t.test(
x,
y = NULL,
designObj = NULL,
paired = FALSE,
var.equal = TRUE,
pilot = FALSE,
alpha = NULL,
alternative = NULL,
...
)
Arguments
x |
a (non-empty) numeric vector of data values. |
y |
an optional (non-empty) numeric vector of data values. |
designObj |
an object obtained from |
paired |
a logical indicating whether you want a paired t-test. |
varEqual |
a logical variable indicating whether to treat the two variances as being equal. For
the moment, this is always |
pilot |
a logical indicating whether a pilot study is run. If |
alpha |
numeric > 0 only used if pilot equals |
alternative |
a character only used if pilot equals |
ciValue |
numeric is the ciValue-level of the confidence sequence. Default ciValue=NULL, and ciValue = 1 - alpha |
na.rm |
a logical value indicating whether |
... |
further arguments to be passed to or from methods. |
var.equal |
a logical variable indicating whether to treat the two variances as being equal. For the moment,
this is always |
Value
Returns an object of class "safeTest". An object of class "safeTest" is a list containing at least the following components:
- statistic
the value of the t-statistic.
- n
The realised sample size(s).
- eValue
the realised e-value from the safe test.
- confSeq
A safe confidence interval for the mean appropriate to the specific alternative hypothesis.
- estimate
the estimated mean or difference in means or mean difference depending on whether it a one- sample test or a two-sample test was conducted.
- stderr
the standard error of the mean (difference), used as denominator in the t-statistic formula.
- testType
any of "oneSample", "paired", "twoSample" provided by the user.
- dataName
a character string giving the name(s) of the data.
- designObj
an object of class "safeTDesign" obtained from
designSafeT()
.- call
the expression with which this function is called.
Examples
designObj <- designSafeT(deltaMin=0.6, alpha=0.008, alternative="greater",
testType="twoSample", ratio=1.2)
set.seed(1)
x <- rnorm(100)
y <- rnorm(100)
safeTTest(x, y, designObj=designObj) #0.2959334
safeTTest(1:10, y = c(7:20), pilot=TRUE) # s = 658.69 > 1/alpha
designObj <- designSafeT(deltaMin=0.6, alpha=0.008, alternative="greater",
testType="twoSample", ratio=1.2)
set.seed(1)
x <- rnorm(100)
y <- rnorm(100)
safe.t.test(x, y, alternative="greater", designObj=designObj) #0.2959334
safe.t.test(1:10, y = c(7:20), pilot=TRUE) # s = 658.69 > 1/alpha