Learn R Programming

seqtest (version 0.1-0)

seqtest.prop: Sequential triangular test for the proportion

Description

This function performs the sequential triangular test for the proportion in one- or two-samples

Usage

seqtest.prop(x, y = NULL, pi = NULL, alternative = c("two.sided", "less", "greater"),
             delta, alpha = 0.05, beta = 0.1, output = TRUE, plot = FALSE)

Arguments

x
initial data for group x, at least one entry.
y
initial data for group y, at least one entry for a two-sample test.
pi
a number indicating the true value of the probability of success in group x, $\pi$.0.
alternative
a character string specifying the alternative hypothesis, must be one of "two.sided" (default), "less" or "greater".
delta
minimum difference to be detected, $\delta$.
alpha
type-I-risk, $\alpha$.
beta
type-II-risk, $\beta$.
output
logical: if TRUE, output is shown.
plot
logical: if TRUE, a plot is generated.

Value

  • Returns an object of class seqtest, to be used for later update steps. The object has following entries: ll{ call function call type type of the test (i.e., proportion) spec specification of function arguments tri specification of the triangular dat data res list with results }

Details

For the one-sample test, arguments x, pi, and delta has to be specified (i.e., argument y must not be specified). For the two-sample test, arguments x, y, pi, and delta has to be specified In order to specify a one-sided test, argument alternative has to be used (i.e., two-sided tests are conducted by default). For the one-sample test, alternative = "less" specifies the null hypothesis, H0: $\pi$ >= $\pi$.0 and the alternative hypothesis, H1: $\pi$ < $\pi$.0; alternative = "greater" specifies the null hypothesis, H0: $\pi$ <= $\pi$.0="" and="" the="" alternative="" hypothesis,="" h1:="" $\pi$=""> $\pi$.0. For the two-sample test alternative = "less" specifies the null hypothesis, H0: $\pi$.1 >= $\pi$.2 and the alternative hypothesis, H1: $\pi$.1 < $\pi$.2; alternative = "greater" specifies the null hypothesis, H0: $\pi$.1 <= $\pi$.2="" and="" the="" alternative="" hypothesis,="" h1:="" $\pi$.1=""> $\pi$.2. The main characteristic of the sequential triangular test is that there is no fixed sample size given in advance. That is, for the most recent sampling point, one has to decide whether sampling has to be continued or either the null- or the alternative hypothesis can be accepted given specified precision requirements (i.e. type-I-risk, type-II-risk and an effect size). The (cumulative) test statistic Z.m on a Cartesian coordinate system produces a "sequential path" on a continuation area as a triangle. As long as the statistic remains within that triangle, additional data have to be sampled. If the path touches or exceeds the borderlines of the triangle, sampling is completed. Depending on the particular borderline, the null-hypothesis is either accepted or rejected.

References

Rasch, D., Pilz, J., Verdooren, L. R., & Gebhardt, G. (2011). Optimal experimental design with R. Boca Raton: Chapman & Hall/CRC. Rasch, D., Kubinger, K. D., & Yanagida, T. (2011). Statistics in psychology - Using R and SPSS. New York: John Wiley & Sons.

See Also

update.seqtest, seqtest.mean, seqtest.cor, print.seqtest, plot.seqtest, descript

Examples

Run this code
#--------------------------------------
# Two-sided one-sample test
# H0: pi = 0.5, H1: pi != 0.5
# alpha = 0.05, beta = 0.2, delta = 0.2

seq.obj <- seqtest.prop(c(1, 1, 0, 1), pi = 0.5, delta = 0.2,
                        alpha = 0.05, beta = 0.2, plot = TRUE)

seq.obj <- update(seq.obj, x = c(1, 1, 1, 1, 1, 0, 1, 1, 1))
seq.obj <- update(seq.obj, x = c(0, 1, 1, 1))
seq.obj <- update(seq.obj, x = c(1, 1))

#--------------------------------------
# One-sided one-sample test
# H0: pi <= 0.5, H1: pi > 0.5
# alpha = 0.05, beta = 0.2, delta = 0.2

seq.obj <- seqtest.prop(c(1, 1, 0, 1), pi = 0.5,
                        alternative = "greater", delta = 0.2,
                        alpha = 0.05, beta = 0.2, plot = TRUE)

seq.obj <- update(seq.obj, x = c(1, 1, 1, 1, 1, 0, 1, 1, 1))
seq.obj <- update(seq.obj, x = c(0, 1, 1, 1))

#--------------------------------------
# Two-sided two-sample test
# H0: pi.1 = pi.2 = 0.5, H1: pi.1 != pi.2
# alpha = 0.01, beta = 0.1, delta = 0.2

seq.obj <- seqtest.prop(1, 0, pi = 0.5, delta = 0.2,
                        alpha = 0.01, beta = 0.1, plot = TRUE)

seq.obj <- update(seq.obj, x = c(1, 1, 1, 0), y = c(0, 0, 1, 0))
seq.obj <- update(seq.obj, x = c(0, 1, 1, 1), y = c(0, 0, 0, 0))
seq.obj <- update(seq.obj, x = c(1, 0, 1, 1), y = c(0, 0, 0, 1))
seq.obj <- update(seq.obj, x = c(1, 1, 1, 1), y = c(0, 0, 0, 0))
seq.obj <- update(seq.obj, x = c(0, 1, 0, 1))
seq.obj <- update(seq.obj, y = c(0, 0, 0, 1))
seq.obj <- update(seq.obj, x = c(1, 1, 1, 1))

#--------------------------------------
# One-sided two-sample test
# H0: pi.1 <=  pi.1 = 0.5, H1: pi.1 > pi.2
# alpha = 0.01, beta = 0.1, delta = 0.2

seq.obj <- seqtest.prop(1, 0, pi = 0.5, delta = 0.2,
                        alternative = "greater",
                        alpha = 0.01, beta = 0.1, plot = TRUE)

seq.obj <- update(seq.obj, x = c(1, 1, 1, 0), y = c(0, 0, 1, 0))
seq.obj <- update(seq.obj, x = c(0, 1, 1, 1), y = c(0, 0, 0, 0))
seq.obj <- update(seq.obj, x = c(1, 0, 1, 1), y = c(0, 0, 0, 1))
seq.obj <- update(seq.obj, x = c(1, 1, 1), y = c(0, 0))

Run the code above in your browser using DataLab