seq_ttest: Sequential Probability Ratio Test using t-statistic In sprtt: Sequential Probability Ratio Tests: Using t-Statistic

Description

Performs one and two sample sequential t-tests on vectors of data.

Usage

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13``` ```seq_ttest( x, y = NULL, data = NULL, mu = 0, d, alpha = 0.05, power = 0.95, alternative = "two.sided", paired = FALSE, na.rm = TRUE, verbose = TRUE ) ```

Arguments

 `x` Works with two classes: `numeric` and `formula`. Therefore you can write `"x"` or `"x~y"`. `"numeric input"`: a (non-empty) numeric vector of data values. `"formula input"`: a formula of the form lhs ~ rhs where lhs is a numeric variable giving the data values and rhs either 1 for a one-sample test or a factor with two levels giving the corresponding groups. `y` an optional (non-empty) numeric vector of data values. `data` an optional `data.frame`, which you can use only in combination with a `"formula input"` in argument `x`. `mu` a number indicating the true value of the mean (or difference in means if you are performing a two sample test). `d` a number indicating the specified effect size (Cohen's d) `alpha` the type I error. A number between 0 and 1. `power` 1 - beta (beta is the type II error probability). A number between 0 and 1. `alternative` a character string specifying the alternative hypothesis, must be one of `two.sided` (default), `greater` or `less`. You can specify just the initial letter. `paired` a logical indicating whether you want a paired t-test. `na.rm` a logical value indicating whether `NA` values should be stripped before the computation proceeds. `verbose` a logical value whether you want a verbose output or not.

Value

An object of the S4 class `seq_ttest_results`. Click on the class link to see the full description of the slots. To get access to the object use the `@`-operator or `[]`-brackets instead of `\$`. See the examples below.

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``` ```# set seed -------------------------------------------------------------------- set.seed(333) # load library ---------------------------------------------------------------- library(sprtt) # one sample: numeric input --------------------------------------------------- treatment_group <- rnorm(20, mean = 0, sd = 1) results <- seq_ttest(treatment_group, mu = 1, d = 0.8) # get access to the slots ----------------------------------------------------- # @ Operator results@likelihood_ratio # [] Operator results["likelihood_ratio"] # two sample: numeric input---------------------------------------------------- treatment_group <- stats::rnorm(20, mean = 0, sd = 1) control_group <- stats::rnorm(20, mean = 1, sd = 1) seq_ttest(treatment_group, control_group, d = 0.8) # two sample: formula input --------------------------------------------------- stress_level <- stats::rnorm(20, mean = 0, sd = 1) sex <- as.factor(c(rep(1, 10), rep(2, 10))) seq_ttest(stress_level ~ sex, d = 0.8) # NA in the data -------------------------------------------------------------- stress_level <- c(NA, stats::rnorm(20, mean = 0, sd = 2), NA) sex <- as.factor(c(rep(1, 11), rep(2, 11))) seq_ttest(stress_level ~ sex, d = 0.8, na.rm = TRUE) # work with dataset (data are in the package included) ------------------------ seq_ttest(monthly_income ~ sex, data = df_income, d = 0.8) ```

sprtt documentation built on Aug. 7, 2021, 1:06 a.m.