The sprtt
package is a sequential
probability ratio
tests toolbox
(sprtt).
The package contains:
seq_ttest()
, seq_anova()
calculates
sequential t-test and sequential one-way ANOVAs
three data sets (df_income
, df_stress
,
df_cancer
) to run the examples in the t-test
documentation
plot_anova()
plots results of sequential
ANOVAs
draw_sample_normal()
,
draw_sample_mixture()
simulation of data sets
This is the recommended version for a normal user.
# installs the package
install.packages("sprtt")
To get a bug fix or to use a feature from the development version, you can install the development version from GitHub.
# the installation requires the "devtools" package
# install.packages("devtools")
::install_github("MeikeSteinhilber/sprtt") devtools
Detailed documentation can be found on the home page. There are several articles covering the usage of the package, the theoretical background of the test, and also an extended use case.
Short examples can be found in the following paragraph.
Note
In the R code sections:
# comment
: is a comment
function()
: is R code
#> results of function()
: is console output
# set seed --------------------------------------------------------------------
set.seed(333)
# load library ----------------------------------------------------------------
library(sprtt)
# t-TEST ----------------------------------------------------------------------
# one sample: numeric input ---------------------------------------------------
<- rnorm(20, mean = 0, sd = 1)
treatment_group <- seq_ttest(treatment_group, mu = 1, d = 0.8)
results
# get access to the slots -----------------------------------------------------
# @ Operator
@likelihood_ratio
results#> [1] 965.0728
# [] Operator
"likelihood_ratio"]
results[#> [1] 965.0728
# ANOVA -----------------------------------------------------------------------
# simulate data ---------------------------------------------------------------
set.seed(333)
<- sprtt::draw_sample_normal(k_groups = 3,
data f = 0.25,
sd = c(1, 1, 1),
max_n = 25)
# calculate sequential ANOVA --------------------------------------------------
<- sprtt::seq_anova(y ~ x, f = 0.25, data = data, plot = TRUE)
results # test decision
@decision
results#> [1] "continue sampling"
# test results
results#>
#> ***** Sequential ANOVA *****
#>
#> formula: y ~ x
#> test statistic:
#> log-likelihood ratio = 2.892, decision = continue sampling
#> SPRT thresholds:
#> lower log(B) = -2.944, upper log(A) = 2.944
#> Log-Likelihood of the:
#> alternative hypothesis = -2.715
#> null hypothesis = -5.607
#> alternative hypothesis: true difference in means is not equal to 0.
#> specified effect size: Cohen's f = 0.25
#> empirical Cohen's f = 0.4045074, 95% CI[0.129478, 0.6171581]
#> Cohen's f adjusted = 0.355
#> degrees of freedom: df1 = 2, df2 = 72
#> SS effect = 10.74731, SS residual = 65.68208, SS total = 76.42939
#> *Note: to get access to the object of the results use the @ or [] instead of the $ operator.
# plot results -----------------------------------------------------------------
::plot_anova(results) sprtt