# Sequential triangular test for the proportion

### Description

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

### Usage

1 2 |

### 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, |

`alternative` |
a character string specifying the alternative hypothesis, must be one of "two.sided" (default), "less" or "greater". |

`delta` |
minimum difference to be detected, |

`alpha` |
type-I-risk, |

`beta` |
type-II-risk, |

`output` |
logical: if |

`plot` |
logical: if |

### 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: *π* >= *π*.0
and the alternative hypothesis, H1: *π* < *π*.0; `alternative = "greater"`

specifies the
null hypothesis, H0: *π* <= *π*.0 and the alternative hypothesis, H1: *π* > *π*.0.
For the two-sample test `alternative = "less"`

specifies the null hypothesis, H0: *π*.1 >= *π*.2
and the alternative hypothesis, H1: *π*.1 < *π*.2; `alternative = "greater"`

specifies
the null hypothesis, H0: *π*.1 <= *π*.2 and the alternative hypothesis, H1: *π*.1 > *π*.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.

### Value

Returns an object of class `seqtest`

, to be used for later update steps. The object has
following entries:

`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 |

### Author(s)

Takuya Yanagida takuya.yanagida@univie.ac.at,

### 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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | ```
#--------------------------------------
# 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))
``` |