power.groups {emon} | R Documentation |
Power for comparing mean of two groups
Description
Calculates the power by simulation for comparing the mean of two groups of independent observations.
Usage
power.groups(change, change.type="M", n1, n2, pars1, pars2,
distribution, test, alternative="two", alpha=0.05, nsims=1000, nreps=999)
Arguments
change |
Mean of second group minus mean of first group (i.e. |
change.type |
Whether the parameter |
n1 |
Vector of sample sizes for group 1. Must be of same dimension as |
n2 |
Vector of sample sizes for group 2. Must be of same dimension as |
pars1 |
Parameters for the treatment data. If |
pars2 |
|
distribution |
The statistical distribution for the two groups. Can be either: |
test |
The statistical test used to compare the group means. If When |
alternative |
A character string specifying the alternative hypothesis, must be one of |
alpha |
The type 1 error for assessing statistical significance (default is 0.05) in the power simulations. |
nsims |
Number of repeat simulations to estimate power (default is 1000). |
nreps |
Number of repeat permutations for randomisation test (default is 999). |
Details
The Negative Binomial distribution option allows the user to specify the size parameter for both
groups 1 and 2. One possibility is to keep the size the same for both groupss. However, because the
mean is different between the groups and because the variance V = mu+mu^2/size, this means that V
will be different for the group 1 and group 2 distributions. If you want to keep the variance the
same, you can use the function size2.samevar
.
Several powers can be calculated per call to this function by specifying more than one values for
the sample sizes n1
and n2
.
Value
The power is returned. This is the proportion of the nreps
simulations that returned
a p-value less than the type1 error.
Author(s)
Jon Barry: Jon.Barry@cefas.co.uk
References
Manly BFJ (1997) Randomization, bootstrap and monte carlo methods in biology: 2nd edition. Chapman and Hall, London, 399 pages.
See Also
permute.groups
, glm.nb
, size2.samevar
Examples
library(MASS)
# In practice, \code{nsims} would be set to at least 1000
power.groups(change=2.5, change.type="A", n1=20, n2=20, pars1=c(10,2),
pars2=2, test='P', distribution="Normal", nsims=50)
power.groups(change=2.5, change.type="A", n1=seq(5,25,5), n2=seq(5,25,5), pars1=c(10,2),
pars2=2, test='P', distribution="Normal", nsims=50)
power.groups(change=25, change.type="M", n1=20, n2=20, pars1=10,
test='P', distribution="Poisson", nsims=50)
power.groups(change=4, change.type="A", n1=20, n2=20, pars1=c(1,2),
pars2=2, test='P', distribution="Lognormal", nsims=50)
# Keeping size constant
power.groups(change=100, change.type="M", n1=20, n2=20, pars1=c(5,2),
pars2=2, test='P', distribution="Negbin", nsims=50)
# Keeping variance constant
s2 = size2.samevar(mu1=5, mu2=10, s1=2) # 13.333
power.groups(change=100, change.type="M", n1=20, n2=20, pars1=c(5,2),
pars2=s2, test='P', distribution="Negbin", nsims=50)