Description Usage Arguments Details Value Author(s) References See Also Examples
Calculates the power by simulation for comparing the mean of two groups of independent observations.
1 2 | power.groups(change, change.type="M", n1, n2, pars1, pars2,
distribution, test, alternative="two", alpha=0.05, nsims=1000, nreps=999)
|
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). |
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.
The power is returned. This is the proportion of the nreps simulations that returned
a p-value less than the type1 error.
Jon Barry: Jon.Barry@cefas.co.uk
Manly BFJ (1997) Randomization, bootstrap and monte carlo methods in biology: 2nd edition. Chapman and Hall, London, 399 pages.
permute.groups, glm.nb, size2.samevar
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 | 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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.