Learn R Programming

safestats (version 0.8.7)

safeZTest: Safe Z-Test

Description

Safe one and two sample z-tests on vectors of data. The function is modelled after t.test().

Usage

safeZTest(
  x,
  y = NULL,
  paired = FALSE,
  designObj = NULL,
  pilot = FALSE,
  ciValue = NULL,
  tol = 1e-05,
  na.rm = FALSE,
  ...
)

safe.z.test( x, y = NULL, paired = FALSE, designObj = NULL, pilot = FALSE, tol = 1e-05, ... )

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 test statistic. Here the z-statistic.

n

The realised sample size(s).

eValue

the e-value of the safe test.

confInt

To be implemented: 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 was a one- sample test or a two-sample test.

h0

the specified hypothesised value of the mean or mean difference depending on whether it was a one-sample or a two-sample test.

testType

any of "oneSample", "paired", "twoSample" effectively provided by the user.

dataName

a character string giving the name(s) of the data.

designObj

an object of class "safeDesign" described in designSafeZ().

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.

paired

a logical indicating whether you want the paired z-test.

designObj

an object obtained from designSafeZ(), or NULL, when pilot is set to 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. The default null h0=1 is used, alpha=0.05, and alternative="twoSided" is used. To change these default values, please use designSafeZ().

ciValue

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

tol

numeric > 0, only used if pilot equals TRUE, as it then specifies the mesh used to find the test defining parameter to construct a pilot design object.

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.

Examples

Run this code

designObj <- designSafeZ(meanDiffMin=0.6, alpha=0.008,
                         alternative="greater", testType="twoSample",
                         ratio=1.2)

set.seed(1)
x <- rnorm(100)
y <- rnorm(100)
safeZTest(x, y, designObj=designObj)      #

safeZTest(1:10, y = c(7:20), pilot=TRUE, alternative="less")      # s = 7.7543e+20 > 1/alpha

Run the code above in your browser using DataLab