Learn R Programming

safestats (version 0.8.7)

safeTTest: 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, ... )

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.

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 designSafeT(), or NULL, when pilot equals TRUE.

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 TRUE.

pilot

a logical indicating whether a pilot study is run. If TRUE, it is assumed that the number of samples is exactly as planned.

alpha

numeric > 0 only used if pilot equals TRUE. If pilot equals FALSE, then the alpha of the design object is used instead in constructing the decision rule S > 1/alpha.

alternative

a character only used if pilot equals TRUE. If pilot equals FALSE, then the alternative specified by the design object is used instead.

ciValue

numeric is the ciValue-level of the confidence sequence. Default ciValue=NULL, and ciValue = 1 - alpha

na.rm

a logical value indicating whether NA values should be stripped before the computation proceeds.

...

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 TRUE.

Examples

Run this code
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

Run the code above in your browser using DataLab