sim.power.t.test {MKpower} | R Documentation |
Monte Carlo Simulations for Empirical Power of Two-sample t-Tests
Description
Simulate the empirical power and type-I-error of two-sample t-tests; i.e., classical (equal variances), Welch and Hsu t-tests.
Usage
sim.power.t.test(nx, rx, rx.H0 = NULL, ny, ry, ry.H0 = NULL,
sig.level = 0.05, conf.int = FALSE, mu = 0,
alternative = c("two.sided", "less", "greater"),
iter = 10000)
Arguments
nx |
single numeric, sample size of first group. |
rx |
function to simulate the values of first group (assuming H1). |
rx.H0 |
|
ny |
single numeric, sample size of second group. |
ry |
function to simulate the values of second group (assuming H1). |
ry.H0 |
|
sig.level |
significance level (type I error probability) |
conf.int |
logical, shall confidence intervals be computed. Increases computation time! |
mu |
true value of the location shift for the null hypothesis. |
alternative |
one- or two-sided test. Can be abbreviated. |
iter |
single integer, number of interations of the simulations. |
Details
Functions rx
and ry
are used to simulate the data under the
alternative hypothesis H1. If specified, functions rx.H0
and ry.H0
simulte the data unter the null hypothesis H0.
For fast computations functions from package matrixTests
are used.
Value
Object of class "sim.power.ttest"
with the results of the three t-tests
in the list elements Classical
, Welch
and Hsu
. In addition,
the simulation setup is saved in element SetUp
.
Author(s)
Matthias Kohl Matthias.Kohl@stamats.de
References
J. Hedderich, L. Sachs. Angewandte Statistik: Methodensammlung mit R. Springer 2018.
Hsu, P. (1938). Contribution to the theory of “student's” t-test as applied to the problem of two samples. Statistical Research Memoirs 2: 1-24.
Student (1908). The Probable Error of a Mean. Biometrika, 6(1): 1-25.
Welch, B. L. (1947). The generalization of “Student's” problem when several different population variances are involved. Biometrika, 34 (1-2): 28-35.
See Also
Examples
## Equal variance, small sample size
power.t.test(n = 5, delta = 2)
power.welch.t.test(n = 5, delta = 2)
power.hsu.t.test(n = 5, delta = 2)
sim.power.t.test(nx = 5, rx = rnorm, rx.H0 = rnorm,
ny = 5, ry = function(x) rnorm(x, mean = 2), ry.H0 = rnorm)
## Equal variance, moderate sample size
power.t.test(n = 25, delta = 0.8)
power.welch.t.test(n = 25, delta = 0.8)
power.hsu.t.test(n = 25, delta = 0.8)
sim.power.t.test(nx = 25, rx = rnorm, rx.H0 = rnorm,
ny = 25, ry = function(x) rnorm(x, mean = 0.8), ry.H0 = rnorm)
## Equal variance, high sample size
power.t.test(n = 100, delta = 0.4)
power.welch.t.test(n = 100, delta = 0.4)
power.hsu.t.test(n = 100, delta = 0.4)
sim.power.t.test(nx = 100, rx = rnorm, rx.H0 = rnorm,
ny = 100, ry = function(x) rnorm(x, mean = 0.4), ry.H0 = rnorm)
## Unequal variance, small sample size
power.welch.t.test(n = 5, delta = 5, sd1 = 1, sd2 = 3)
power.hsu.t.test(n = 5, delta = 5, sd1 = 1, sd2 = 3)
sim.power.t.test(nx = 5, rx = rnorm, rx.H0 = rnorm,
ny = 5, ry = function(x) rnorm(x, mean = 5, sd = 3),
ry.H0 = function(x) rnorm(x, sd = 3))
## Unequal variance, moderate sample size
power.welch.t.test(n = 25, delta = 1.8, sd1 = 1, sd2 = 3)
power.hsu.t.test(n = 25, delta = 1.8, sd1 = 1, sd2 = 3)
sim.power.t.test(nx = 25, rx = rnorm, rx.H0 = rnorm,
ny = 25, ry = function(x) rnorm(x, mean = 1.8, sd = 3),
ry.H0 = function(x) rnorm(x, sd = 3))
## Unequal variance, high sample size
power.welch.t.test(n = 100, delta = 0.9, sd1 = 1, sd2 = 3)
power.hsu.t.test(n = 100, delta = 0.9, sd1 = 1, sd2 = 3)
sim.power.t.test(nx = 100, rx = rnorm, rx.H0 = rnorm,
ny = 100, ry = function(x) rnorm(x, mean = 0.9, sd = 3),
ry.H0 = function(x) rnorm(x, sd = 3))
## Unequal variance, unequal sample sizes
## small sample sizes
sim.power.t.test(nx = 10, rx = rnorm, rx.H0 = rnorm,
ny = 5, ry = function(x) rnorm(x, mean = 5, sd = 3),
ry.H0 = function(x) rnorm(x, sd = 3))
sim.power.t.test(nx = 5, rx = rnorm, rx.H0 = rnorm,
ny = 10, ry = function(x) rnorm(x, mean = 3, sd = 3),
ry.H0 = function(x) rnorm(x, sd = 3))
## Unequal variance, unequal sample sizes
## moderate sample sizes
sim.power.t.test(nx = 25, rx = rnorm, rx.H0 = rnorm,
ny = 50, ry = function(x) rnorm(x, mean = 1.5, sd = 3),
ry.H0 = function(x) rnorm(x, sd = 3))
## Unequal variance, unequal sample sizes
## high sample sizes
sim.power.t.test(nx = 100, rx = rnorm, rx.H0 = rnorm,
ny = 200, ry = function(x) rnorm(x, mean = 0.6, sd = 3),
ry.H0 = function(x) rnorm(x, sd = 3))